All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] add power management support to st_lsm6dsx driver
@ 2017-04-21 18:22 Lorenzo Bianconi
  2017-04-21 18:22 ` [PATCH 1/2] iio: imu: st_lsm6dsx: export st_lsm6dsx_flush_fifo() and st_lsm6dsx_set_fifo_mode() routines Lorenzo Bianconi
  2017-04-21 18:22 ` [PATCH 2/2] iio: imu: st_lsm6dsx: add system sleep power management support Lorenzo Bianconi
  0 siblings, 2 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2017-04-21 18:22 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, lorenzo.bianconi

Lorenzo Bianconi (2):
  iio: imu: st_lsm6dsx: export st_lsm6dsx_flush_fifo() and
    st_lsm6dsx_set_fifo_mode() routines
  iio: imu: st_lsm6dsx: add system sleep power management support

 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h        |  5 +++
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c |  6 +--
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c   | 54 ++++++++++++++++++++++++++
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c    |  1 +
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c    |  1 +
 5 files changed, 64 insertions(+), 3 deletions(-)

-- 
2.9.3


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

* [PATCH 1/2] iio: imu: st_lsm6dsx: export st_lsm6dsx_flush_fifo() and st_lsm6dsx_set_fifo_mode() routines
  2017-04-21 18:22 [PATCH 0/2] add power management support to st_lsm6dsx driver Lorenzo Bianconi
@ 2017-04-21 18:22 ` Lorenzo Bianconi
  2017-04-26  5:54   ` Jonathan Cameron
  2017-04-21 18:22 ` [PATCH 2/2] iio: imu: st_lsm6dsx: add system sleep power management support Lorenzo Bianconi
  1 sibling, 1 reply; 8+ messages in thread
From: Lorenzo Bianconi @ 2017-04-21 18:22 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, lorenzo.bianconi

Remove static qualifier from st_lsm6dsx_flush_fifo() and
st_lsm6dsx_set_fifo_mode() in order to use them in system sleep pm support

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h        | 3 +++
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index 4839db7..7778520 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -144,5 +144,8 @@ int st_lsm6dsx_write_with_mask(struct st_lsm6dsx_hw *hw, u8 addr, u8 mask,
 			       u8 val);
 int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor,
 				u16 watermark);
+int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw);
+int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
+			     enum st_lsm6dsx_fifo_mode fifo_mode);
 
 #endif /* ST_LSM6DSX_H */
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
index c8e5cfd..b19a62d 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
@@ -130,8 +130,8 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw)
 	return 0;
 }
 
-static int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
-				    enum st_lsm6dsx_fifo_mode fifo_mode)
+int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
+			     enum st_lsm6dsx_fifo_mode fifo_mode)
 {
 	u8 data;
 	int err;
@@ -303,7 +303,7 @@ static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
 	return read_len;
 }
 
-static int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw)
+int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw)
 {
 	int err;
 
-- 
2.9.3


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

* [PATCH 2/2] iio: imu: st_lsm6dsx: add system sleep power management support
  2017-04-21 18:22 [PATCH 0/2] add power management support to st_lsm6dsx driver Lorenzo Bianconi
  2017-04-21 18:22 ` [PATCH 1/2] iio: imu: st_lsm6dsx: export st_lsm6dsx_flush_fifo() and st_lsm6dsx_set_fifo_mode() routines Lorenzo Bianconi
