On Thu, Jul 2, 2020 at 3:18 PM Sungbo Eo <mans0n@xxxxxxxxxx> wrote: > > NXP PCA9570 is 4-bit I2C GPO expander without interrupt functionality. is a 4-bit > Its ports are controlled only by a data byte without register address. > > As there is no other driver similar enough to be adapted for it, a new > driver is introduced here. Can we have a Datasheet: tag with URL attached to it? ... > +static int pca9570_read(struct pca9570 *gpio, u8 *value) > +{ > + s32 ret; > + > + ret = i2c_smbus_read_byte(gpio->client); > + if (ret < 0) > + return ret; > + > + *value = (u8)ret; I doubt casting is needed. > + return 0; > +} ... > +static const struct i2c_device_id pca9570_id_table[] = { > + { "pca9570", 4 }, > + { /* sentinel */ } > +}; > +MODULE_DEVICE_TABLE(i2c, pca9570_id_table); > + > +static const struct of_device_id pca9570_of_match_table[] = { > + { .compatible = "nxp,pca9570" }, This driver data should also have 4. > + { /* sentinel */ } > +}; ... > + gpio->chip.ngpio = i2c_match_id(pca9570_id_table, client)->driver_data; Oh, avoid direct access to the table like this. And you may simply use device_get_match_data(). ... > + /* Read the current output level */ > + (void) pca9570_read(gpio, &gpio->out); (void) casting is not needed. And I'm not sure hiding an error is a good idea. But the latter is up to you. -- With Best Regards, Andy Shevchenko