diff mbox series

[v1,1/2] pinctrl: msm: Switch to use device_property_count_uXX()

Message ID 20190723192738.68486-1-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [v1,1/2] pinctrl: msm: Switch to use device_property_count_uXX() | expand

Commit Message

Andy Shevchenko July 23, 2019, 7:27 p.m. UTC
Use use device_property_count_uXX() directly, that makes code neater.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/pinctrl/qcom/pinctrl-msm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Linus Walleij Aug. 5, 2019, 10:01 a.m. UTC | #1
On Tue, Jul 23, 2019 at 9:27 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> Use use device_property_count_uXX() directly, that makes code neater.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
(...)
>         /* The number of GPIOs in the ACPI tables */
> -       len = ret = device_property_read_u16_array(pctrl->dev, "gpios", NULL,
> -                                                  0);
> +       len = ret = device_property_count_u16(pctrl->dev, "gpios");

Patch applied (makes the kernel a better place) but:

Can't we just use: gpiod_count(pctrl->dev, NULL); ?

It's more to the point when counting gpios I think.

However this driver is not includeing <linux/gpio/consumer.h>
and is this "gpios" property really a consumer property? I think
so but...

Yours,
Linus Walleij
Andy Shevchenko Aug. 5, 2019, 10:24 a.m. UTC | #2
On Mon, Aug 05, 2019 at 12:01:11PM +0200, Linus Walleij wrote:
> On Tue, Jul 23, 2019 at 9:27 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> 
> > Use use device_property_count_uXX() directly, that makes code neater.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> (...)
> >         /* The number of GPIOs in the ACPI tables */
> > -       len = ret = device_property_read_u16_array(pctrl->dev, "gpios", NULL,
> > -                                                  0);
> > +       len = ret = device_property_count_u16(pctrl->dev, "gpios");
> 
> Patch applied (makes the kernel a better place) but:

Thanks!

> Can't we just use: gpiod_count(pctrl->dev, NULL); ?

Perhaps. I have no hardware to test and the question probably better to be
addressed to author(s) of the driver.

My scope is to convert to new extension to device property API, so, anyone who
will look for examples will not use the old approach.

> It's more to the point when counting gpios I think.
> 
> However this driver is not includeing <linux/gpio/consumer.h>
> and is this "gpios" property really a consumer property? I think
> so but...

Sounds like this is an old driver and many questions to it applies.
diff mbox series

Patch

diff --git a/drivers/pinctrl/qcom/pinctrl-msm.c b/drivers/pinctrl/qcom/pinctrl-msm.c
index 7f35c196bb3e..90bc667139e0 100644
--- a/drivers/pinctrl/qcom/pinctrl-msm.c
+++ b/drivers/pinctrl/qcom/pinctrl-msm.c
@@ -617,8 +617,7 @@  static int msm_gpio_init_valid_mask(struct gpio_chip *chip)
 	}
 
 	/* The number of GPIOs in the ACPI tables */
-	len = ret = device_property_read_u16_array(pctrl->dev, "gpios", NULL,
-						   0);
+	len = ret = device_property_count_u16(pctrl->dev, "gpios");
 	if (ret < 0)
 		return 0;
 
@@ -996,7 +995,7 @@  static bool msm_gpio_needs_valid_mask(struct msm_pinctrl *pctrl)
 	if (pctrl->soc->reserved_gpios)
 		return true;
 
-	return device_property_read_u16_array(pctrl->dev, "gpios", NULL, 0) > 0;
+	return device_property_count_u16(pctrl->dev, "gpios") > 0;
 }
 
 static int msm_gpio_init(struct msm_pinctrl *pctrl)