* [PATCH v1 1/1] iio: light: tsl2772: Make use of device properties
@ 2022-04-13 18:14 Andy Shevchenko
2022-04-16 11:12 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2022-04-13 18:14 UTC (permalink / raw)
To: Andy Shevchenko, linux-iio, linux-kernel
Cc: Jonathan Cameron, Lars-Peter Clausen
Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.
While at it, reuse temporary device pointer in the same function.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/light/tsl2772.c | 25 ++++++++++---------------
1 file changed, 10 insertions(+), 15 deletions(-)
diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c
index 729f14d9f2a4..dd9051f1cc1a 100644
--- a/drivers/iio/light/tsl2772.c
+++ b/drivers/iio/light/tsl2772.c
@@ -15,7 +15,9 @@
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
+#include <linux/property.h>
#include <linux/slab.h>
+
#include <linux/iio/events.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -549,10 +551,10 @@ static int tsl2772_get_prox(struct iio_dev *indio_dev)
static int tsl2772_read_prox_led_current(struct tsl2772_chip *chip)
{
- struct device_node *of_node = chip->client->dev.of_node;
+ struct device *dev = &chip->client->dev;
int ret, tmp, i;
- ret = of_property_read_u32(of_node, "led-max-microamp", &tmp);
+ ret = device_property_read_u32(dev, "led-max-microamp", &tmp);
if (ret < 0)
return ret;
@@ -563,20 +565,18 @@ static int tsl2772_read_prox_led_current(struct tsl2772_chip *chip)
}
}
- dev_err(&chip->client->dev, "Invalid value %d for led-max-microamp\n",
- tmp);
+ dev_err(dev, "Invalid value %d for led-max-microamp\n", tmp);
return -EINVAL;
-
}
static int tsl2772_read_prox_diodes(struct tsl2772_chip *chip)
{
- struct device_node *of_node = chip->client->dev.of_node;
+ struct device *dev = &chip->client->dev;
int i, ret, num_leds, prox_diode_mask;
u32 leds[TSL2772_MAX_PROX_LEDS];
- ret = of_property_count_u32_elems(of_node, "amstaos,proximity-diodes");
+ ret = device_property_count_u32(dev, "amstaos,proximity-diodes");
if (ret < 0)
return ret;
@@ -584,12 +584,9 @@ static int tsl2772_read_prox_diodes(struct tsl2772_chip *chip)
if (num_leds > TSL2772_MAX_PROX_LEDS)
num_leds = TSL2772_MAX_PROX_LEDS;
- ret = of_property_read_u32_array(of_node, "amstaos,proximity-diodes",
- leds, num_leds);
+ ret = device_property_read_u32_array(dev, "amstaos,proximity-diodes", leds, num_leds);
if (ret < 0) {
- dev_err(&chip->client->dev,
- "Invalid value for amstaos,proximity-diodes: %d.\n",
- ret);
+ dev_err(dev, "Invalid value for amstaos,proximity-diodes: %d.\n", ret);
return ret;
}
@@ -600,9 +597,7 @@ static int tsl2772_read_prox_diodes(struct tsl2772_chip *chip)
else if (leds[i] == 1)
prox_diode_mask |= TSL2772_DIODE1;
else {
- dev_err(&chip->client->dev,
- "Invalid value %d in amstaos,proximity-diodes.\n",
- leds[i]);
+ dev_err(dev, "Invalid value %d in amstaos,proximity-diodes.\n", leds[i]);
return -EINVAL;
}
}
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v1 1/1] iio: light: tsl2772: Make use of device properties
2022-04-13 18:14 [PATCH v1 1/1] iio: light: tsl2772: Make use of device properties Andy Shevchenko
@ 2022-04-16 11:12 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-04-16 11:12 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-iio, linux-kernel, Lars-Peter Clausen, Brian Masney
On Wed, 13 Apr 2022 21:14:02 +0300
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.
>
> While at it, reuse temporary device pointer in the same function.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+CC Bryan as an FYI.
Applied to the togreg branch of iio.git and pushed out as testing for
all the normal reasons.
Thanks,
Jonathan
> ---
> drivers/iio/light/tsl2772.c | 25 ++++++++++---------------
> 1 file changed, 10 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c
> index 729f14d9f2a4..dd9051f1cc1a 100644
> --- a/drivers/iio/light/tsl2772.c
> +++ b/drivers/iio/light/tsl2772.c
> @@ -15,7 +15,9 @@
> #include <linux/kernel.h>
> #include <linux/module.h>
> #include <linux/mutex.h>
> +#include <linux/property.h>
> #include <linux/slab.h>
> +
> #include <linux/iio/events.h>
> #include <linux/iio/iio.h>
> #include <linux/iio/sysfs.h>
> @@ -549,10 +551,10 @@ static int tsl2772_get_prox(struct iio_dev *indio_dev)
>
> static int tsl2772_read_prox_led_current(struct tsl2772_chip *chip)
> {
> - struct device_node *of_node = chip->client->dev.of_node;
> + struct device *dev = &chip->client->dev;
> int ret, tmp, i;
>
> - ret = of_property_read_u32(of_node, "led-max-microamp", &tmp);
> + ret = device_property_read_u32(dev, "led-max-microamp", &tmp);
> if (ret < 0)
> return ret;
>
> @@ -563,20 +565,18 @@ static int tsl2772_read_prox_led_current(struct tsl2772_chip *chip)
> }
> }
>
> - dev_err(&chip->client->dev, "Invalid value %d for led-max-microamp\n",
> - tmp);
> + dev_err(dev, "Invalid value %d for led-max-microamp\n", tmp);
>
> return -EINVAL;
> -
> }
>
> static int tsl2772_read_prox_diodes(struct tsl2772_chip *chip)
> {
> - struct device_node *of_node = chip->client->dev.of_node;
> + struct device *dev = &chip->client->dev;
> int i, ret, num_leds, prox_diode_mask;
> u32 leds[TSL2772_MAX_PROX_LEDS];
>
> - ret = of_property_count_u32_elems(of_node, "amstaos,proximity-diodes");
> + ret = device_property_count_u32(dev, "amstaos,proximity-diodes");
> if (ret < 0)
> return ret;
>
> @@ -584,12 +584,9 @@ static int tsl2772_read_prox_diodes(struct tsl2772_chip *chip)
> if (num_leds > TSL2772_MAX_PROX_LEDS)
> num_leds = TSL2772_MAX_PROX_LEDS;
>
> - ret = of_property_read_u32_array(of_node, "amstaos,proximity-diodes",
> - leds, num_leds);
> + ret = device_property_read_u32_array(dev, "amstaos,proximity-diodes", leds, num_leds);
> if (ret < 0) {
> - dev_err(&chip->client->dev,
> - "Invalid value for amstaos,proximity-diodes: %d.\n",
> - ret);
> + dev_err(dev, "Invalid value for amstaos,proximity-diodes: %d.\n", ret);
> return ret;
> }
>
> @@ -600,9 +597,7 @@ static int tsl2772_read_prox_diodes(struct tsl2772_chip *chip)
> else if (leds[i] == 1)
> prox_diode_mask |= TSL2772_DIODE1;
> else {
> - dev_err(&chip->client->dev,
> - "Invalid value %d in amstaos,proximity-diodes.\n",
> - leds[i]);
> + dev_err(dev, "Invalid value %d in amstaos,proximity-diodes.\n", leds[i]);
> return -EINVAL;
> }
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-16 11:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-13 18:14 [PATCH v1 1/1] iio: light: tsl2772: Make use of device properties Andy Shevchenko
2022-04-16 11:12 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox