2013-09-06 11:04:23

by Xie XiuQi

[permalink] [raw]
Subject: [PATCH 0/5] remove unnecessary work pending test

There's no need to test whether a (delayed) work item in pending
before queueing, flushing or cancelling it. It has been tested in
queue_work_on() already. No functional changed.

Xie XiuQi (5):
iio: adc: remove unnecessary work pending test
input: remove unnecessary work pending test
lib: remove unnecessary work pending test
staging: olpc_dcon: remove unnecessary work pending test
ipc: input: remove unnecessary work pending test

drivers/input/touchscreen/cyttsp4_core.c | 3 +--
drivers/staging/iio/adc/ad7606_core.c | 7 +++----
drivers/staging/olpc_dcon/olpc_dcon.c | 2 +-
ipc/util.c | 4 +---
lib/debugobjects.c | 2 +-
5 files changed, 7 insertions(+), 11 deletions(-)

--
1.8.2.2


2013-09-06 11:04:19

by Xie XiuQi

[permalink] [raw]
Subject: [PATCH 2/5] input: remove unnecessary work pending test

Remove unnecessary work pending test before calling schedule_work().
It has been tested in queue_work_on() already.

Signed-off-by: Xie XiuQi <[email protected]>
Cc: Tejun Heo <[email protected]>
---
drivers/input/touchscreen/cyttsp4_core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c
index edcf799..b0ee865 100644
--- a/drivers/input/touchscreen/cyttsp4_core.c
+++ b/drivers/input/touchscreen/cyttsp4_core.c
@@ -1249,8 +1249,7 @@ static void cyttsp4_watchdog_timer(unsigned long handle)
if (!cd)
return;

- if (!work_pending(&cd->watchdog_work))
- schedule_work(&cd->watchdog_work);
+ schedule_work(&cd->watchdog_work);

return;
}
--
1.8.2.2


2013-09-06 11:04:44

by Xie XiuQi

[permalink] [raw]
Subject: [PATCH 1/5] iio: adc: remove unnecessary work pending test

Remove unnecessary work pending test before calling schedule_work().
It has been tested in queue_work_on() already. No functional changed.

Signed-off-by: Xie XiuQi <[email protected]>
Cc: Tejun Heo <[email protected]>
---
drivers/staging/iio/adc/ad7606_core.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7606_core.c b/drivers/staging/iio/adc/ad7606_core.c
index 72868ce..c6f99069 100644
--- a/drivers/staging/iio/adc/ad7606_core.c
+++ b/drivers/staging/iio/adc/ad7606_core.c
@@ -424,10 +424,9 @@ static irqreturn_t ad7606_interrupt(int irq, void *dev_id)
struct iio_dev *indio_dev = dev_id;
struct ad7606_state *st = iio_priv(indio_dev);

- if (iio_buffer_enabled(indio_dev)) {
- if (!work_pending(&st->poll_work))
- schedule_work(&st->poll_work);
- } else {
+ if (iio_buffer_enabled(indio_dev))
+ schedule_work(&st->poll_work);
+ else {
st->done = true;
wake_up_interruptible(&st->wq_data_avail);
}
--
1.8.2.2


2013-09-06 11:05:38

by Xie XiuQi

[permalink] [raw]
Subject: [PATCH 3/5] lib: remove unnecessary work pending test

Remove unnecessary work pending test before calling schedule_work().
It has been tested in queue_work_on() already. No functional changed.

Signed-off-by: Xie XiuQi <[email protected]>
Cc: Tejun Heo <[email protected]>
---
lib/debugobjects.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/debugobjects.c b/lib/debugobjects.c
index 37061ed..67e84c8 100644
--- a/lib/debugobjects.c
+++ b/lib/debugobjects.c
@@ -196,7 +196,7 @@ static void free_object(struct debug_obj *obj)
* initialized:
*/
if (obj_pool_free > ODEBUG_POOL_SIZE && obj_cache)
- sched = keventd_up() && !work_pending(&debug_obj_work);
+ sched = keventd_up();
hlist_add_head(&obj->node, &obj_pool);
obj_pool_free++;
obj_pool_used--;
--
1.8.2.2


2013-09-06 11:07:35

by Xie XiuQi

[permalink] [raw]
Subject: [PATCH 4/5] staging: olpc_dcon: remove unnecessary work pending test

Remove unnecessary work pending test before calling schedule_work().
It has been tested in queue_work_on() already. No functional changed.

Signed-off-by: Xie XiuQi <[email protected]>
Cc: Tejun Heo <[email protected]>
---
drivers/staging/olpc_dcon/olpc_dcon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/olpc_dcon/olpc_dcon.c b/drivers/staging/olpc_dcon/olpc_dcon.c
index 193e1c6..0dfd528 100644
--- a/drivers/staging/olpc_dcon/olpc_dcon.c
+++ b/drivers/staging/olpc_dcon/olpc_dcon.c
@@ -381,7 +381,7 @@ static void dcon_set_source(struct dcon_priv *dcon, int arg)

dcon->pending_src = arg;

- if ((dcon->curr_src != arg) && !work_pending(&dcon->switch_source))
+ if (dcon->curr_src != arg)
schedule_work(&dcon->switch_source);
}