@ 2017-04-21 18:22 ` Lorenzo Bianconi
  2017-04-21 18:33   ` Lars-Peter Clausen
  2017-04-26  5:56   ` Jonathan Cameron
  1 sibling, 2 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2017-04-21 18:22 UTC (permalink / raw)
  To: jic23; +Cc: linux-iio, lorenzo.bianconi

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
---
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  2 ++
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 54 ++++++++++++++++++++++++++++
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c  |  1 +
 drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c  |  1 +
 4 files changed, 58 insertions(+)

diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
index 7778520..46352c7 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
@@ -135,6 +135,8 @@ struct st_lsm6dsx_hw {
 #endif /* CONFIG_SPI_MASTER */
 };
 
+extern const struct dev_pm_ops st_lsm6dsx_pm_ops;
+
 int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
 		     const struct st_lsm6dsx_transfer_function *tf_ops);
 int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor);
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
index 462a27b..1b53848 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
@@ -36,6 +36,7 @@
 #include <linux/delay.h>
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
+#include <linux/pm.h>
 
 #include <linux/platform_data/st_sensors_pdata.h>
 
@@ -731,6 +732,59 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
 }
 EXPORT_SYMBOL(st_lsm6dsx_probe);
 
+#ifdef CONFIG_PM
+static int st_lsm6dsx_suspend(struct device *dev)
+{
+	struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
+	struct st_lsm6dsx_sensor *sensor;
+	int i, err = 0;
+
+	for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
+		sensor = iio_priv(hw->iio_devs[i]);
+		if (!(hw->enable_mask & BIT(sensor->id)))
+			continue;
+
+		err = st_lsm6dsx_write_with_mask(hw,
+				st_lsm6dsx_odr_table[sensor->id].reg.addr,
+				st_lsm6dsx_odr_table[sensor->id].reg.mask, 0);
+		if (err < 0)
+			return err;
+	}
+
+	if (hw->fifo_mode != ST_LSM6DSX_FIFO_BYPASS)
+		err = st_lsm6dsx_flush_fifo(hw);
+
+	return err;
+}
+
+static int st_lsm6dsx_resume(struct device *dev)
+{
+	struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
+	struct st_lsm6dsx_sensor *sensor;
+	int i, err = 0;
+
+	for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
+		sensor = iio_priv(hw->iio_devs[i]);
+		if (!(hw->enable_mask & BIT(sensor->id)))
+			continue;
+
+		err = st_lsm6dsx_set_odr(sensor, sensor->odr);
+		if (err < 0)
+			return err;
+	}
+
+	if (hw->enable_mask)
+		err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT);
+
+	return err;
+}
+#endif /* CONFIG_PM */
+
+const struct dev_pm_ops st_lsm6dsx_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(st_lsm6dsx_suspend, st_lsm6dsx_resume)
+};
+EXPORT_SYMBOL(st_lsm6dsx_pm_ops);
+
 MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
 MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
 MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx driver");
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
index 09a51cf..305fec7 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
@@ -98,6 +98,7 @@ MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table);
 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),
 	},
 	.probe = st_lsm6dsx_i2c_probe,
diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
index f765a50..95472f1 100644
--- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
+++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
@@ -115,6 +115,7 @@ MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table);
 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),
 	},
 	.probe = st_lsm6dsx_spi_probe,
-- 
2.9.3


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

* Re: [PATCH 2/2] iio: imu: st_lsm6dsx: add system sleep power management support
  2017-04-21 18:22 ` [PATCH 2/2] iio: imu: st_lsm6dsx: add system sleep power management support Lorenzo Bianconi
