linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/3] iio: st_lsm6dsx: Mark predefined constants with __maybe_unused
@ 2019-12-16 18:19 Andy Shevchenko
  2019-12-16 18:19 ` [PATCH v1 2/3] iio: st_lsm6dsx: Drop unneeded OF code Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andy Shevchenko @ 2019-12-16 18:19 UTC (permalink / raw)
  To: Lorenzo Bianconi, Jonathan Cameron, linux-iio, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler
  Cc: Andy Shevchenko

Since we put static variable to a header file it's copied to each module
that includes the header. But not all of them are actually used it.

Mark predefined constants with __maybe_unused to calm a compiler down:

In file included from drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c:17:
.../st_lsm6dsx/st_lsm6dsx.h:399:28: warning: ‘st_lsm6dsx_available_scan_masks’ defined but not used [-Wunused-const-variable=]
  399 | static const unsigned long st_lsm6dsx_available_scan_masks[] = {0x7, 0x0};
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.../st_lsm6dsx/st_lsm6dsx.h:392:36: warning: ‘st_lsm6dsx_event’ defined but not used [-Wunused-const-variable=]
  392 | static const struct iio_event_spec st_lsm6dsx_event = {
      |                                    ^~~~~~~~~~~~~~~~
...

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index dc55d7dff3eb..b3fbbae81955 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -389,14 +389,17 @@ struct st_lsm6dsx_hw {
 	const struct st_lsm6dsx_settings *settings;
 };
 
-static const struct iio_event_spec st_lsm6dsx_event = {
+static __maybe_unused const struct iio_event_spec st_lsm6dsx_event = {
 	.type = IIO_EV_TYPE_THRESH,
 	.dir = IIO_EV_DIR_EITHER,
 	.mask_separate = BIT(IIO_EV_INFO_VALUE) |
 			 BIT(IIO_EV_INFO_ENABLE)
 };
 
-static const unsigned long st_lsm6dsx_available_scan_masks[] = {0x7, 0x0};
+static __maybe_unused const unsigned long st_lsm6dsx_available_scan_masks[] = {
+	0x7, 0x0,
+};
+
 extern const struct dev_pm_ops st_lsm6dsx_pm_ops;
 
 int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
-- 
2.24.0


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

* [PATCH v1 2/3] iio: st_lsm6dsx: Drop unneeded OF code
  2019-12-16 18:19 [PATCH v1 1/3] iio: st_lsm6dsx: Mark predefined constants with __maybe_unused Andy Shevchenko
@ 2019-12-16 18:19 ` Andy Shevchenko
  2019-12-23 16:11   ` Jonathan Cameron
  2019-12-16 18:19 ` [PATCH v1 3/3] iio: st_lsm6dsx: Make use of device properties Andy Shevchenko
  2019-12-23 16:10 ` [PATCH v1 1/3] iio: st_lsm6dsx: Mark predefined constants with __maybe_unused Jonathan Cameron
  2 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2019-12-16 18:19 UTC (permalink / raw)
  To: Lorenzo Bianconi, Jonathan Cameron, linux-iio, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler
  Cc: Andy Shevchenko

There is no need to have OF guard against ID table.
Drop it for good.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 3 +--
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
index cd47ec1fedcb..0fb32131afce 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
@@ -12,7 +12,6 @@
 #include <linux/module.h>
 #include <linux/i2c.h>
 #include <linux/slab.h>
-#include <linux/of.h>
 #include <linux/regmap.h>
 
 #include "st_lsm6dsx.h"
@@ -122,7 +121,7 @@ static struct i2c_driver st_lsm6dsx_driver = {
 	.driver = {
 		.name = "st_lsm6dsx_i2c",
 		.pm = &st_lsm6dsx_pm_ops,
-		.of_match_table = of_match_ptr(st_lsm6dsx_i2c_of_match),
+		.of_match_table = st_lsm6dsx_i2c_of_match,
 	},
 	.probe = st_lsm6dsx_i2c_probe,
 	.id_table = st_lsm6dsx_i2c_id_table,
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
index 67ff36eac247..eb1086e4a951 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
@@ -12,7 +12,6 @@
 #include <linux/module.h>
 #include <linux/spi/spi.h>
 #include <linux/slab.h>
-#include <linux/of.h>
 #include <linux/regmap.h>
 
 #include "st_lsm6dsx.h"
@@ -122,7 +121,7 @@ static struct spi_driver st_lsm6dsx_driver = {
 	.driver = {
 		.name = "st_lsm6dsx_spi",
 		.pm = &st_lsm6dsx_pm_ops,
-		.of_match_table = of_match_ptr(st_lsm6dsx_spi_of_match),
+		.of_match_table = st_lsm6dsx_spi_of_match,
 	},
 	.probe = st_lsm6dsx_spi_probe,
 	.id_table = st_lsm6dsx_spi_id_table,
-- 
2.24.0


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

* [PATCH v1 3/3] iio: st_lsm6dsx: Make use of device properties
  2019-12-16 18:19 [PATCH v1 1/3] iio: st_lsm6dsx: Mark predefined constants with __maybe_unused Andy Shevchenko
  2019-12-16 18:19 ` [PATCH v1 2/3] iio: st_lsm6dsx: Drop unneeded OF code Andy Shevchenko
