* [PATCH] iio:light:tsl2563: Replace cancel_delayed_work() with cancel_delayed_work_sync().
@ 2022-06-12 15:04 Tetsuo Handa
2022-06-18 13:57 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Tetsuo Handa @ 2022-06-12 15:04 UTC (permalink / raw)
To: Jonathan Cameron, Lars-Peter Clausen; +Cc: linux-iio
Since cancel_delayed_work(&chip->poweroff_work) does not guarantee that
tsl2563_poweroff_work() is not running, tsl2563_set_power(chip, 0) can be
called from tsl2563_poweroff_work() after tsl2563_get_power(chip) and
tsl2563_set_power(chip, 1) are called. Use _sync version in order to make
sure that tsl2563_poweroff_work() is no longer running.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
---
drivers/iio/light/tsl2563.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
index 4d89ac3a5bbc..bbb577459fb9 100644
--- a/drivers/iio/light/tsl2563.c
+++ b/drivers/iio/light/tsl2563.c
@@ -310,7 +310,7 @@ static int tsl2563_get_adc(struct tsl2563_chip *chip)
goto out;
if (!chip->int_enabled) {
- cancel_delayed_work(&chip->poweroff_work);
+ cancel_delayed_work_sync(&chip->poweroff_work);
if (!tsl2563_get_power(chip)) {
ret = tsl2563_set_power(chip, 1);
@@ -638,7 +638,7 @@ static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev,
chip->intr &= ~0x30;
chip->intr |= 0x10;
/* ensure the chip is actually on */
- cancel_delayed_work(&chip->poweroff_work);
+ cancel_delayed_work_sync(&chip->poweroff_work);
if (!tsl2563_get_power(chip)) {
ret = tsl2563_set_power(chip, 1);
if (ret)
--
2.18.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio:light:tsl2563: Replace cancel_delayed_work() with cancel_delayed_work_sync().
2022-06-12 15:04 [PATCH] iio:light:tsl2563: Replace cancel_delayed_work() with cancel_delayed_work_sync() Tetsuo Handa
@ 2022-06-18 13:57 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2022-06-18 13:57 UTC (permalink / raw)
To: Tetsuo Handa; +Cc: Lars-Peter Clausen, linux-iio
On Mon, 13 Jun 2022 00:04:00 +0900
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:
> Since cancel_delayed_work(&chip->poweroff_work) does not guarantee that
> tsl2563_poweroff_work() is not running, tsl2563_set_power(chip, 0) can be
> called from tsl2563_poweroff_work() after tsl2563_get_power(chip) and
> tsl2563_set_power(chip, 1) are called. Use _sync version in order to make
> sure that tsl2563_poweroff_work() is no longer running.
>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Makes sense to me.
Applied to the togreg branch of iio.git.
Technically this may be a fix (at very least it removes some undesirable
behaviour) but I'm not proposing that we should backport it to stable.
Thanks,
Jonathan
> ---
> drivers/iio/light/tsl2563.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
> index 4d89ac3a5bbc..bbb577459fb9 100644
> --- a/drivers/iio/light/tsl2563.c
> +++ b/drivers/iio/light/tsl2563.c
> @@ -310,7 +310,7 @@ static int tsl2563_get_adc(struct tsl2563_chip *chip)
> goto out;
>
> if (!chip->int_enabled) {
> - cancel_delayed_work(&chip->poweroff_work);
> + cancel_delayed_work_sync(&chip->poweroff_work);
>
> if (!tsl2563_get_power(chip)) {
> ret = tsl2563_set_power(chip, 1);
> @@ -638,7 +638,7 @@ static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev,
> chip->intr &= ~0x30;
> chip->intr |= 0x10;
> /* ensure the chip is actually on */
> - cancel_delayed_work(&chip->poweroff_work);
> + cancel_delayed_work_sync(&chip->poweroff_work);
> if (!tsl2563_get_power(chip)) {
> ret = tsl2563_set_power(chip, 1);
> if (ret)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-18 13:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-12 15:04 [PATCH] iio:light:tsl2563: Replace cancel_delayed_work() with cancel_delayed_work_sync() Tetsuo Handa
2022-06-18 13:57 ` 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.