linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.19 482/671] iio: tsl2772: Use devm_add_action_or_reset for tsl2772_chip_off
       [not found] <20200116170509.12787-1-sashal@kernel.org>
@ 2020-01-16 17:02 ` Sasha Levin
  2020-01-16 18:16   ` Jonathan Cameron
  2020-01-16 17:02 ` [PATCH AUTOSEL 4.19 523/671] iio: dac: ad5380: fix incorrect assignment to val Sasha Levin
  1 sibling, 1 reply; 4+ messages in thread
From: Sasha Levin @ 2020-01-16 17:02 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Chuhong Yuan, Brian Masney, Jonathan Cameron, Sasha Levin, linux-iio

From: Chuhong Yuan <hslester96@gmail.com>

[ Upstream commit 338084135aeddb103624a6841972fb8588295cc6 ]

Use devm_add_action_or_reset to call tsl2772_chip_off
when the device is removed.
This also fixes the issue that the chip is turned off
before the device is unregistered.

Not marked for stable as fairly hard to hit the bug and
this is in the middle of a set making other cleanups
to the driver.  Hence will probably need explicit backporting.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Fixes: c06c4d793584 ("staging: iio: tsl2x7x/tsl2772: move out of staging")
Reviewed-by: Brian Masney <masneyb@onstation.org>
Tested-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/light/tsl2772.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c
index df5b2a0da96c..f2e308c6d6d7 100644
--- a/drivers/iio/light/tsl2772.c
+++ b/drivers/iio/light/tsl2772.c
@@ -716,6 +716,13 @@ static int tsl2772_chip_off(struct iio_dev *indio_dev)
 	return tsl2772_write_control_reg(chip, 0x00);
 }
 
+static void tsl2772_chip_off_action(void *data)
+{
+	struct iio_dev *indio_dev = data;
+
+	tsl2772_chip_off(indio_dev);
+}
+
 /**
  * tsl2772_invoke_change - power cycle the device to implement the user
  *                         parameters
@@ -1711,9 +1718,14 @@ static int tsl2772_probe(struct i2c_client *clientp,
 	if (ret < 0)
 		return ret;
 
+	ret = devm_add_action_or_reset(&clientp->dev,
+					tsl2772_chip_off_action,
+					indio_dev);
+	if (ret < 0)
+		return ret;
+
 	ret = iio_device_register(indio_dev);
 	if (ret) {
-		tsl2772_chip_off(indio_dev);
 		dev_err(&clientp->dev,
 			"%s: iio registration failed\n", __func__);
 		return ret;
@@ -1740,8 +1752,6 @@ static int tsl2772_remove(struct i2c_client *client)
 {
 	struct iio_dev *indio_dev = i2c_get_clientdata(client);
 
-	tsl2772_chip_off(indio_dev);
-
 	iio_device_unregister(indio_dev);
 
 	return 0;
-- 
2.20.1


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

* [PATCH AUTOSEL 4.19 523/671] iio: dac: ad5380: fix incorrect assignment to val
       [not found] <20200116170509.12787-1-sashal@kernel.org>
  2020-01-16 17:02 ` [PATCH AUTOSEL 4.19 482/671] iio: tsl2772: Use devm_add_action_or_reset for tsl2772_chip_off Sasha Levin
@ 2020-01-16 17:02 ` Sasha Levin
  1 sibling, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2020-01-16 17:02 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Colin Ian King, Alexandru Ardelean, Jonathan Cameron,
	Sasha Levin, linux-iio

From: Colin Ian King <colin.king@canonical.com>

[ Upstream commit b1e18768ef1214c0a8048327918a182cabe09f9d ]

Currently the pointer val is being incorrectly incremented
instead of the value pointed to by val. Fix this by adding
in the missing * indirection operator.

Addresses-Coverity: ("Unused value")
Fixes: c03f2c536818 ("staging:iio:dac: Add AD5380 driver")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/iio/dac/ad5380.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/dac/ad5380.c b/drivers/iio/dac/ad5380.c
index 873c2bf637c0..617c9f7fe59a 100644
--- a/drivers/iio/dac/ad5380.c
+++ b/drivers/iio/dac/ad5380.c
@@ -221,7 +221,7 @@ static int ad5380_read_raw(struct iio_dev *indio_dev,
 		if (ret)
 			return ret;
 		*val >>= chan->scan_type.shift;
-		val -= (1 << chan->scan_type.realbits) / 2;
+		*val -= (1 << chan->scan_type.realbits) / 2;
 		return IIO_VAL_INT;
 	case IIO_CHAN_INFO_SCALE:
 		*val = 2 * st->vref;
-- 
2.20.1


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

* Re: [PATCH AUTOSEL 4.19 482/671] iio: tsl2772: Use devm_add_action_or_reset for tsl2772_chip_off
  2020-01-16 17:02 ` [PATCH AUTOSEL 4.19 482/671] iio: tsl2772: Use devm_add_action_or_reset for tsl2772_chip_off Sasha Levin
@ 2020-01-16 18:16   ` Jonathan Cameron
  2020-01-17  2:43     ` Sasha Levin
  0 siblings, 1 reply; 4+ messages in thread