@ 2019-12-16 18:19 ` Andy Shevchenko
  2019-12-23 16:14   ` Jonathan Cameron
  2019-12-23 16:10 ` [PATCH v1 1/3] iio: st_lsm6dsx: Mark predefined constants with __maybe_unused Jonathan Cameron
  2 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2019-12-16 18:19 UTC (permalink / raw)
  To: Lorenzo Bianconi, Jonathan Cameron, linux-iio, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald-Stadler
  Cc: Andy Shevchenko

Device property API allows to gather device resources from different sources,
such as ACPI. Convert the drivers to unleash the power of device property API.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 26 ++++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index a7d40c02ce6b..2b01155d1f32 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -54,6 +54,7 @@
 #include <linux/interrupt.h>
 #include <linux/irq.h>
 #include <linux/pm.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/bitfield.h>
 
@@ -1826,14 +1827,14 @@ static const struct iio_info st_lsm6dsx_gyro_info = {
 	.hwfifo_set_watermark = st_lsm6dsx_set_watermark,
 };
 
-static int st_lsm6dsx_of_get_drdy_pin(struct st_lsm6dsx_hw *hw, int *drdy_pin)
+static int st_lsm6dsx_get_drdy_pin(struct st_lsm6dsx_hw *hw, int *drdy_pin)
 {
-	struct device_node *np = hw->dev->of_node;
+	struct device *dev = hw->dev;
 
-	if (!np)
+	if (!dev_fwnode(dev))
 		return -EINVAL;
 
-	return of_property_read_u32(np, "st,drdy-int-pin", drdy_pin);
+	return device_property_read_u32(dev, "st,drdy-int-pin", drdy_pin);
 }
 
 static int
@@ -1842,7 +1843,7 @@ st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw,
 {
 	int err = 0, drdy_pin;
 
-	if (st_lsm6dsx_of_get_drdy_pin(hw, &drdy_pin) < 0) {
+	if (st_lsm6dsx_get_drdy_pin(hw, &drdy_pin) < 0) {
 		struct st_sensors_platform_data *pdata;
 		struct device *dev = hw->dev;
 
@@ -1871,15 +1872,15 @@ st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw,
 static int st_lsm6dsx_init_shub(struct st_lsm6dsx_hw *hw)
 {
 	const struct st_lsm6dsx_shub_settings *hub_settings;
-	struct device_node *np = hw->dev->of_node;
 	struct st_sensors_platform_data *pdata;
+	struct device *dev = hw->dev;
 	unsigned int data;
 	int err = 0;
 
 	hub_settings = &hw->settings->shub_settings;
 
-	pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
-	if ((np && of_property_read_bool(np, "st,pullups")) ||
+	pdata = (struct st_sensors_platform_data *)dev->platform_data;
+	if ((dev_fwnode(dev) && device_property_read_bool(dev, "st,pullups")) ||
 	    (pdata && pdata->pullups)) {
 		err = st_lsm6dsx_set_page(hw, true);
 		if (err < 0)
@@ -2157,9 +2158,9 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private)
 
 static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
 {
-	struct device_node *np = hw->dev->of_node;
 	struct st_sensors_platform_data *pdata;
 	const struct st_lsm6dsx_reg *reg;
+	struct device *dev = hw->dev;
 	unsigned long irq_type;
 	bool irq_active_low;
 	int err;
@@ -2187,8 +2188,8 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
 	if (err < 0)
 		return err;
 
-	pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
-	if ((np && of_property_read_bool(np, "drive-open-drain")) ||
+	pdata = (struct st_sensors_platform_data *)dev->platform_data;
+	if ((dev_fwnode(dev) && device_property_read_bool(dev, "drive-open-drain")) ||
 	    (pdata && pdata->open_drain)) {
 		reg = &hw->settings->irq_config.od;
 		err = regmap_update_bits(hw->regmap, reg->addr, reg->mask,
@@ -2218,7 +2219,6 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
 {
 	struct st_sensors_platform_data *pdata = dev->platform_data;
 	const struct st_lsm6dsx_shub_settings *hub_settings;
-	struct device_node *np = dev->of_node;
 	struct st_lsm6dsx_hw *hw;
 	const char *name = NULL;
 	int i, err;
@@ -2281,7 +2281,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
 			return err;
 	}
 
-	if ((np && of_property_read_bool(np, "wakeup-source")) ||
+	if ((dev_fwnode(dev) && device_property_read_bool(dev, "wakeup-source")) ||
 	    (pdata && pdata->wakeup_source))
 		device_init_wakeup(dev, true);
 
-- 
2.24.0


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

* Re: [PATCH v1 1/3] iio: st_lsm6dsx: Mark predefined constants with __maybe_unused
  2019-12-16 18:19 [PATCH v1 1/3] iio: st_lsm6dsx: Mark predefined constants with __maybe_unused Andy Shevchenko
  2019-12-16 18:19 ` [PATCH v1 2/3] iio: st_lsm6dsx: Drop unneeded OF code Andy Shevchenko
  2019-12-16 18:19 ` [PATCH v1 3/3] iio: st_lsm6dsx: Make use of device properties Andy Shevchenko
@ 2019-12-23 16:10 ` Jonathan Cameron
  2 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2019-12-23 16:10 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Lorenzo Bianconi, linux-iio, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler

