Use local wq in order to avoid flush_scheduled_work() usage. Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> --- Please see commit c4f135d643823a86 ("workqueue: Wrap flush_workqueue() using a macro") for background. This is a blind conversion, and is only compile tested. drivers/iio/light/tsl2563.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index 0a278eea36ca..0739fced0d34 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c @@ -75,6 +75,8 @@ #define TSL2563_INT_LEVEL 0x10 #define TSL2563_INT_PERSIST(n) ((n) & 0x0F) +static struct workqueue_struct *tsl2563_wq; + struct tsl2563_gainlevel_coeff { u8 gaintime; u16 min; @@ -343,7 +345,7 @@ static int tsl2563_get_adc(struct tsl2563_chip *chip) chip->data1 = tsl2563_normalize_adc(adc1, chip->gainlevel->gaintime); if (!chip->int_enabled) - schedule_delayed_work(&chip->poweroff_work, 5 * HZ); + queue_delayed_work(tsl2563_wq, &chip->poweroff_work, 5 * HZ); ret = 0; out: @@ -660,7 +662,7 @@ static int tsl2563_write_interrupt_config(struct iio_dev *indio_dev, chip->intr); chip->int_enabled = false; /* now the interrupt is not enabled, we can go to sleep */ - schedule_delayed_work(&chip->poweroff_work, 5 * HZ); + queue_delayed_work(tsl2563_wq, &chip->poweroff_work, 5 * HZ); } out: mutex_unlock(&chip->lock); @@ -781,7 +783,7 @@ static int tsl2563_probe(struct i2c_client *client, INIT_DELAYED_WORK(&chip->poweroff_work, tsl2563_poweroff_work); /* The interrupt cannot yet be enabled so this is fine without lock */ - schedule_delayed_work(&chip->poweroff_work, 5 * HZ); + queue_delayed_work(tsl2563_wq, &chip->poweroff_work, 5 * HZ); err = iio_device_register(indio_dev); if (err) { @@ -808,7 +810,7 @@ static int tsl2563_remove(struct i2c_client *client) chip->intr &= ~0x30; i2c_smbus_write_byte_data(chip->client, TSL2563_CMD | TSL2563_REG_INT, chip->intr); - flush_scheduled_work(); + flush_workqueue(tsl2563_wq); tsl2563_set_power(chip, 0); return 0; @@ -887,7 +889,27 @@ static struct i2c_driver tsl2563_i2c_driver = { .remove = tsl2563_remove, .id_table = tsl2563_id, }; -module_i2c_driver(tsl2563_i2c_driver); + +static int __init tsl2563_init(void) +{ + int ret; + + tsl2563_wq = alloc_workqueue("tsl2563_wq", 0, 0); + if (!tsl2563_wq) + return -ENOMEM; + ret = i2c_add_driver(&tsl2563_i2c_driver); + if (ret) + destroy_workqueue(tsl2563_wq); + return ret; +} +module_init(tsl2563_init); + +static void __exit tsl2563_exit(void) +{ + i2c_del_driver(&tsl2563_i2c_driver); + destroy_workqueue(tsl2563_wq); +} +module_exit(tsl2563_exit); MODULE_AUTHOR("Nokia Corporation"); MODULE_DESCRIPTION("tsl2563 light sensor driver"); -- 2.18.4