linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] iio:light:tsl2563 use generic fw accessors
@ 2020-10-18 20:35 Vaishnav M A
  2020-11-01 15:29 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Vaishnav M A @ 2020-10-18 20:35 UTC (permalink / raw)
  To: jic23, andy.shevchenko, wsa, knaack.h, lars, alexandru.ardelean,
	matt.ranostay, linux-iio, linux-kernel
  Cc: jkridner, drew, robertcnelson, rajkovic, vaishnav

Replace of_property_read_u32() with device_property_read_u32(),
when reading the amstaos,cover-comp-gain.This opens up the
possibility of passing the properties during platform instantiation
of the device by a suitable populated struct property_entry.
Additionally, a minor change in logic is added to remove the
of_node present check.

Signed-off-by: Vaishnav M A <vaishnav@beagleboard.org>
---
 v4:
	-update commit message, fix punctuation.
	-update to a shorter commit title, used for similar changes
	 within the subsystem, like in 00fa493b9989
	 ("iio:proximity:as3935: Drop of_match_ptr and use generic fw accessors")
 v3:
        -modify commit message for readability, mention minor logic change
        -include  mod_devicetable.h and property.h headers
 v2:
        -fix commit message
 drivers/iio/light/tsl2563.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
index abc8d7db8dc1..5bf2bfbc5379 100644
--- a/drivers/iio/light/tsl2563.c
+++ b/drivers/iio/light/tsl2563.c
@@ -12,6 +12,8 @@
  */
 
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/property.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/irq.h>
@@ -703,7 +705,6 @@ static int tsl2563_probe(struct i2c_client *client,
 	struct iio_dev *indio_dev;
 	struct tsl2563_chip *chip;
 	struct tsl2563_platform_data *pdata = client->dev.platform_data;
-	struct device_node *np = client->dev.of_node;
 	int err = 0;
 	u8 id = 0;
 
@@ -738,13 +739,14 @@ static int tsl2563_probe(struct i2c_client *client,
 	chip->calib0 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS);
 	chip->calib1 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS);
 
-	if (pdata)
+	if (pdata) {
 		chip->cover_comp_gain = pdata->cover_comp_gain;
-	else if (np)
-		of_property_read_u32(np, "amstaos,cover-comp-gain",
-				     &chip->cover_comp_gain);
-	else
-		chip->cover_comp_gain = 1;
+	} else {
+		err = device_property_read_u32(&client->dev, "amstaos,cover-comp-gain",
+					       &chip->cover_comp_gain);
+		if (err)
+			chip->cover_comp_gain = 1;
+	}
 
 	dev_info(&client->dev, "model %d, rev. %d\n", id >> 4, id & 0x0f);
 	indio_dev->name = client->name;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4] iio:light:tsl2563 use generic fw accessors
  2020-10-18 20:35 [PATCH v4] iio:light:tsl2563 use generic fw accessors Vaishnav M A
@ 2020-11-01 15:29 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2020-11-01 15:29 UTC (permalink / raw)
  To: Vaishnav M A
  Cc: andy.shevchenko, wsa, knaack.h, lars, alexandru.ardelean,
	matt.ranostay, linux-iio, linux-kernel, jkridner, drew,
	robertcnelson, rajkovic

On Mon, 19 Oct 2020 02:05:52 +0530
Vaishnav M A <vaishnav@beagleboard.org> wrote:

> Replace of_property_read_u32() with device_property_read_u32(),
> when reading the amstaos,cover-comp-gain.This opens up the
> possibility of passing the properties during platform instantiation
> of the device by a suitable populated struct property_entry.
> Additionally, a minor change in logic is added to remove the
> of_node present check.
> 
> Signed-off-by: Vaishnav M A <vaishnav@beagleboard.org>
Dropped v3 and applied this.

If no one has replied to a previous version and you decide to respin
for whatever reason, please reply yourself to that earlier version
to say you have done so.

Thanks,

Jonathan

> ---
>  v4:
> 	-update commit message, fix punctuation.
> 	-update to a shorter commit title, used for similar changes
> 	 within the subsystem, like in 00fa493b9989
> 	 ("iio:proximity:as3935: Drop of_match_ptr and use generic fw accessors")
>  v3:
>         -modify commit message for readability, mention minor logic change
>         -include  mod_devicetable.h and property.h headers
>  v2:
>         -fix commit message
>  drivers/iio/light/tsl2563.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
> index abc8d7db8dc1..5bf2bfbc5379 100644
> --- a/drivers/iio/light/tsl2563.c
> +++ b/drivers/iio/light/tsl2563.c
> @@ -12,6 +12,8 @@
>   */
>  
>  #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/property.h>
>  #include <linux/i2c.h>
>  #include <linux/interrupt.h>
>  #include <linux/irq.h>
> @@ -703,7 +705,6 @@ static int tsl2563_probe(struct i2c_client *client,
>  	struct iio_dev *indio_dev;
>  	struct tsl2563_chip *chip;
>  	struct tsl2563_platform_data *pdata = client->dev.platform_data;
> -	struct device_node *np = client->dev.of_node;
>  	int err = 0;
>  	u8 id = 0;
>  
> @@ -738,13 +739,14 @@ static int tsl2563_probe(struct i2c_client *client,
>  	chip->calib0 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS);
>  	chip->calib1 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS);
>  
> -	if (pdata)
> +	if (pdata) {
>  		chip->cover_comp_gain = pdata->cover_comp_gain;
> -	else if (np)
> -		of_property_read_u32(np, "amstaos,cover-comp-gain",
> -				     &chip->cover_comp_gain);
> -	else
> -		chip->cover_comp_gain = 1;
> +	} else {
> +		err = device_property_read_u32(&client->dev, "amstaos,cover-comp-gain",
> +					       &chip->cover_comp_gain);
> +		if (err)
> +			chip->cover_comp_gain = 1;
> +	}
>  
>  	dev_info(&client->dev, "model %d, rev. %d\n", id >> 4, id & 0x0f);
>  	indio_dev->name = client->name;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-01 15:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-18 20:35 [PATCH v4] iio:light:tsl2563 use generic fw accessors Vaishnav M A
2020-11-01 15:29 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).