> > +static int mv88e6xxx_region_global_snapshot(struct devlink *dl, > > + const struct devlink_region_ops > > *ops, > > + struct netlink_ext_ack *extack, > > + u8 **data) > > +{ > > + struct dsa_switch *ds = dsa_devlink_to_ds(dl); > > + struct mv88e6xxx_chip *chip = ds->priv; > > + u16 *registers; > > + int i, err; > > + > > + registers = kmalloc_array(32, sizeof(u16), GFP_KERNEL); > > + if (!registers) > > + return -ENOMEM; > > + > > + mv88e6xxx_reg_lock(chip); > > + for (i = 0; i < 32; i++) { > > + switch ((long)ops->priv) { > > + case 1: > > + err = mv88e6xxx_g1_read(chip, i, ®isters[i]); > > + break; > > + case 2: > > + err = mv88e6xxx_g1_read(chip, i, ®isters[i]); > > Should this be mv88e6xxx_g2_read() here?
Doh! Thanks. > Can you use the region IDs you defined above? Yes. That would be more readable. I probably need to make ops->priv point to a real structure, to avoid compiler warnings about down sizing types on casts. Andrew