* [PATCH v2] Input: synaptics_i2c - remove redundant spinlock
@ 2019-02-17 6:10 thesven73
2019-02-17 6:54 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: thesven73 @ 2019-02-17 6:10 UTC (permalink / raw)
To: Dmitry Torokhov; +Cc: linux-input, linux-kernel, Sven Van Asbroeck, Tejun Heo
From: Sven Van Asbroeck <TheSven73@gmail.com>
Remove a leftover spinlock.
This was required back when mod_delayed_work() did not exist,
and had to be implemented with a cancel + queue. See
commit e7c2f967445d ("workqueue: use mod_delayed_work() instead of
__cancel + queue")
schedule_delayed_work() and mod_delayed_work() can now be used
concurrently. So the spinlock is no longer needed.
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
---
v2: replace useless synaptics_i2c_reschedule_work() with
mod_delayed_work().
drivers/input/mouse/synaptics_i2c.c | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/drivers/input/mouse/synaptics_i2c.c b/drivers/input/mouse/synaptics_i2c.c
index 8538318d332c..fa304648d611 100644
--- a/drivers/input/mouse/synaptics_i2c.c
+++ b/drivers/input/mouse/synaptics_i2c.c
@@ -219,7 +219,6 @@ struct synaptics_i2c {
struct i2c_client *client;
struct input_dev *input;
struct delayed_work dwork;
- spinlock_t lock;
int no_data_count;
int no_decel_param;
int reduce_report_param;
@@ -369,23 +368,11 @@ static bool synaptics_i2c_get_input(struct synaptics_i2c *touch)
return xy_delta || gesture;
}
-static void synaptics_i2c_reschedule_work(struct synaptics_i2c *touch,
- unsigned long delay)
-{
- unsigned long flags;
-
- spin_lock_irqsave(&touch->lock, flags);
-
- mod_delayed_work(system_wq, &touch->dwork, delay);
-
- spin_unlock_irqrestore(&touch->lock, flags);
-}
-
static irqreturn_t synaptics_i2c_irq(int irq, void *dev_id)
{
struct synaptics_i2c *touch = dev_id;
- synaptics_i2c_reschedule_work(touch, 0);
+ mod_delayed_work(system_wq, &touch->dwork, 0);
return IRQ_HANDLED;
}
@@ -461,7 +448,7 @@ static void synaptics_i2c_work_handler(struct work_struct *work)
* We poll the device once in THREAD_IRQ_SLEEP_SECS and
* if error is detected, we try to reset and reconfigure the touchpad.
*/
- synaptics_i2c_reschedule_work(touch, delay);
+ mod_delayed_work(system_wq, &touch->dwork, delay);
}
static int synaptics_i2c_open(struct input_dev *input)
@@ -474,7 +461,7 @@ static int synaptics_i2c_open(struct input_dev *input)
return ret;
if (polling_req)
- synaptics_i2c_reschedule_work(touch,
+ mod_delayed_work(system_wq, &touch->dwork,
msecs_to_jiffies(NO_DATA_SLEEP_MSECS));
return 0;
@@ -530,7 +517,6 @@ static struct synaptics_i2c *synaptics_i2c_touch_create(struct i2c_client *clien
touch->scan_rate_param = scan_rate;
set_scan_rate(touch, scan_rate);
INIT_DELAYED_WORK(&touch->dwork, synaptics_i2c_work_handler);
- spin_lock_init(&touch->lock);
return touch;
}
@@ -637,7 +623,7 @@ static int __maybe_unused synaptics_i2c_resume(struct device *dev)
if (ret)
return ret;
- synaptics_i2c_reschedule_work(touch,
+ mod_delayed_work(system_wq, &touch->dwork,
msecs_to_jiffies(NO_DATA_SLEEP_MSECS));
return 0;
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] Input: synaptics_i2c - remove redundant spinlock
2019-02-17 6:10 [PATCH v2] Input: synaptics_i2c - remove redundant spinlock thesven73
@ 2019-02-17 6:54 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2019-02-17 6:54 UTC (permalink / raw)
To: thesven73; +Cc: linux-input, linux-kernel, Tejun Heo
On Sun, Feb 17, 2019 at 01:10:53AM -0500, thesven73@gmail.com wrote:
> From: Sven Van Asbroeck <TheSven73@gmail.com>
>
> Remove a leftover spinlock.
>
> This was required back when mod_delayed_work() did not exist,
> and had to be implemented with a cancel + queue. See
> commit e7c2f967445d ("workqueue: use mod_delayed_work() instead of
> __cancel + queue")
>
> schedule_delayed_work() and mod_delayed_work() can now be used
> concurrently. So the spinlock is no longer needed.
>
> Cc: Tejun Heo <tj@kernel.org>
> Signed-off-by: Sven Van Asbroeck <TheSven73@gmail.com>
Applied, thank you.
> ---
>
> v2: replace useless synaptics_i2c_reschedule_work() with
> mod_delayed_work().
>
> drivers/input/mouse/synaptics_i2c.c | 22 ++++------------------
> 1 file changed, 4 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/input/mouse/synaptics_i2c.c b/drivers/input/mouse/synaptics_i2c.c
> index 8538318d332c..fa304648d611 100644
> --- a/drivers/input/mouse/synaptics_i2c.c
> +++ b/drivers/input/mouse/synaptics_i2c.c
> @@ -219,7 +219,6 @@ struct synaptics_i2c {
> struct i2c_client *client;
> struct input_dev *input;
> struct delayed_work dwork;
> - spinlock_t lock;
> int no_data_count;
> int no_decel_param;
> int reduce_report_param;
> @@ -369,23 +368,11 @@ static bool synaptics_i2c_get_input(struct synaptics_i2c *touch)
> return xy_delta || gesture;
> }
>
> -static void synaptics_i2c_reschedule_work(struct synaptics_i2c *touch,
> - unsigned long delay)
> -{
> - unsigned long flags;
> -
> - spin_lock_irqsave(&touch->lock, flags);
> -
> - mod_delayed_work(system_wq, &touch->dwork, delay);
> -
> - spin_unlock_irqrestore(&touch->lock, flags);
> -}
> -
> static irqreturn_t synaptics_i2c_irq(int irq, void *dev_id)
> {
> struct synaptics_i2c *touch = dev_id;
>
> - synaptics_i2c_reschedule_work(touch, 0);
> + mod_delayed_work(system_wq, &touch->dwork, 0);
>
> return IRQ_HANDLED;
> }
> @@ -461,7 +448,7 @@ static void synaptics_i2c_work_handler(struct work_struct *work)
> * We poll the device once in THREAD_IRQ_SLEEP_SECS and
> * if error is detected, we try to reset and reconfigure the touchpad.
> */
> - synaptics_i2c_reschedule_work(touch, delay);
> + mod_delayed_work(system_wq, &touch->dwork, delay);
> }
>
> static int synaptics_i2c_open(struct input_dev *input)
> @@ -474,7 +461,7 @@ static int synaptics_i2c_open(struct input_dev *input)
> return ret;
>
> if (polling_req)
> - synaptics_i2c_reschedule_work(touch,
> + mod_delayed_work(system_wq, &touch->dwork,
> msecs_to_jiffies(NO_DATA_SLEEP_MSECS));
>
> return 0;
> @@ -530,7 +517,6 @@ static struct synaptics_i2c *synaptics_i2c_touch_create(struct i2c_client *clien
> touch->scan_rate_param = scan_rate;
> set_scan_rate(touch, scan_rate);
> INIT_DELAYED_WORK(&touch->dwork, synaptics_i2c_work_handler);
> - spin_lock_init(&touch->lock);
>
> return touch;
> }
> @@ -637,7 +623,7 @@ static int __maybe_unused synaptics_i2c_resume(struct device *dev)
> if (ret)
> return ret;
>
> - synaptics_i2c_reschedule_work(touch,
> + mod_delayed_work(system_wq, &touch->dwork,
> msecs_to_jiffies(NO_DATA_SLEEP_MSECS));
>
> return 0;
> --
> 2.17.1
>
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-02-17 6:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-17 6:10 [PATCH v2] Input: synaptics_i2c - remove redundant spinlock thesven73
2019-02-17 6:54 ` Dmitry Torokhov
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).