--
1.8.2.2


2013-09-06 11:08:14

by Xie XiuQi

[permalink] [raw]
Subject: [PATCH 5/5] ipc: remove unnecessary work pending test

Remove unnecessary work pending test before calling schedule_work().
It has been tested in queue_work_on() already. No functional changed.

Signed-off-by: Xie XiuQi <[email protected]>
Cc: Nadia Derbey <[email protected]>
Cc: Tejun Heo <[email protected]>
---
ipc/util.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/ipc/util.c b/ipc/util.c
index 4704223..f9105ed 100644
--- a/ipc/util.c
+++ b/ipc/util.c
@@ -67,10 +67,8 @@ static int ipc_memory_callback(struct notifier_block *self,
* In order not to keep the lock on the hotplug memory chain
* for too long, queue a work item that will, when waken up,
* activate the ipcns notification chain.
- * No need to keep several ipc work items on the queue.
*/
- if (!work_pending(&ipc_memory_wq))
- schedule_work(&ipc_memory_wq);
+ schedule_work(&ipc_memory_wq);
break;
case MEM_GOING_ONLINE:
case MEM_GOING_OFFLINE:
--
1.8.2.2


2013-09-06 15:20:36

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH 1/5] iio: adc: remove unnecessary work pending test

On Fri, Sep 06, 2013 at 07:02:34PM +0800, Xie XiuQi wrote:
> Remove unnecessary work pending test before calling schedule_work().
> It has been tested in queue_work_on() already. No functional changed.
>
> Signed-off-by: Xie XiuQi <[email protected]>
> Cc: Tejun Heo <[email protected]>

Reviewed-by: Tejun Heo <[email protected]>

One nit below tho.

> - if (iio_buffer_enabled(indio_dev)) {
> - if (!work_pending(&st->poll_work))
> - schedule_work(&st->poll_work);
> - } else {
> + if (iio_buffer_enabled(indio_dev))
> + schedule_work(&st->poll_work);
> + else {
> st->done = true;
> wake_up_interruptible(&st->wq_data_avail);
> }

Please don't drop the parentheses. The convention is to have either
both or none on if/else.

Thanks.

--
tejun

2013-09-06 15:21:10

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH 2/5] input: remove unnecessary work pending test

On Fri, Sep 06, 2013 at 07:03:43PM +0800, Xie XiuQi wrote:
> Remove unnecessary work pending test before calling schedule_work().
> It has been tested in queue_work_on() already.
>
> Signed-off-by: Xie XiuQi <[email protected]>
> Cc: Tejun Heo <[email protected]>

Reviewed-by: Tejun Heo <[email protected]>

Thanks.

--
tejun

2013-09-06 15:22:12

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH 3/5] lib: remove unnecessary work pending test

On Fri, Sep 06, 2013 at 07:05:09PM +0800, Xie XiuQi wrote:
> Remove unnecessary work pending test before calling schedule_work().
> It has been tested in queue_work_on() already. No functional changed.
>
> Signed-off-by: Xie XiuQi <[email protected]>
> Cc: Tejun Heo <[email protected]>

Reviewed-by: Tejun Heo <[email protected]>

Thanks.

--
tejun

2013-09-06 15:24:59

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH 4/5] staging: olpc_dcon: remove unnecessary work pending test

On Fri, Sep 06, 2013 at 07:06:41PM +0800, Xie XiuQi wrote:
> Remove unnecessary work pending test before calling schedule_work().
> It has been tested in queue_work_on() already. No functional changed.
>
> Signed-off-by: Xie XiuQi <[email protected]>
> Cc: Tejun Heo <[email protected]>

Reviewed-by: Tejun Heo <[email protected]>

Thanks.

--
tejun

