diff mbox series

[RFC,3/4] i2c: mux: pca954x: convert to using a pointer in i2c_device_id

Message ID 20230814-i2c-id-rework-v1-3-3e5bc71c49ee@gmail.com
State RFC
Headers show
Series Start unification of of_device_id and i2c_device_id | expand

Commit Message

Dmitry Torokhov Aug. 14, 2023, 9:52 p.m. UTC
Switch the driver to use newly added "data" pointer in i2c_device_id to
streamline DT and legacy flows.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/i2c/muxes/i2c-mux-pca954x.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

Comments

Andy Shevchenko Aug. 15, 2023, 3:51 p.m. UTC | #1
On Mon, Aug 14, 2023 at 02:52:51PM -0700, Dmitry Torokhov wrote:
> Switch the driver to use newly added "data" pointer in i2c_device_id to
> streamline DT and legacy flows.

...

> @@ -206,7 +206,7 @@ static const struct of_device_id pca954x_of_match[] = {
>  	{ .compatible = "nxp,pca9847", .data = &chips[pca_9847] },
>  	{ .compatible = "nxp,pca9848", .data = &chips[pca_9848] },
>  	{ .compatible = "nxp,pca9849", .data = &chips[pca_9849] },
> -	{}
> +	{ }
>  };
>  MODULE_DEVICE_TABLE(of, pca954x_of_match);

Stray change.

...

>  	data->chip = device_get_match_data(dev);
>  	if (!data->chip)
> -		data->chip = &chips[id->driver_data];
> +		data->chip = id->data;

Same, why not to use that helper and if anything, modify it instead.
diff mbox series

Patch

diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
index 6965bf4c2348..c8540e4ca660 100644
--- a/drivers/i2c/muxes/i2c-mux-pca954x.c
+++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
@@ -177,18 +177,18 @@  static const struct chip_desc chips[] = {
 };
 
 static const struct i2c_device_id pca954x_id[] = {
-	{ "pca9540", pca_9540 },
-	{ "pca9542", pca_9542 },
-	{ "pca9543", pca_9543 },
-	{ "pca9544", pca_9544 },
-	{ "pca9545", pca_9545 },
-	{ "pca9546", pca_9546 },
-	{ "pca9547", pca_9547 },
-	{ "pca9548", pca_9548 },
-	{ "pca9846", pca_9846 },
-	{ "pca9847", pca_9847 },
-	{ "pca9848", pca_9848 },
-	{ "pca9849", pca_9849 },
+	{ "pca9540", .data = &chips[pca_9540] },
+	{ "pca9542", .data = &chips[pca_9542] },
+	{ "pca9543", .data = &chips[pca_9543] },
+	{ "pca9544", .data = &chips[pca_9544] },
+	{ "pca9545", .data = &chips[pca_9545] },
+	{ "pca9546", .data = &chips[pca_9546] },
+	{ "pca9547", .data = &chips[pca_9547] },
+	{ "pca9548", .data = &chips[pca_9548] },
+	{ "pca9846", .data = &chips[pca_9846] },
+	{ "pca9847", .data = &chips[pca_9847] },
+	{ "pca9848", .data = &chips[pca_9848] },
+	{ "pca9849", .data = &chips[pca_9849] },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, pca954x_id);
@@ -206,7 +206,7 @@  static const struct of_device_id pca954x_of_match[] = {
 	{ .compatible = "nxp,pca9847", .data = &chips[pca_9847] },
 	{ .compatible = "nxp,pca9848", .data = &chips[pca_9848] },
 	{ .compatible = "nxp,pca9849", .data = &chips[pca_9849] },
-	{}
+	{ }
 };
 MODULE_DEVICE_TABLE(of, pca954x_of_match);
 
@@ -447,7 +447,7 @@  static int pca954x_probe(struct i2c_client *client)
 
 	data->chip = device_get_match_data(dev);
 	if (!data->chip)
-		data->chip = &chips[id->driver_data];
+		data->chip = id->data;
 
 	if (data->chip->id.manufacturer_id != I2C_DEVICE_ID_NONE) {
 		struct i2c_device_identity id;