diff mbox series

[10/13] iio: imu: st_lsm6dsx: add wakeup_source in st_sensors_platform_data

Message ID a237c2406825ff16c5606344420fd566b08525f9.1570367532.git.lorenzo@kernel.org (mailing list archive)
State New, archived
Headers show
Series various st_lsm6dsx fixes and missing bits | expand

Commit Message

Lorenzo Bianconi Oct. 6, 2019, 1:22 p.m. UTC
Add the possibility to enable/disable wakeup source through
st_sensors_platform_data and not only through device tree

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c   | 6 ++++--
 include/linux/platform_data/st_sensors_pdata.h | 2 ++
 2 files changed, 6 insertions(+), 2 deletions(-)

Comments

Jonathan Cameron Oct. 12, 2019, 12:25 p.m. UTC | #1
On Sun,  6 Oct 2019 15:22:04 +0200
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> Add the possibility to enable/disable wakeup source through
> st_sensors_platform_data and not only through device tree
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
I'm going to assume you need this for something... In general
I'm not that keen on expanding platform data support.

Applied,

Thanks,

Jonathan

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c   | 6 ++++--
>  include/linux/platform_data/st_sensors_pdata.h | 2 ++
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index b0623b837abd..a2a0ac81e3d3 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -2089,7 +2089,9 @@ static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
>  int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
>  		     struct regmap *regmap)
>  {
> +	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;
> @@ -2152,8 +2154,8 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
>  			return err;
>  	}
>  
> -	if (dev->of_node &&
> -	    of_property_read_bool(dev->of_node, "wakeup-source"))
> +	if ((np && of_property_read_bool(np, "wakeup-source")) ||
> +	    (pdata && pdata->wakeup_source))
>  		device_init_wakeup(dev, true);
>  
>  	return 0;
> diff --git a/include/linux/platform_data/st_sensors_pdata.h b/include/linux/platform_data/st_sensors_pdata.h
> index 30929c22227d..e40b28ca892e 100644
> --- a/include/linux/platform_data/st_sensors_pdata.h
> +++ b/include/linux/platform_data/st_sensors_pdata.h
> @@ -18,12 +18,14 @@
>   * @open_drain: set the interrupt line to be open drain if possible.
>   * @spi_3wire: enable spi-3wire mode.
>   * @pullups: enable/disable i2c controller pullup resistors.
> + * @wakeup_source: enable/disable device as wakeup generator.
>   */
>  struct st_sensors_platform_data {
>  	u8 drdy_int_pin;
>  	bool open_drain;
>  	bool spi_3wire;
>  	bool pullups;
> +	bool wakeup_source;
>  };
>  
>  #endif /* ST_SENSORS_PDATA_H */
diff mbox series

Patch

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index b0623b837abd..a2a0ac81e3d3 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -2089,7 +2089,9 @@  static int st_lsm6dsx_irq_setup(struct st_lsm6dsx_hw *hw)
 int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
 		     struct regmap *regmap)
 {
+	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;
@@ -2152,8 +2154,8 @@  int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id,
 			return err;
 	}
 
-	if (dev->of_node &&
-	    of_property_read_bool(dev->of_node, "wakeup-source"))
+	if ((np && of_property_read_bool(np, "wakeup-source")) ||
+	    (pdata && pdata->wakeup_source))
 		device_init_wakeup(dev, true);
 
 	return 0;
diff --git a/include/linux/platform_data/st_sensors_pdata.h b/include/linux/platform_data/st_sensors_pdata.h
index 30929c22227d..e40b28ca892e 100644
--- a/include/linux/platform_data/st_sensors_pdata.h
+++ b/include/linux/platform_data/st_sensors_pdata.h
@@ -18,12 +18,14 @@ 
  * @open_drain: set the interrupt line to be open drain if possible.
  * @spi_3wire: enable spi-3wire mode.
  * @pullups: enable/disable i2c controller pullup resistors.
+ * @wakeup_source: enable/disable device as wakeup generator.
  */
 struct st_sensors_platform_data {
 	u8 drdy_int_pin;
 	bool open_drain;
 	bool spi_3wire;
 	bool pullups;
+	bool wakeup_source;
 };
 
 #endif /* ST_SENSORS_PDATA_H */