@ 2017-04-21 18:33   ` Lars-Peter Clausen
  2017-04-21 18:46     ` Lorenzo Bianconi
  2017-04-26  5:56   ` Jonathan Cameron
  1 sibling, 1 reply; 8+ messages in thread
From: Lars-Peter Clausen @ 2017-04-21 18:33 UTC (permalink / raw)
  To: Lorenzo Bianconi, jic23; +Cc: linux-iio, lorenzo.bianconi

On 04/21/2017 08:22 PM, Lorenzo Bianconi wrote:
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>

Hi,

Please consider writing a commit message
(https://chris.beams.io/posts/git-commit/).

> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  2 ++
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 54 ++++++++++++++++++++++++++++
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c  |  1 +
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c  |  1 +
>  4 files changed, 58 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 7778520..46352c7 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -135,6 +135,8 @@ struct st_lsm6dsx_hw {
>  #endif /* CONFIG_SPI_MASTER */
>  };
>  
> +extern const struct dev_pm_ops st_lsm6dsx_pm_ops;
> +
>  int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
>  		     const struct st_lsm6dsx_transfer_function *tf_ops);
>  int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor);
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 462a27b..1b53848 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -36,6 +36,7 @@
>  #include <linux/delay.h>
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> +#include <linux/pm.h>
>  
>  #include <linux/platform_data/st_sensors_pdata.h>
>  
> @@ -731,6 +732,59 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
>  }
>  EXPORT_SYMBOL(st_lsm6dsx_probe);
>  
> +#ifdef CONFIG_PM
> +static int st_lsm6dsx_suspend(struct device *dev)
> +{
> +	struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
> +	struct st_lsm6dsx_sensor *sensor;
> +	int i, err = 0;
> +
> +	for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
> +		sensor = iio_priv(hw->iio_devs[i]);
> +		if (!(hw->enable_mask & BIT(sensor->id)))
> +			continue;
> +
> +		err = st_lsm6dsx_write_with_mask(hw,
> +				st_lsm6dsx_odr_table[sensor->id].reg.addr,
> +				st_lsm6dsx_odr_table[sensor->id].reg.mask, 0);
> +		if (err < 0)
> +			return err;
> +	}
> +
> +	if (hw->fifo_mode != ST_LSM6DSX_FIFO_BYPASS)
> +		err = st_lsm6dsx_flush_fifo(hw);
> +
> +	return err;
> +}
> +
> +static int st_lsm6dsx_resume(struct device *dev)
> +{
> +	struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
> +	struct st_lsm6dsx_sensor *sensor;
> +	int i, err = 0;
> +
> +	for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
> +		sensor = iio_priv(hw->iio_devs[i]);
> +		if (!(hw->enable_mask & BIT(sensor->id)))
> +			continue;
> +
> +		err = st_lsm6dsx_set_odr(sensor, sensor->odr);
> +		if (err < 0)
> +			return err;
> +	}
> +
> +	if (hw->enable_mask)
> +		err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT);
> +
> +	return err;
> +}
> +#endif /* CONFIG_PM */
> +
> +const struct dev_pm_ops st_lsm6dsx_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(st_lsm6dsx_suspend, st_lsm6dsx_resume)
> +};
> +EXPORT_SYMBOL(st_lsm6dsx_pm_ops);
> +
>  MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
>  MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
>  MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx driver");
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> index 09a51cf..305fec7 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> @@ -98,6 +98,7 @@ MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table);
>  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),
>  	},
>  	.probe = st_lsm6dsx_i2c_probe,
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> index f765a50..95472f1 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> @@ -115,6 +115,7 @@ MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table);
>  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),
>  	},
>  	.probe = st_lsm6dsx_spi_probe,
> 


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

* Re: [PATCH 2/2] iio: imu: st_lsm6dsx: add system sleep power management support
  2017-04-21 18:33   ` Lars-Peter Clausen