2013-09-06 15:25:33

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH 5/5] ipc: remove unnecessary work pending test

On Fri, Sep 06, 2013 at 07:07:37PM +0800, Xie XiuQi wrote:
> Remove unnecessary work pending test before calling schedule_work().
> It has been tested in queue_work_on() already. No functional changed.
>
> Signed-off-by: Xie XiuQi <[email protected]>
> Cc: Nadia Derbey <[email protected]>
> Cc: Tejun Heo <[email protected]>

Reviewed-by: Tejun Heo <[email protected]>

Thanks.

--
tejun

2013-09-07 19:44:45

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 1/5] iio: adc: remove unnecessary work pending test

ccing Michael Hennerich and Lars-Peter Clausen,

On 09/06/13 16:20, Tejun Heo wrote:
> On Fri, Sep 06, 2013 at 07:02:34PM +0800, Xie XiuQi wrote:
>> Remove unnecessary work pending test before calling schedule_work().
>> It has been tested in queue_work_on() already. No functional changed.
>>
>> Signed-off-by: Xie XiuQi <[email protected]>
>> Cc: Tejun Heo <[email protected]>
>
> Reviewed-by: Tejun Heo <[email protected]>
>
> One nit below tho.
>
>> - if (iio_buffer_enabled(indio_dev)) {
>> - if (!work_pending(&st->poll_work))
>> - schedule_work(&st->poll_work);
>> - } else {
>> + if (iio_buffer_enabled(indio_dev))
>> + schedule_work(&st->poll_work);
>> + else {
>> st->done = true;
>> wake_up_interruptible(&st->wq_data_avail);
>> }
>
> Please don't drop the parentheses. The convention is to have either
> both or none on if/else.

I'll fix this up on applying if everyone is happy (can't see why the
won't be, but best to check!) Michael is clearly given as the author of driver
so should probably have been in the cc list. Whilst I might apply this directly
as maintainer I much prefer if I get an ack from the driver author as if nothing
else it gives me a warm fuzzy feeling ;)

Also patch title should mention that a) this is a staging driver, b) which adc driver it
applies to. I'll fix that up as well on applying it.

Thanks for the patch though, it would probably never have been noticed otherwise!

>
> Thanks.
>

2013-09-09 20:14:45

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH 1/5] iio: adc: remove unnecessary work pending test

On 09/09/13 16:23, Michael Hennerich wrote:
> On 09/07/2013 10:44 PM, Jonathan Cameron wrote:
>> ccing Michael Hennerich and Lars-Peter Clausen,
>
> Looks good to me!
>
> /Acked-by/: /Michael Hennerich/ <[email protected]>
Applied to the togreg branch of iio.git.

Thanks
>
>>
>> On 09/06/13 16:20, Tejun Heo wrote:
>>> On Fri, Sep 06, 2013 at 07:02:34PM +0800, Xie XiuQi wrote:
>>>> Remove unnecessary work pending test before calling schedule_work().
>>>> It has been tested in queue_work_on() already. No functional changed.
>>>>
>>>> Signed-off-by: Xie XiuQi <[email protected]>
>>>> Cc: Tejun Heo <[email protected]>
>>> Reviewed-by: Tejun Heo <[email protected]>
>>>
>>> One nit below tho.
>>>
>>>> - if (iio_buffer_enabled(indio_dev)) {
>>>> - if (!work_pending(&st->poll_work))
>>>> - schedule_work(&st->poll_work);
>>>> - } else {
>>>> + if (iio_buffer_enabled(indio_dev))
>>>> + schedule_work(&st->poll_work);
>>>> + else {
>>>> st->done = true;
>>>> wake_up_interruptible(&st->wq_data_avail);
>>>> }
>>> Please don't drop the parentheses. The convention is to have either
>>> both or none on if/else.
>> I'll fix this up on applying if everyone is happy (can't see why the
>> won't be, but best to check!) Michael is clearly given as the author of driver
>> so should probably have been in the cc list. Whilst I might apply this directly
>> as maintainer I much prefer if I get an ack from the driver author as if nothing
>> else it gives me a warm fuzzy feeling ;)
>>
>> Also patch title should mention that a) this is a staging driver, b) which adc driver it
>> applies to. I'll fix that up as well on applying it.
>>
>> Thanks for the patch though, it would probably never have been noticed otherwise!
>>
>>> Thanks.
>>>
>
>
> --
> Greetings,
> Michael
>
> --
> Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
> Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
> Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
> Margaret Seif
>