diff mbox series

gpio: pca953x: Use i2c_get_match_data()

Message ID 20230819173747.8682-1-biju.das.jz@bp.renesas.com
State New
Headers show
Series gpio: pca953x: Use i2c_get_match_data() | expand

Commit Message

Biju Das Aug. 19, 2023, 5:37 p.m. UTC
Replace device_get_match_data() and id lookup for retrieving match data
by i2c_get_match_data().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Note:
 This patch is only compile tested.
---
 drivers/gpio/gpio-pca953x.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

Comments

Andy Shevchenko Aug. 21, 2023, 12:55 p.m. UTC | #1
On Sat, Aug 19, 2023 at 06:37:47PM +0100, Biju Das wrote:
> Replace device_get_match_data() and id lookup for retrieving match data
> by i2c_get_match_data().

...

> -	if (i2c_id) {
> -		chip->driver_data = i2c_id->driver_data;
> -	} else {
> -		const void *match;
> -
> -		match = device_get_match_data(&client->dev);
> -		if (!match) {
> -			ret = -ENODEV;
> -			goto err_exit;
> -		}
> -
> -		chip->driver_data = (uintptr_t)match;
> +	chip->driver_data = (uintptr_t)i2c_get_match_data(client);
> +	if (!chip->driver_data) {
> +		ret = -ENODEV;
> +		goto err_exit;
>  	}

Can you move this to be called before devm_regulator_get()? It doesn't require
regulator to be enabled for functioning.
Biju Das Aug. 24, 2023, 1:43 p.m. UTC | #2
Hi Andy Shevchenko,

Thanks for the feedback.

> Subject: Re: [PATCH] gpio: pca953x: Use i2c_get_match_data()
> 
> On Sat, Aug 19, 2023 at 06:37:47PM +0100, Biju Das wrote:
> > Replace device_get_match_data() and id lookup for retrieving match
> > data by i2c_get_match_data().
> 
> ...
> 
> > -	if (i2c_id) {
> > -		chip->driver_data = i2c_id->driver_data;
> > -	} else {
> > -		const void *match;
> > -
> > -		match = device_get_match_data(&client->dev);
> > -		if (!match) {
> > -			ret = -ENODEV;
> > -			goto err_exit;
> > -		}
> > -
> > -		chip->driver_data = (uintptr_t)match;
> > +	chip->driver_data = (uintptr_t)i2c_get_match_data(client);
> > +	if (!chip->driver_data) {
> > +		ret = -ENODEV;
> > +		goto err_exit;
> >  	}
> 
> Can you move this to be called before devm_regulator_get()? It doesn't
> require regulator to be enabled for functioning.

OK will do.

Cheers,
Biju
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index a806a3c1b801..1ef6cf182e64 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -1051,7 +1051,6 @@  static int device_pca957x_init(struct pca953x_chip *chip, u32 invert)
 
 static int pca953x_probe(struct i2c_client *client)
 {
-	const struct i2c_device_id *i2c_id = i2c_client_get_device_id(client);
 	struct pca953x_platform_data *pdata;
 	struct pca953x_chip *chip;
 	int irq_base = 0;
@@ -1102,18 +1101,10 @@  static int pca953x_probe(struct i2c_client *client)
 	}
 	chip->regulator = reg;
 
-	if (i2c_id) {
-		chip->driver_data = i2c_id->driver_data;
-	} else {
-		const void *match;
-
-		match = device_get_match_data(&client->dev);
-		if (!match) {
-			ret = -ENODEV;
-			goto err_exit;
-		}
-
-		chip->driver_data = (uintptr_t)match;
+	chip->driver_data = (uintptr_t)i2c_get_match_data(client);
+	if (!chip->driver_data) {
+		ret = -ENODEV;
+		goto err_exit;
 	}
 
 	i2c_set_clientdata(client, chip);