diff mbox series

[v1,2/2] gpio: adnp: Make use of device properties

Message ID 20220628195913.36940-2-andriy.shevchenko@linux.intel.com
State Accepted
Commit 8773bacefcd7a5c742437974771976a9e79288f7
Headers show
Series None | expand

Commit Message

Andy Shevchenko June 28, 2022, 7:59 p.m. UTC
Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-adnp.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Linus Walleij June 28, 2022, 8:29 p.m. UTC | #1
On Tue, Jun 28, 2022 at 9:59 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> Convert the module to be property provider agnostic and allow
> it to be used on non-OF platforms.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Very nice!
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Bartosz Golaszewski July 1, 2022, 9:37 a.m. UTC | #2
On Tue, Jun 28, 2022 at 9:59 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Convert the module to be property provider agnostic and allow
> it to be used on non-OF platforms.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpio-adnp.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
> index 075782831044..a6439e3daff0 100644
> --- a/drivers/gpio/gpio-adnp.c
> +++ b/drivers/gpio/gpio-adnp.c
> @@ -6,8 +6,9 @@
>  #include <linux/gpio/driver.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
> -#include <linux/of_irq.h>
> +#include <linux/property.h>
>  #include <linux/seq_file.h>
>  #include <linux/slab.h>
>
> @@ -487,19 +488,15 @@ static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios,
>
>  static int adnp_i2c_probe(struct i2c_client *client)
>  {
> -       struct device_node *np = client->dev.of_node;
> +       struct device *dev = &client->dev;
>         struct adnp *adnp;
>         u32 num_gpios;
>         int err;
>
> -       err = of_property_read_u32(np, "nr-gpios", &num_gpios);
> +       err = device_property_read_u32(dev, "nr-gpios", &num_gpios);
>         if (err < 0)
>                 return err;
>
> -       client->irq = irq_of_parse_and_map(np, 0);
> -       if (!client->irq)
> -               return -EPROBE_DEFER;
> -
>         adnp = devm_kzalloc(&client->dev, sizeof(*adnp), GFP_KERNEL);
>         if (!adnp)
>                 return -ENOMEM;
> @@ -507,8 +504,7 @@ static int adnp_i2c_probe(struct i2c_client *client)
>         mutex_init(&adnp->i2c_lock);
>         adnp->client = client;
>
> -       err = adnp_gpio_setup(adnp, num_gpios,
> -                       of_property_read_bool(np, "interrupt-controller"));
> +       err = adnp_gpio_setup(adnp, num_gpios, device_property_read_bool(dev, "interrupt-controller"));
>         if (err)
>                 return err;
>
> --
> 2.35.1
>

Applied, thanks!

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
index 075782831044..a6439e3daff0 100644
--- a/drivers/gpio/gpio-adnp.c
+++ b/drivers/gpio/gpio-adnp.c
@@ -6,8 +6,9 @@ 
 #include <linux/gpio/driver.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
-#include <linux/of_irq.h>
+#include <linux/property.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 
@@ -487,19 +488,15 @@  static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios,
 
 static int adnp_i2c_probe(struct i2c_client *client)
 {
-	struct device_node *np = client->dev.of_node;
+	struct device *dev = &client->dev;
 	struct adnp *adnp;
 	u32 num_gpios;
 	int err;
 
-	err = of_property_read_u32(np, "nr-gpios", &num_gpios);
+	err = device_property_read_u32(dev, "nr-gpios", &num_gpios);
 	if (err < 0)
 		return err;
 
-	client->irq = irq_of_parse_and_map(np, 0);
-	if (!client->irq)
-		return -EPROBE_DEFER;
-
 	adnp = devm_kzalloc(&client->dev, sizeof(*adnp), GFP_KERNEL);
 	if (!adnp)
 		return -ENOMEM;
@@ -507,8 +504,7 @@  static int adnp_i2c_probe(struct i2c_client *client)
 	mutex_init(&adnp->i2c_lock);
 	adnp->client = client;
 
-	err = adnp_gpio_setup(adnp, num_gpios,
-			of_property_read_bool(np, "interrupt-controller"));
+	err = adnp_gpio_setup(adnp, num_gpios, device_property_read_bool(dev, "interrupt-controller"));
 	if (err)
 		return err;