Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: pcf857x: Extend match data support for OF tables

The driver has OF match table, but still it uses an ID lookup table for
retrieving match data. Currently, the driver is working on the
assumption that an I2C device registered via OF will always match a
legacy I2C device ID. Extend match data support for OF tables by using
i2c_get_match_data() instead of the ID lookup for both OF/ID matches by
making similar OF/ID tables.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

authored by

Biju Das and committed by
Bartosz Golaszewski
db3b16dc bb5ad5ef

+14 -15
+14 -15
drivers/gpio/gpio-pcf857x.c
··· 36 36 MODULE_DEVICE_TABLE(i2c, pcf857x_id); 37 37 38 38 static const struct of_device_id pcf857x_of_table[] = { 39 - { .compatible = "nxp,pcf8574" }, 40 - { .compatible = "nxp,pcf8574a" }, 41 - { .compatible = "nxp,pca8574" }, 42 - { .compatible = "nxp,pca9670" }, 43 - { .compatible = "nxp,pca9672" }, 44 - { .compatible = "nxp,pca9674" }, 45 - { .compatible = "nxp,pcf8575" }, 46 - { .compatible = "nxp,pca8575" }, 47 - { .compatible = "nxp,pca9671" }, 48 - { .compatible = "nxp,pca9673" }, 49 - { .compatible = "nxp,pca9675" }, 50 - { .compatible = "maxim,max7328" }, 51 - { .compatible = "maxim,max7329" }, 39 + { .compatible = "nxp,pcf8574", (void *)8 }, 40 + { .compatible = "nxp,pcf8574a", (void *)8 }, 41 + { .compatible = "nxp,pca8574", (void *)8 }, 42 + { .compatible = "nxp,pca9670", (void *)8 }, 43 + { .compatible = "nxp,pca9672", (void *)8 }, 44 + { .compatible = "nxp,pca9674", (void *)8 }, 45 + { .compatible = "nxp,pcf8575", (void *)16 }, 46 + { .compatible = "nxp,pca8575", (void *)16 }, 47 + { .compatible = "nxp,pca9671", (void *)16 }, 48 + { .compatible = "nxp,pca9673", (void *)16 }, 49 + { .compatible = "nxp,pca9675", (void *)16 }, 50 + { .compatible = "maxim,max7328", (void *)8 }, 51 + { .compatible = "maxim,max7329", (void *)8 }, 52 52 { } 53 53 }; 54 54 MODULE_DEVICE_TABLE(of, pcf857x_of_table); ··· 272 272 273 273 static int pcf857x_probe(struct i2c_client *client) 274 274 { 275 - const struct i2c_device_id *id = i2c_client_get_device_id(client); 276 275 struct pcf857x *gpio; 277 276 unsigned int n_latch = 0; 278 277 int status; ··· 295 296 gpio->chip.set_multiple = pcf857x_set_multiple; 296 297 gpio->chip.direction_input = pcf857x_input; 297 298 gpio->chip.direction_output = pcf857x_output; 298 - gpio->chip.ngpio = id->driver_data; 299 + gpio->chip.ngpio = (uintptr_t)i2c_get_match_data(client); 299 300 300 301 /* NOTE: the OnSemi jlc1562b is also largely compatible with 301 302 * these parts, notably for output. It has a low-resolution