linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: adp5588-keys: cancel workqueue in failure path
@ 2014-10-07  7:30 Pramod Gurav
  2014-10-07 12:42 ` Michael Hennerich
  2014-10-07 16:38 ` Dmitry Torokhov
  0 siblings, 2 replies; 5+ messages in thread
From: Pramod Gurav @ 2014-10-07  7:30 UTC (permalink / raw)
  To: linux-kernel
  Cc: Pramod Gurav, Michael Hennerich, Dmitry Torokhov, linux-input

This change introduces a label to call cancel_delayed_work_sync in
failure path.

Cc: Michael Hennerich <michael.hennerich@analog.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
---
 drivers/input/keyboard/adp5588-keys.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
index 5ef7fcf..b494062 100644
--- a/drivers/input/keyboard/adp5588-keys.c
+++ b/drivers/input/keyboard/adp5588-keys.c
@@ -559,7 +559,7 @@ static int adp5588_probe(struct i2c_client *client,
 	error = input_register_device(input);
 	if (error) {
 		dev_err(&client->dev, "unable to register input device\n");
-		goto err_free_mem;
+		goto err_delayed_work;
 	}
 
 	error = request_irq(client->irq, adp5588_irq,
@@ -592,6 +592,8 @@ static int adp5588_probe(struct i2c_client *client,
  err_unreg_dev:
 	input_unregister_device(input);
 	input = NULL;
+ err_delayed_work:
+	cancel_delayed_work_sync(&kpad->work);
  err_free_mem:
 	input_free_device(input);
 	kfree(kpad);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: adp5588-keys: cancel workqueue in failure path
  2014-10-07  7:30 [PATCH] Input: adp5588-keys: cancel workqueue in failure path Pramod Gurav
@ 2014-10-07 12:42 ` Michael Hennerich
  2014-10-07 16:38 ` Dmitry Torokhov
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Hennerich @ 2014-10-07 12:42 UTC (permalink / raw)
  To: Pramod Gurav, linux-kernel; +Cc: Dmitry Torokhov, linux-input

On 10/07/2014 09:30 AM, Pramod Gurav wrote:
> This change introduces a label to call cancel_delayed_work_sync in
> failure path.
>
> Cc: Michael Hennerich <michael.hennerich@analog.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>

The interrupt triggers the work queue. adp5588_setup() enable the HW 
interrupt.
Only if the device was configured before, without being resetb -
The earliest point in time where a problem could happen - is after the 
request_irq().

Anyways patch below doesn't harm and fixes a potential problem.

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

> ---
>   drivers/input/keyboard/adp5588-keys.c |    4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
> index 5ef7fcf..b494062 100644
> --- a/drivers/input/keyboard/adp5588-keys.c
> +++ b/drivers/input/keyboard/adp5588-keys.c
> @@ -559,7 +559,7 @@ static int adp5588_probe(struct i2c_client *client,
>   	error = input_register_device(input);
>   	if (error) {
>   		dev_err(&client->dev, "unable to register input device\n");
> -		goto err_free_mem;
> +		goto err_delayed_work;
>   	}
>   
>   	error = request_irq(client->irq, adp5588_irq,
> @@ -592,6 +592,8 @@ static int adp5588_probe(struct i2c_client *client,
>    err_unreg_dev:
>   	input_unregister_device(input);
>   	input = NULL;
> + err_delayed_work:
> +	cancel_delayed_work_sync(&kpad->work);
>    err_free_mem:
>   	input_free_device(input);
>   	kfree(kpad);


-- 
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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: adp5588-keys: cancel workqueue in failure path
  2014-10-07  7:30 [PATCH] Input: adp5588-keys: cancel workqueue in failure path Pramod Gurav
  2014-10-07 12:42 ` Michael Hennerich
@ 2014-10-07 16:38 ` Dmitry Torokhov
  2014-10-08 10:18   ` Pramod Gurav
  1 sibling, 1 reply; 5+ messages in thread
From: Dmitry Torokhov @ 2014-10-07 16:38 UTC (permalink / raw)
  To: Pramod Gurav; +Cc: linux-kernel, Michael Hennerich, linux-input

On Tue, Oct 07, 2014 at 01:00:49PM +0530, Pramod Gurav wrote:
> This change introduces a label to call cancel_delayed_work_sync in
> failure path.
> 
> Cc: Michael Hennerich <michael.hennerich@analog.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: linux-input@vger.kernel.org
> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
> ---
>  drivers/input/keyboard/adp5588-keys.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
> index 5ef7fcf..b494062 100644
> --- a/drivers/input/keyboard/adp5588-keys.c
> +++ b/drivers/input/keyboard/adp5588-keys.c
> @@ -559,7 +559,7 @@ static int adp5588_probe(struct i2c_client *client,
>  	error = input_register_device(input);
>  	if (error) {
>  		dev_err(&client->dev, "unable to register input device\n");
> -		goto err_free_mem;
> +		goto err_delayed_work;
>  	}
>  
>  	error = request_irq(client->irq, adp5588_irq,
> @@ -592,6 +592,8 @@ static int adp5588_probe(struct i2c_client *client,
>   err_unreg_dev:
>  	input_unregister_device(input);
>  	input = NULL;
> + err_delayed_work:
> +	cancel_delayed_work_sync(&kpad->work);

We do not need to have a separate label, just need to cancel workqueue
after freeing interrupt. I adjusted the patch and applied.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: adp5588-keys: cancel workqueue in failure path
  2014-10-07 16:38 ` Dmitry Torokhov
@ 2014-10-08 10:18   ` Pramod Gurav
  2014-10-08 10:25     ` Pramod Gurav
  0 siblings, 1 reply; 5+ messages in thread
From: Pramod Gurav @ 2014-10-08 10:18 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Pramod Gurav, linux-kernel, Michael Hennerich, linux-input

Hi Dmitry,

On Tue, Oct 7, 2014 at 10:08 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Tue, Oct 07, 2014 at 01:00:49PM +0530, Pramod Gurav wrote:
>> This change introduces a label to call cancel_delayed_work_sync in
>> failure path.
>>
>> Cc: Michael Hennerich <michael.hennerich@analog.com>
>> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> Cc: linux-input@vger.kernel.org
>> Signed-off-by: Pramod Gurav <pramod.gurav@smartplayin.com>
>> ---
>>  drivers/input/keyboard/adp5588-keys.c |    4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c
>> index 5ef7fcf..b494062 100644
>> --- a/drivers/input/keyboard/adp5588-keys.c
>> +++ b/drivers/input/keyboard/adp5588-keys.c
>> @@ -559,7 +559,7 @@ static int adp5588_probe(struct i2c_client *client,
>>       error = input_register_device(input);
>>       if (error) {
>>               dev_err(&client->dev, "unable to register input device\n");
>> -             goto err_free_mem;
>> +             goto err_delayed_work;
>>       }
>>
>>       error = request_irq(client->irq, adp5588_irq,
>> @@ -592,6 +592,8 @@ static int adp5588_probe(struct i2c_client *client,
>>   err_unreg_dev:
>>       input_unregister_device(input);
>>       input = NULL;
>> + err_delayed_work:
>> +     cancel_delayed_work_sync(&kpad->work);
>
> We do not need to have a separate label, just need to cancel workqueue
> after freeing interrupt. I adjusted the patch and applied.
>
Thanks. I saw the change in your tree. Shouldn't
cancel_delayed_work_sync(&kpad->work) be called under label
err_free_mem so that it will executed in case adp5588_read,
input_register_device, request_irq etc.
Or else we will still have workqueue instance hanging around.

> Thanks.
>
> --
> Dmitry
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/



-- 
Thanks and Regards
Pramod

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Input: adp5588-keys: cancel workqueue in failure path
  2014-10-08 10:18   ` Pramod Gurav
@ 2014-10-08 10:25     ` Pramod Gurav
  0 siblings, 0 replies; 5+ messages in thread
From: Pramod Gurav @ 2014-10-08 10:25 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Pramod Gurav, linux-kernel, Michael Hennerich, linux-input

On Wed, Oct 8, 2014 at 3:48 PM, Pramod Gurav <pramod.gurav.etc@gmail.com> wrote:
> Hi Dmitry,
>
> On Tue, Oct 7, 2014 at 10:08 PM, Dmitry Torokhov
>

..

> Thanks. I saw the change in your tree. Shouldn't
> cancel_delayed_work_sync(&kpad->work) be called under label
> err_free_mem so that it will executed in case adp5588_read,
> input_register_device, request_irq etc.
> Or else we will still have workqueue instance hanging around.
>

Sorry, Should have read Michael's reply more carefully. I get the
reason behind cancelling workquequq after freeing irq.


-- 
Thanks and Regards
Pramod

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-10-08 10:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-07  7:30 [PATCH] Input: adp5588-keys: cancel workqueue in failure path Pramod Gurav
2014-10-07 12:42 ` Michael Hennerich
2014-10-07 16:38 ` Dmitry Torokhov
2014-10-08 10:18   ` Pramod Gurav
2014-10-08 10:25     ` Pramod Gurav

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).