[PATCH 1/2] pinctrl: mcp23s08: Extend match support for OF tables

Biju Das posted 2 patches 2 years, 3 months ago
There is a newer version of this series
[PATCH 1/2] pinctrl: mcp23s08: Extend match support for OF tables
Posted by Biju Das 2 years, 3 months ago
The driver has OF match table, still it uses ID lookup table for
retrieving match data. Currently the driver is working on the
assumption that a I2C device registered via OF will always match a
legacy I2C device ID. The correct approach is to have an OF device ID
table using of_device_match_data() if the devices are registered via OF.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/pinctrl/pinctrl-mcp23s08_i2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-mcp23s08_i2c.c b/drivers/pinctrl/pinctrl-mcp23s08_i2c.c
index 3dd1bd8e73eb..393d9b099cc5 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08_i2c.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08_i2c.c
@@ -10,9 +10,8 @@
 
 static int mcp230xx_probe(struct i2c_client *client)
 {
-	const struct i2c_device_id *id = i2c_client_get_device_id(client);
 	struct device *dev = &client->dev;
-	unsigned int type = id->driver_data;
+	unsigned int type;
 	struct mcp23s08 *mcp;
 	int ret;
 
@@ -20,6 +19,7 @@ static int mcp230xx_probe(struct i2c_client *client)
 	if (!mcp)
 		return -ENOMEM;
 
+	type = (uintptr_t)i2c_get_match_data(client);
 	switch (type) {
 	case MCP_TYPE_008:
 		mcp->regmap = devm_regmap_init_i2c(client, &mcp23x08_regmap);
-- 
2.25.1
Re: [PATCH 1/2] pinctrl: mcp23s08: Extend match support for OF tables
Posted by Andy Shevchenko 2 years, 3 months ago
On Sat, Sep 02, 2023 at 10:09:36AM +0100, Biju Das wrote:
> The driver has OF match table, still it uses ID lookup table for
> retrieving match data. Currently the driver is working on the
> assumption that a I2C device registered via OF will always match a
> legacy I2C device ID. The correct approach is to have an OF device ID
> table using of_device_match_data() if the devices are registered via OF.

...

> -	const struct i2c_device_id *id = i2c_client_get_device_id(client);
>  	struct device *dev = &client->dev;
> -	unsigned int type = id->driver_data;

> +	unsigned int type;


Now it's shorter than below line, so move it further.

>  	struct mcp23s08 *mcp;
>  	int ret;

-- 
With Best Regards,
Andy Shevchenko