@ 2017-04-21 18:46     ` Lorenzo Bianconi
  0 siblings, 0 replies; 8+ messages in thread
From: Lorenzo Bianconi @ 2017-04-21 18:46 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio, Lorenzo BIANCONI

> On 04/21/2017 08:22 PM, Lorenzo Bianconi wrote:
>> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
>
> Hi,

Hi Lars,

>
> Please consider writing a commit message
> (https://chris.beams.io/posts/git-commit/).
>

Ack, I will do in v2. Meanwhile I will wait for more comments.

Regards,
Lorenzo

>> ---
>>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  2 ++
>>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 54 ++++++++++++++++++++++++++++
>>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c  |  1 +
>>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c  |  1 +
>>  4 files changed, 58 insertions(+)
>>
>> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
>> index 7778520..46352c7 100644
>> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
>> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
>> @@ -135,6 +135,8 @@ struct st_lsm6dsx_hw {
>>  #endif /* CONFIG_SPI_MASTER */
>>  };
>>
>> +extern const struct dev_pm_ops st_lsm6dsx_pm_ops;
>> +
>>  int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
>>                    const struct st_lsm6dsx_transfer_function *tf_ops);
>>  int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor);
>> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
>> index 462a27b..1b53848 100644
>> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
>> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
>> @@ -36,6 +36,7 @@
>>  #include <linux/delay.h>
>>  #include <linux/iio/iio.h>
>>  #include <linux/iio/sysfs.h>
>> +#include <linux/pm.h>
>>
>>  #include <linux/platform_data/st_sensors_pdata.h>
>>
>> @@ -731,6 +732,59 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
>>  }
>>  EXPORT_SYMBOL(st_lsm6dsx_probe);
>>
>> +#ifdef CONFIG_PM
>> +static int st_lsm6dsx_suspend(struct device *dev)
>> +{
>> +     struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
>> +     struct st_lsm6dsx_sensor *sensor;
>> +     int i, err = 0;
>> +
>> +     for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
>> +             sensor = iio_priv(hw->iio_devs[i]);
>> +             if (!(hw->enable_mask & BIT(sensor->id)))
>> +                     continue;
>> +
>> +             err = st_lsm6dsx_write_with_mask(hw,
>> +                             st_lsm6dsx_odr_table[sensor->id].reg.addr,
>> +                             st_lsm6dsx_odr_table[sensor->id].reg.mask, 0);
>> +             if (err < 0)
>> +                     return err;
>> +     }
>> +
>> +     if (hw->fifo_mode != ST_LSM6DSX_FIFO_BYPASS)
>> +             err = st_lsm6dsx_flush_fifo(hw);
>> +
>> +     return err;
>> +}
>> +
>> +static int st_lsm6dsx_resume(struct device *dev)
>> +{
>> +     struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
>> +     struct st_lsm6dsx_sensor *sensor;
>> +     int i, err = 0;
>> +
>> +     for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
>> +             sensor = iio_priv(hw->iio_devs[i]);
>> +             if (!(hw->enable_mask & BIT(sensor->id)))
>> +                     continue;
>> +
>> +             err = st_lsm6dsx_set_odr(sensor, sensor->odr);
>> +             if (err < 0)
>> +                     return err;
>> +     }
>> +
>> +     if (hw->enable_mask)
>> +             err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT);
>> +
>> +     return err;
>> +}
>> +#endif /* CONFIG_PM */
>> +
>> +const struct dev_pm_ops st_lsm6dsx_pm_ops = {
>> +     SET_SYSTEM_SLEEP_PM_OPS(st_lsm6dsx_suspend, st_lsm6dsx_resume)
>> +};
>> +EXPORT_SYMBOL(st_lsm6dsx_pm_ops);
>> +
>>  MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
>>  MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
>>  MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx driver");
>> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
>> index 09a51cf..305fec7 100644
>> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
>> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
>> @@ -98,6 +98,7 @@ MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table);
>>  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),
>>       },
>>       .probe = st_lsm6dsx_i2c_probe,
>> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
>> index f765a50..95472f1 100644
>> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
>> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
>> @@ -115,6 +115,7 @@ MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table);
>>  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),
>>       },
>>       .probe = st_lsm6dsx_spi_probe,
>>
>



-- 
UNIX is Sexy: who | grep -i blonde | talk; cd ~; wine; talk; touch;
unzip; touch; strip; gasp; finger; gasp; mount; fsck; more; yes; gasp;
umount; make clean; sleep

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

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: export st_lsm6dsx_flush_fifo() and st_lsm6dsx_set_fifo_mode() routines
  2017-04-21 18:22 ` [PATCH 1/2] iio: imu: st_lsm6dsx: export st_lsm6dsx_flush_fifo() and st_lsm6dsx_set_fifo_mode() routines Lorenzo Bianconi
@ 2017-04-26  5:54   ` Jonathan Cameron
  2017-04-26  7:13     ` Lorenzo BIANCONI
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Cameron @ 2017-04-26  5:54 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-iio, lorenzo.bianconi

On 21/04/17 19:22, Lorenzo Bianconi wrote:
> Remove static qualifier from st_lsm6dsx_flush_fifo() and
> st_lsm6dsx_set_fifo_mode() in order to use them in system sleep pm support
Export kind of implies exporting the symbols when referring to kernel code.
Here you are just making them available to other parts of the same driver.
Perhaps reword the patch title.

