[PATCH RFC 2/4] i2c: mux: ltc4306: convert to using a pointer in i2c_device_id

Dmitry Torokhov posted 4 patches 2 years, 4 months ago
[PATCH RFC 2/4] i2c: mux: ltc4306: convert to using a pointer in i2c_device_id
Posted by Dmitry Torokhov 2 years, 4 months ago
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-ltc4306.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-mux-ltc4306.c b/drivers/i2c/muxes/i2c-mux-ltc4306.c
index 637e25506490..17b9ed9ceef3 100644
--- a/drivers/i2c/muxes/i2c-mux-ltc4306.c
+++ b/drivers/i2c/muxes/i2c-mux-ltc4306.c
@@ -192,8 +192,8 @@ static int ltc4306_deselect_mux(struct i2c_mux_core *muxc, u32 chan)
 }
 
 static const struct i2c_device_id ltc4306_id[] = {
-	{ "ltc4305", ltc_4305 },
-	{ "ltc4306", ltc_4306 },
+	{ "ltc4305", .data = &chips[ltc_4305] },
+	{ "ltc4306", .data = &chips[ltc_4306] },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, ltc4306_id);
@@ -217,9 +217,8 @@ static int ltc4306_probe(struct i2c_client *client)
 	int num, ret;
 
 	chip = of_device_get_match_data(&client->dev);
-
 	if (!chip)
-		chip = &chips[i2c_match_id(ltc4306_id, client)->driver_data];
+		chip = i2c_match_id(ltc4306_id, client)->data;
 
 	idle_disc = device_property_read_bool(&client->dev,
 					      "i2c-mux-idle-disconnect");

-- 
2.41.0.694.ge786442a9b-goog
Re: [PATCH RFC 2/4] i2c: mux: ltc4306: convert to using a pointer in i2c_device_id
Posted by Andy Shevchenko 2 years, 4 months ago
On Mon, Aug 14, 2023 at 02:52:50PM -0700, Dmitry Torokhov wrote:
> Switch the driver to use newly added "data" pointer in i2c_device_id to
> streamline DT and legacy flows.

...

>  	chip = of_device_get_match_data(&client->dev);
> -
>  	if (!chip)
> -		chip = &chips[i2c_match_id(ltc4306_id, client)->driver_data];
> +		chip = i2c_match_id(ltc4306_id, client)->data;

The whole thing can be converted to i2c_device_get_match_data() with the new
helper from another thread. That said, I don't see value in this half-baked
change.

-- 
With Best Regards,
Andy Shevchenko