From: Jonathan Cameron @ 2020-01-16 18:16 UTC (permalink / raw)
  To: Sasha Levin; +Cc: linux-kernel, stable, Chuhong Yuan, Brian Masney, linux-iio

On Thu, 16 Jan 2020 12:02:00 -0500
Sasha Levin <sashal@kernel.org> wrote:

> From: Chuhong Yuan <hslester96@gmail.com>
> 
> [ Upstream commit 338084135aeddb103624a6841972fb8588295cc6 ]
> 
> Use devm_add_action_or_reset to call tsl2772_chip_off
> when the device is removed.
> This also fixes the issue that the chip is turned off
> before the device is unregistered.
> 
> Not marked for stable as fairly hard to hit the bug and
> this is in the middle of a set making other cleanups
> to the driver.  Hence will probably need explicit backporting.

Guess I was wrong and it does go on cleanly.  I took a quick
look at current 4.19 driver and looks like it's fine on it's
own.

We need to be careful with this one in general though.

Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> for 4.19

> 
> Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
> Fixes: c06c4d793584 ("staging: iio: tsl2x7x/tsl2772: move out of staging")
> Reviewed-by: Brian Masney <masneyb@onstation.org>
> Tested-by: Brian Masney <masneyb@onstation.org>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
>  drivers/iio/light/tsl2772.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/light/tsl2772.c b/drivers/iio/light/tsl2772.c
> index df5b2a0da96c..f2e308c6d6d7 100644
> --- a/drivers/iio/light/tsl2772.c
> +++ b/drivers/iio/light/tsl2772.c
> @@ -716,6 +716,13 @@ static int tsl2772_chip_off(struct iio_dev *indio_dev)
>  	return tsl2772_write_control_reg(chip, 0x00);
>  }
>  
> +static void tsl2772_chip_off_action(void *data)
> +{
> +	struct iio_dev *indio_dev = data;
> +
> +	tsl2772_chip_off(indio_dev);
> +}
> +
>  /**
>   * tsl2772_invoke_change - power cycle the device to implement the user
>   *                         parameters
> @@ -1711,9 +1718,14 @@ static int tsl2772_probe(struct i2c_client *clientp,
>  	if (ret < 0)
>  		return ret;
>  
> +	ret = devm_add_action_or_reset(&clientp->dev,
> +					tsl2772_chip_off_action,
> +					indio_dev);
> +	if (ret < 0)
> +		return ret;
> +
>  	ret = iio_device_register(indio_dev);
>  	if (ret) {
> -		tsl2772_chip_off(indio_dev);
>  		dev_err(&clientp->dev,
>  			"%s: iio registration failed\n", __func__);
>  		return ret;
> @@ -1740,8 +1752,6 @@ static int tsl2772_remove(struct i2c_client *client)
>  {
>  	struct iio_dev *indio_dev = i2c_get_clientdata(client);
>  
> -	tsl2772_chip_off(indio_dev);
> -
>  	iio_device_unregister(indio_dev);
>  
>  	return 0;



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

* Re: [PATCH AUTOSEL 4.19 482/671] iio: tsl2772: Use devm_add_action_or_reset for tsl2772_chip_off
  2020-01-16 18:16   ` Jonathan Cameron
@ 2020-01-17  2:43     ` Sasha Levin
  0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2020-01-17  2:43 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-kernel, stable, Chuhong Yuan, Brian Masney, linux-iio

On Thu, Jan 16, 2020 at 06:16:18PM +0000, Jonathan Cameron wrote:
>On Thu, 16 Jan 2020 12:02:00 -0500
>Sasha Levin <sashal@kernel.org> wrote:
>
>> From: Chuhong Yuan <hslester96@gmail.com>
>>
>> [ Upstream commit 338084135aeddb103624a6841972fb8588295cc6 ]
>>
>> Use devm_add_action_or_reset to call tsl2772_chip_off
>> when the device is removed.
>> This also fixes the issue that the chip is turned off
>> before the device is unregistered.
>>
>> Not marked for stable as fairly hard to hit the bug and
>> this is in the middle of a set making other cleanups
>> to the driver.  Hence will probably need explicit backporting.
>
>Guess I was wrong and it does go on cleanly.  I took a quick
>look at current 4.19 driver and looks like it's fine on it's
>own.
>
>We need to be careful with this one in general though.
>
>Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> for 4.19

Thanks Jonathan. I saw the comment, but it applied and built cleanly,
and looked sane enough without any related changes.

-- 
Thanks,
Sasha

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

end of thread, other threads:[~2020-01-17  2:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200116170509.12787-1-sashal@kernel.org>
2020-01-16 17:02 ` [PATCH AUTOSEL 4.19 482/671] iio: tsl2772: Use devm_add_action_or_reset for tsl2772_chip_off Sasha Levin
2020-01-16 18:16   ` Jonathan Cameron
2020-01-17  2:43     ` Sasha Levin
2020-01-16 17:02 ` [PATCH AUTOSEL 4.19 523/671] iio: dac: ad5380: fix incorrect assignment to val Sasha Levin

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).