Jonathan
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h        | 3 +++
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 6 +++---
>  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 4839db7..7778520 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -144,5 +144,8 @@ int st_lsm6dsx_write_with_mask(struct st_lsm6dsx_hw *hw, u8 addr, u8 mask,
>  			       u8 val);
>  int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor,
>  				u16 watermark);
> +int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw);
> +int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
> +			     enum st_lsm6dsx_fifo_mode fifo_mode);
>  
>  #endif /* ST_LSM6DSX_H */
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> index c8e5cfd..b19a62d 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> @@ -130,8 +130,8 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw)
>  	return 0;
>  }
>  
> -static int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
> -				    enum st_lsm6dsx_fifo_mode fifo_mode)
> +int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
> +			     enum st_lsm6dsx_fifo_mode fifo_mode)
>  {
>  	u8 data;
>  	int err;
> @@ -303,7 +303,7 @@ static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
>  	return read_len;
>  }
>  
> -static int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw)
> +int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw)
>  {
>  	int err;
>  
> 


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

* Re: [PATCH 2/2] iio: imu: st_lsm6dsx: add system sleep power management support
  2017-04-21 18:22 ` [PATCH 2/2] iio: imu: st_lsm6dsx: add system sleep power management support Lorenzo Bianconi
  2017-04-21 18:33   ` Lars-Peter Clausen
@ 2017-04-26  5:56   ` Jonathan Cameron
  1 sibling, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2017-04-26  5:56 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: linux-iio, lorenzo.bianconi

On 21/04/17 19:22, Lorenzo Bianconi wrote:
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Looks good to me.

Jonathan
> ---
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h      |  2 ++
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c | 54 ++++++++++++++++++++++++++++
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c  |  1 +
>  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c  |  1 +
>  4 files changed, 58 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> index 7778520..46352c7 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> @@ -135,6 +135,8 @@ struct st_lsm6dsx_hw {
>  #endif /* CONFIG_SPI_MASTER */
>  };
>  
> +extern const struct dev_pm_ops st_lsm6dsx_pm_ops;
> +
>  int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
>  		     const struct st_lsm6dsx_transfer_function *tf_ops);
>  int st_lsm6dsx_sensor_enable(struct st_lsm6dsx_sensor *sensor);
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> index 462a27b..1b53848 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
> @@ -36,6 +36,7 @@
>  #include <linux/delay.h>
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> +#include <linux/pm.h>
>  
>  #include <linux/platform_data/st_sensors_pdata.h>
>  
> @@ -731,6 +732,59 @@ int st_lsm6dsx_probe(struct device *dev, int irq, int hw_id, const char *name,
>  }
>  EXPORT_SYMBOL(st_lsm6dsx_probe);
>  
> +#ifdef CONFIG_PM
> +static int st_lsm6dsx_suspend(struct device *dev)
> +{
> +	struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
> +	struct st_lsm6dsx_sensor *sensor;
> +	int i, err = 0;
> +
> +	for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
> +		sensor = iio_priv(hw->iio_devs[i]);
> +		if (!(hw->enable_mask & BIT(sensor->id)))
> +			continue;
> +
> +		err = st_lsm6dsx_write_with_mask(hw,
> +				st_lsm6dsx_odr_table[sensor->id].reg.addr,
> +				st_lsm6dsx_odr_table[sensor->id].reg.mask, 0);
> +		if (err < 0)
> +			return err;
> +	}
> +
> +	if (hw->fifo_mode != ST_LSM6DSX_FIFO_BYPASS)
> +		err = st_lsm6dsx_flush_fifo(hw);
> +
> +	return err;
> +}
> +
> +static int st_lsm6dsx_resume(struct device *dev)
> +{
> +	struct st_lsm6dsx_hw *hw = dev_get_drvdata(dev);
> +	struct st_lsm6dsx_sensor *sensor;
> +	int i, err = 0;
> +
> +	for (i = 0; i < ST_LSM6DSX_ID_MAX; i++) {
> +		sensor = iio_priv(hw->iio_devs[i]);
> +		if (!(hw->enable_mask & BIT(sensor->id)))
> +			continue;
> +
> +		err = st_lsm6dsx_set_odr(sensor, sensor->odr);
> +		if (err < 0)
> +			return err;
> +	}
> +
> +	if (hw->enable_mask)
> +		err = st_lsm6dsx_set_fifo_mode(hw, ST_LSM6DSX_FIFO_CONT);
> +
> +	return err;
> +}
> +#endif /* CONFIG_PM */
> +
> +const struct dev_pm_ops st_lsm6dsx_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(st_lsm6dsx_suspend, st_lsm6dsx_resume)
> +};
> +EXPORT_SYMBOL(st_lsm6dsx_pm_ops);
> +
>  MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi@st.com>");
>  MODULE_AUTHOR("Denis Ciocca <denis.ciocca@st.com>");
>  MODULE_DESCRIPTION("STMicroelectronics st_lsm6dsx driver");
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> index 09a51cf..305fec7 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i2c.c
> @@ -98,6 +98,7 @@ MODULE_DEVICE_TABLE(i2c, st_lsm6dsx_i2c_id_table);
>  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),
>  	},
>  	.probe = st_lsm6dsx_i2c_probe,
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> index f765a50..95472f1 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_spi.c
> @@ -115,6 +115,7 @@ MODULE_DEVICE_TABLE(spi, st_lsm6dsx_spi_id_table);
>  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),
>  	},
>  	.probe = st_lsm6dsx_spi_probe,
> 


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

* Re: [PATCH 1/2] iio: imu: st_lsm6dsx: export st_lsm6dsx_flush_fifo() and st_lsm6dsx_set_fifo_mode() routines
  2017-04-26  5:54   ` Jonathan Cameron
@ 2017-04-26  7:13     ` Lorenzo BIANCONI
  0 siblings, 0 replies; 8+ messages in thread
From: Lorenzo BIANCONI @ 2017-04-26  7:13 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Lorenzo Bianconi, linux-iio

On Apr 26, Jonathan Cameron wrote:
> On 21/04/17 19:22, Lorenzo Bianconi wrote:
> > Remove static qualifier from st_lsm6dsx_flush_fifo() and
> > st_lsm6dsx_set_fifo_mode() in order to use them in system sleep pm support
> Export kind of implies exporting the symbols when referring to kernel code.
> Here you are just making them available to other parts of the same driver.
> Perhaps reword the patch title.

Ack, will do in v2.
Thx,
Lorenzo

> 
> Jonathan
> > 
> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
> > ---
> >  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h        | 3 +++
> >  drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c | 6 +++---
> >  2 files changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > index 4839db7..7778520 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
> > @@ -144,5 +144,8 @@ int st_lsm6dsx_write_with_mask(struct st_lsm6dsx_hw *hw, u8 addr, u8 mask,
> >  			       u8 val);
> >  int st_lsm6dsx_update_watermark(struct st_lsm6dsx_sensor *sensor,
> >  				u16 watermark);
> > +int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw);
> > +int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
> > +			     enum st_lsm6dsx_fifo_mode fifo_mode);
> >  
> >  #endif /* ST_LSM6DSX_H */
> > diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> > index c8e5cfd..b19a62d 100644
> > --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> > +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
> > @@ -130,8 +130,8 @@ static int st_lsm6dsx_update_decimators(struct st_lsm6dsx_hw *hw)
> >  	return 0;
> >  }
> >  
> > -static int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
> > -				    enum st_lsm6dsx_fifo_mode fifo_mode)
> > +int st_lsm6dsx_set_fifo_mode(struct st_lsm6dsx_hw *hw,
> > +			     enum st_lsm6dsx_fifo_mode fifo_mode)
> >  {
> >  	u8 data;
> >  	int err;
> > @@ -303,7 +303,7 @@ static int st_lsm6dsx_read_fifo(struct st_lsm6dsx_hw *hw)
> >  	return read_len;
> >  }
> >  
> > -static int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw)
> > +int st_lsm6dsx_flush_fifo(struct st_lsm6dsx_hw *hw)
> >  {
> >  	int err;
> >  
> > 
> 

-- 

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

end of thread, other threads:[~2017-04-26  7:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-21 18:22 [PATCH 0/2] add power management support to st_lsm6dsx driver Lorenzo Bianconi
2017-04-21 18:22 ` [PATCH 1/2] iio: imu: st_lsm6dsx: export st_lsm6dsx_flush_fifo() and st_lsm6dsx_set_fifo_mode() routines Lorenzo Bianconi
2017-04-26  5:54   ` Jonathan Cameron
2017-04-26  7:13     ` Lorenzo BIANCONI
2017-04-21 18:22 ` [PATCH 2/2] iio: imu: st_lsm6dsx: add system sleep power management support Lorenzo Bianconi
2017-04-21 18:33   ` Lars-Peter Clausen
2017-04-21 18:46     ` Lorenzo Bianconi
2017-04-26  5:56   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.