diff mbox series

[v1,1/4] gpio: pca953x: Switch to use device_get_match_data()

Message ID 20190801173938.36676-1-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [v1,1/4] gpio: pca953x: Switch to use device_get_match_data() | expand

Commit Message

Andy Shevchenko Aug. 1, 2019, 5:39 p.m. UTC
Instead of open coded variants, switch to direct use of
device_get_match_data().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-pca953x.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

Comments

Bartosz Golaszewski Aug. 2, 2019, 7:51 a.m. UTC | #1
czw., 1 sie 2019 o 19:39 Andy Shevchenko
<andriy.shevchenko@linux.intel.com> napisaƂ(a):
>
> Instead of open coded variants, switch to direct use of
> device_get_match_data().
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpio-pca953x.c | 20 ++++++++------------
>  1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 378b206d2dc9..54cf01901320 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -949,19 +949,15 @@ static int pca953x_probe(struct i2c_client *client,
>         if (i2c_id) {
>                 chip->driver_data = i2c_id->driver_data;
>         } else {
> -               const struct acpi_device_id *acpi_id;
> -               struct device *dev = &client->dev;
> -
> -               chip->driver_data = (uintptr_t)of_device_get_match_data(dev);
> -               if (!chip->driver_data) {
> -                       acpi_id = acpi_match_device(pca953x_acpi_ids, dev);
> -                       if (!acpi_id) {
> -                               ret = -ENODEV;
> -                               goto err_exit;
> -                       }
> -
> -                       chip->driver_data = acpi_id->driver_data;
> +               const void *match;
> +
> +               match = device_get_match_data(&client->dev);
> +               if (!match) {
> +                       ret = -ENODEV;
> +                       goto err_exit;
>                 }
> +
> +               chip->driver_data = (uintptr_t)match;
>         }
>
>         i2c_set_clientdata(client, chip);
> --
> 2.20.1
>

Excellent work, all four applied.

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index 378b206d2dc9..54cf01901320 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -949,19 +949,15 @@  static int pca953x_probe(struct i2c_client *client,
 	if (i2c_id) {
 		chip->driver_data = i2c_id->driver_data;
 	} else {
-		const struct acpi_device_id *acpi_id;
-		struct device *dev = &client->dev;
-
-		chip->driver_data = (uintptr_t)of_device_get_match_data(dev);
-		if (!chip->driver_data) {
-			acpi_id = acpi_match_device(pca953x_acpi_ids, dev);
-			if (!acpi_id) {
-				ret = -ENODEV;
-				goto err_exit;
-			}
-
-			chip->driver_data = acpi_id->driver_data;
+		const void *match;
+
+		match = device_get_match_data(&client->dev);
+		if (!match) {
+			ret = -ENODEV;
+			goto err_exit;
 		}
+
+		chip->driver_data = (uintptr_t)match;
 	}
 
 	i2c_set_clientdata(client, chip);