On Mon, 16 Dec 2019 20:19:23 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Since we put static variable to a header file it's copied to each module
> that includes the header. But not all of them are actually used it.
> 
> Mark predefined constants with __maybe_unused to calm a compiler down:
> 
> In file included from drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c:17:
> .../st_lsm6dsx/st_lsm6dsx.h:399:28: warning: ‘st_lsm6dsx_available_scan_masks’ defined but not used [-Wunused-const-variable=]
>   399 | static const unsigned long st_lsm6dsx_available_scan_masks[] = {0x7, 0x0};
>       |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> .../st_lsm6dsx/st_lsm6dsx.h:392:36: warning: ‘st_lsm6dsx_event’ defined but not used [-Wunused-const-variable=]
>   392 | static const struct iio_event_spec st_lsm6dsx_event = {
>       |                                    ^~~~~~~~~~~~~~~~
> ...
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Huh, I wonder we I never saw this one either locally or from the autobuilders.

Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to have a fun Christmas poking at it ;)

Thanks,

Jonathan

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index dc55d7dff3eb..b3fbbae81955 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -389,14 +389,17 @@ struct st_lsm6dsx_hw {
>  	const struct st_lsm6dsx_settings *settings;
>  };
>  
> -static const struct iio_event_spec st_lsm6dsx_event = {
> +static __maybe_unused const struct iio_event_spec st_lsm6dsx_event = {
>  	.type = IIO_EV_TYPE_THRESH,
>  	.dir = IIO_EV_DIR_EITHER,
>  	.mask_separate = BIT(IIO_EV_INFO_VALUE) |
>  			 BIT(IIO_EV_INFO_ENABLE)
>  };
>  
> -static const unsigned long st_lsm6dsx_available_scan_masks[] = {0x7, 0x0};
> +static __maybe_unused const unsigned long st_lsm6dsx_available_scan_masks[] = {
> +	0x7, 0x0,
> +};
> +
>  extern const struct dev_pm_ops st_lsm6dsx_pm_ops;
>  
>  int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,


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

* Re: [PATCH v1 2/3] iio: st_lsm6dsx: Drop unneeded OF code
  2019-12-16 18:19 ` [PATCH v1 2/3] iio: st_lsm6dsx: Drop unneeded OF code Andy Shevchenko
@ 2019-12-23 16:11   ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2019-12-23 16:11 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Lorenzo Bianconi, linux-iio, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler

On Mon, 16 Dec 2019 20:19:24 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> There is no need to have OF guard against ID table.
> Drop it for good.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Agreed. Good to slowly push out this bit of legacy...

Applied to the togreg branch of iio.git and pushed out as testing.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c | 3 +--
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c | 3 +--
>  2 files changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> index cd47ec1fedcb..0fb32131afce 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> @@ -12,7 +12,6 @@
>  #include <linux/module.h>
>  #include <linux/i2c.h>
>  #include <linux/slab.h>
> -#include <linux/of.h>
>  #include <linux/regmap.h>
>  
>  #include "st_lsm6dsx.h"
> @@ -122,7 +121,7 @@ static struct i2c_driver st_lsm6dsx_driver = {
>  	.driver = {
>  		.name = "st_lsm6dsx_i2c",
>  		.pm = &st_lsm6dsx_pm_ops,
> -		.of_match_table = of_match_ptr(st_lsm6dsx_i2c_of_match),
> +		.of_match_table = st_lsm6dsx_i2c_of_match,
>  	},
>  	.probe = st_lsm6dsx_i2c_probe,
>  	.id_table = st_lsm6dsx_i2c_id_table,
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> index 67ff36eac247..eb1086e4a951 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> @@ -12,7 +12,6 @@
>  #include <linux/module.h>
>  #include <linux/spi/spi.h>
>  #include <linux/slab.h>
> -#include <linux/of.h>
>  #include <linux/regmap.h>
>  
>  #include "st_lsm6dsx.h"
> @@ -122,7 +121,7 @@ static struct spi_driver st_lsm6dsx_driver = {
>  	.driver = {
>  		.name = "st_lsm6dsx_spi",
>  		.pm = &st_lsm6dsx_pm_ops,
> -		.of_match_table = of_match_ptr(st_lsm6dsx_spi_of_match),
> +		.of_match_table = st_lsm6dsx_spi_of_match,
>  	},
>  	.probe = st_lsm6dsx_spi_probe,
>  	.id_table = st_lsm6dsx_spi_id_table,


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

* Re: [PATCH v1 3/3] iio: st_lsm6dsx: Make use of device properties
  2019-12-16 18:19 ` [PATCH v1 3/3] iio: st_lsm6dsx: Make use of device properties Andy Shevchenko
@ 2019-12-23 16:14   ` Jonathan Cameron
  0 siblings, 0 replies; 6+ messages in thread
From: Jonathan Cameron @ 2019-12-23 16:14 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Lorenzo Bianconi, linux-iio, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler

On Mon, 16 Dec 2019 20:19:25 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Device property API allows to gather device resources from different sources,
> such as ACPI. Convert the drivers to unleash the power of device property API.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Looks good to me.  I'd ideally like Lorenzo of someone else to give it
a sanity check.  However, I confident enough to add it to the branch
that gets pushed out for build tests in the meantime.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 26 ++++++++++----------
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index a7d40c02ce6b..2b01155d1f32 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -54,6 +54,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/irq.h>
>  #include <linux/pm.h>
> +#include <linux/property.h>
>  #include <linux/regmap.h>
>  #include <linux/bitfield.h>
>  
> @@ -1826,14 +1827,14 @@ static const struct iio_info st_lsm6dsx_gyro_info = {
>  	.hwfifo_set_watermark = st_lsm6dsx_set_watermark,
>  };
>  
> -static int st_lsm6dsx_of_get_drdy_pin(struct st_lsm6dsx_hw *hw, int *drdy_pin)
> +static int st_lsm6dsx_get_drdy_pin(struct st_lsm6dsx_hw *hw, int *drdy_pin)
>  {
> -	struct device_node *np = hw->dev->of_node;
> +	struct device *dev = hw->dev;
>  
> -	if (!np)
> +	if (!dev_fwnode(dev))
>  		return -EINVAL;
>  
> -	return of_property_read_u32(np, "st,drdy-int-pin", drdy_pin);
> +	return device_property_read_u32(dev, "st,drdy-int-pin", drdy_pin);
>  }
>  
>  static int
> @@ -1842,7 +1843,7 @@ st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw,
>  {
>  	int err = 0, drdy_pin;
>  
> -	if (st_lsm6dsx_of_get_drdy_pin(hw, &drdy_pin) < 0) {
> +	if (st_lsm6dsx_get_drdy_pin(hw, &drdy_pin) < 0) {
>  		struct st_sensors_platform_data *pdata;
>  		struct device *dev = hw->dev;
>  
> @@ -1871,15 +1872,15 @@ st_lsm6dsx_get_drdy_reg(struct st_lsm6dsx_hw *hw,
>  static int st_lsm6dsx_init_shub(struct st_lsm6dsx_hw *hw)
>  {
>  	const struct st_lsm6dsx_shub_settings *hub_settings;
> -	struct device_node *np = hw->dev->of_node;
>  	struct st_sensors_platform_data *pdata;
> +	struct device *dev = hw->dev;
>  	unsigned int data;
>  	int err = 0;
>  
>  	hub_settings = &hw->settings->shub_settings;
>  
> -	pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
> -	if ((np && of_property_read_bool(np, "st,pullups")) ||
> +	pdata = (struct st_sensors_platform_data *)dev->platform_data;
> +	if ((dev_fwnode(dev) && device_property_read_bool(dev, "st,pullups")) ||
>  	    (pdata && pdata->pullups)) {
>  		err = st_lsm6dsx_set_page(hw, true);
>  		if (err < 0)
> @@ -2157,9 +2158,9 @@ static irqreturn_t st_lsm6dsx_handler_thread(int irq, void *private)
>  
>  static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
>  {
> -	struct device_node *np = hw->dev->of_node;
>  	struct st_sensors_platform_data *pdata;
>  	const struct st_lsm6dsx_reg *reg;
> +	struct device *dev = hw->dev;
>  	unsigned long irq_type;
>  	bool irq_active_low;
>  	int err;
> @@ -2187,8 +2188,8 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
>  	if (err < 0)
>  		return err;
>  
> -	pdata = (struct st_sensors_platform_data *)hw->dev->platform_data;
> -	if ((np && of_property_read_bool(np, "drive-open-drain")) ||
> +	pdata = (struct st_sensors_platform_data *)dev->platform_data;
> +	if ((dev_fwnode(dev) && device_property_read_bool(dev, "drive-open-drain")) ||
>  	    (pdata && pdata->open_drain)) {
>  		reg = &hw->settings->irq_config.od;
>  		err = regmap_update_bits(hw->regmap, reg->addr, reg->mask,
> @@ -2218,7 +2219,6 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
>  {
>  	struct st_sensors_platform_data *pdata = dev->platform_data;
>  	const struct st_lsm6dsx_shub_settings *hub_settings;
> -	struct device_node *np = dev->of_node;
>  	struct st_lsm6dsx_hw *hw;
>  	const char *name = NULL;
>  	int i, err;
> @@ -2281,7 +2281,7 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
>  			return err;
>  	}
>  
> -	if ((np && of_property_read_bool(np, "wakeup-source")) ||
> +	if ((dev_fwnode(dev) && device_property_read_bool(dev, "wakeup-source")) ||
>  	    (pdata && pdata->wakeup_source))
>  		device_init_wakeup(dev, true);
>  


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

end of thread, other threads:[~2019-12-23 16:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-16 18:19 [PATCH v1 1/3] iio: st_lsm6dsx: Mark predefined constants with __maybe_unused Andy Shevchenko
2019-12-16 18:19 ` [PATCH v1 2/3] iio: st_lsm6dsx: Drop unneeded OF code Andy Shevchenko
2019-12-23 16:11   ` Jonathan Cameron
2019-12-16 18:19 ` [PATCH v1 3/3] iio: st_lsm6dsx: Make use of device properties Andy Shevchenko
2019-12-23 16:14   ` Jonathan Cameron
2019-12-23 16:10 ` [PATCH v1 1/3] iio: st_lsm6dsx: Mark predefined constants with __maybe_unused 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).