]> git.itanic.dy.fi Git - linux-stable/commitdiff
iio:light:tsl2563: Replace cancel_delayed_work() with cancel_delayed_work_sync().
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Sun, 12 Jun 2022 15:04:00 +0000 (00:04 +0900)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 18 Jun 2022 13:56:25 +0000 (14:56 +0100)
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>
Link: https://lore.kernel.org/r/041b6745-f784-ff3f-9836-3f4397d35d94@I-love.SAKURA.ne.jp
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/light/tsl2563.c

index 4d89ac3a5bbc51369f68fb8f50334c057deb74b5..bbb577459fb987a3e75a3d3039691d5da116b053 100644 (file)
@@ -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)