* [PATCH] Input: da9052_onkey: Convert to managed resources
@ 2015-07-27 2:56 Vaishali Thakkar
2015-08-04 12:52 ` Opensource [Steve Twiss]
0 siblings, 1 reply; 4+ messages in thread
From: Vaishali Thakkar @ 2015-07-27 2:56 UTC (permalink / raw)
To: Support Opensource; +Cc: Dmitry Torokhov, linux-input, linux-kernel
Use managed resource functions devm_input_allocate_device and
devm_kzalloc. To be compatible with the change, replace various
gotos by direct returns and drop unneeded labels.
Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
---
drivers/input/misc/da9052_onkey.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c
index 266e07f..3243fe9 100644
--- a/drivers/input/misc/da9052_onkey.c
+++ b/drivers/input/misc/da9052_onkey.c
@@ -84,12 +84,11 @@ static int da9052_onkey_probe(struct platform_device *pdev)
return -EINVAL;
}
- onkey = kzalloc(sizeof(*onkey), GFP_KERNEL);
- input_dev = input_allocate_device();
+ onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL);
+ input_dev = devm_input_allocate_device(&pdev->dev);
if (!onkey || !input_dev) {
dev_err(&pdev->dev, "Failed to allocate memory\n");
- error = -ENOMEM;
- goto err_free_mem;
+ return -ENOMEM;
}
onkey->input = input_dev;
@@ -108,7 +107,7 @@ static int da9052_onkey_probe(struct platform_device *pdev)
if (error < 0) {
dev_err(onkey->da9052->dev,
"Failed to register ONKEY IRQ: %d\n", error);
- goto err_free_mem;
+ return error;
}
error = input_register_device(onkey->input);
@@ -124,9 +123,6 @@ static int da9052_onkey_probe(struct platform_device *pdev)
err_free_irq:
da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
cancel_delayed_work_sync(&onkey->work);
-err_free_mem:
- input_free_device(input_dev);
- kfree(onkey);
return error;
}
@@ -138,9 +134,6 @@ static int da9052_onkey_remove(struct platform_device *pdev)
da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
cancel_delayed_work_sync(&onkey->work);
- input_unregister_device(onkey->input);
- kfree(onkey);
-
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] Input: da9052_onkey: Convert to managed resources
2015-07-27 2:56 [PATCH] Input: da9052_onkey: Convert to managed resources Vaishali Thakkar
@ 2015-08-04 12:52 ` Opensource [Steve Twiss]
2015-10-02 17:43 ` Dmitry Torokhov
0 siblings, 1 reply; 4+ messages in thread
From: Opensource [Steve Twiss] @ 2015-08-04 12:52 UTC (permalink / raw)
To: Vaishali Thakkar
Cc: Dmitry Torokhov, linux-input, linux-kernel, Support Opensource
On 27 July 2015 03:56, Vaishali Thakkar wrote:
> Subject: [PATCH] Input: da9052_onkey: Convert to managed resources
>
> Use managed resource functions devm_input_allocate_device and
> devm_kzalloc. To be compatible with the change, replace various
> gotos by direct returns and drop unneeded labels.
>
> Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
> ---
> drivers/input/misc/da9052_onkey.c | 15 ++++-----------
> 1 file changed, 4 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/input/misc/da9052_onkey.c
> b/drivers/input/misc/da9052_onkey.c
> index 266e07f..3243fe9 100644
> --- a/drivers/input/misc/da9052_onkey.c
> +++ b/drivers/input/misc/da9052_onkey.c
> @@ -84,12 +84,11 @@ static int da9052_onkey_probe(struct
> platform_device *pdev)
> return -EINVAL;
> }
>
> - onkey = kzalloc(sizeof(*onkey), GFP_KERNEL);
> - input_dev = input_allocate_device();
> + onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL);
> + input_dev = devm_input_allocate_device(&pdev->dev);
> if (!onkey || !input_dev) {
> dev_err(&pdev->dev, "Failed to allocate memory\n");
> - error = -ENOMEM;
> - goto err_free_mem;
> + return -ENOMEM;
> }
>
> onkey->input = input_dev;
> @@ -108,7 +107,7 @@ static int da9052_onkey_probe(struct
> platform_device *pdev)
> if (error < 0) {
> dev_err(onkey->da9052->dev,
> "Failed to register ONKEY IRQ: %d\n", error);
> - goto err_free_mem;
> + return error;
> }
>
> error = input_register_device(onkey->input);
> @@ -124,9 +123,6 @@ static int da9052_onkey_probe(struct
> platform_device *pdev)
> err_free_irq:
> da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
> cancel_delayed_work_sync(&onkey->work);
> -err_free_mem:
> - input_free_device(input_dev);
> - kfree(onkey);
>
> return error;
> }
> @@ -138,9 +134,6 @@ static int da9052_onkey_remove(struct
> platform_device *pdev)
> da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
> cancel_delayed_work_sync(&onkey->work);
>
> - input_unregister_device(onkey->input);
> - kfree(onkey);
> -
> return 0;
> }
>
> --
> 1.9.1
Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Input: da9052_onkey: Convert to managed resources
2015-08-04 12:52 ` Opensource [Steve Twiss]
@ 2015-10-02 17:43 ` Dmitry Torokhov
2015-10-02 18:35 ` Vaishali Thakkar
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2015-10-02 17:43 UTC (permalink / raw)
To: Opensource [Steve Twiss]
Cc: Vaishali Thakkar, linux-input, linux-kernel, Support Opensource
On Tue, Aug 04, 2015 at 12:52:53PM +0000, Opensource [Steve Twiss] wrote:
> On 27 July 2015 03:56, Vaishali Thakkar wrote:
>
> > Subject: [PATCH] Input: da9052_onkey: Convert to managed resources
> >
> > Use managed resource functions devm_input_allocate_device and
> > devm_kzalloc. To be compatible with the change, replace various
> > gotos by direct returns and drop unneeded labels.
> >
> > Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
> > ---
> > drivers/input/misc/da9052_onkey.c | 15 ++++-----------
> > 1 file changed, 4 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/input/misc/da9052_onkey.c
> > b/drivers/input/misc/da9052_onkey.c
> > index 266e07f..3243fe9 100644
> > --- a/drivers/input/misc/da9052_onkey.c
> > +++ b/drivers/input/misc/da9052_onkey.c
> > @@ -84,12 +84,11 @@ static int da9052_onkey_probe(struct
> > platform_device *pdev)
> > return -EINVAL;
> > }
> >
> > - onkey = kzalloc(sizeof(*onkey), GFP_KERNEL);
> > - input_dev = input_allocate_device();
> > + onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL);
> > + input_dev = devm_input_allocate_device(&pdev->dev);
> > if (!onkey || !input_dev) {
> > dev_err(&pdev->dev, "Failed to allocate memory\n");
> > - error = -ENOMEM;
> > - goto err_free_mem;
> > + return -ENOMEM;
> > }
> >
> > onkey->input = input_dev;
> > @@ -108,7 +107,7 @@ static int da9052_onkey_probe(struct
> > platform_device *pdev)
> > if (error < 0) {
> > dev_err(onkey->da9052->dev,
> > "Failed to register ONKEY IRQ: %d\n", error);
> > - goto err_free_mem;
> > + return error;
> > }
> >
> > error = input_register_device(onkey->input);
> > @@ -124,9 +123,6 @@ static int da9052_onkey_probe(struct
> > platform_device *pdev)
> > err_free_irq:
> > da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
> > cancel_delayed_work_sync(&onkey->work);
> > -err_free_mem:
> > - input_free_device(input_dev);
> > - kfree(onkey);
> >
> > return error;
> > }
> > @@ -138,9 +134,6 @@ static int da9052_onkey_remove(struct
> > platform_device *pdev)
> > da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
> > cancel_delayed_work_sync(&onkey->work);
> >
> > - input_unregister_device(onkey->input);
> > - kfree(onkey);
> > -
> > return 0;
> > }
> >
> > --
> > 1.9.1
>
> Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
>
I prefer not to mix stategies of managing resources in a single driver.
I.e. either everything is devm* or nothing is.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Input: da9052_onkey: Convert to managed resources
2015-10-02 17:43 ` Dmitry Torokhov
@ 2015-10-02 18:35 ` Vaishali Thakkar
0 siblings, 0 replies; 4+ messages in thread
From: Vaishali Thakkar @ 2015-10-02 18:35 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Opensource [Steve Twiss], linux-input, linux-kernel, Support Opensource
On Fri, Oct 2, 2015 at 11:13 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Tue, Aug 04, 2015 at 12:52:53PM +0000, Opensource [Steve Twiss] wrote:
>> On 27 July 2015 03:56, Vaishali Thakkar wrote:
>>
>> > Subject: [PATCH] Input: da9052_onkey: Convert to managed resources
>> >
>> > Use managed resource functions devm_input_allocate_device and
>> > devm_kzalloc. To be compatible with the change, replace various
>> > gotos by direct returns and drop unneeded labels.
>> >
>> > Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
>> > ---
>> > drivers/input/misc/da9052_onkey.c | 15 ++++-----------
>> > 1 file changed, 4 insertions(+), 11 deletions(-)
>> >
>> > diff --git a/drivers/input/misc/da9052_onkey.c
>> > b/drivers/input/misc/da9052_onkey.c
>> > index 266e07f..3243fe9 100644
>> > --- a/drivers/input/misc/da9052_onkey.c
>> > +++ b/drivers/input/misc/da9052_onkey.c
>> > @@ -84,12 +84,11 @@ static int da9052_onkey_probe(struct
>> > platform_device *pdev)
>> > return -EINVAL;
>> > }
>> >
>> > - onkey = kzalloc(sizeof(*onkey), GFP_KERNEL);
>> > - input_dev = input_allocate_device();
>> > + onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL);
>> > + input_dev = devm_input_allocate_device(&pdev->dev);
>> > if (!onkey || !input_dev) {
>> > dev_err(&pdev->dev, "Failed to allocate memory\n");
>> > - error = -ENOMEM;
>> > - goto err_free_mem;
>> > + return -ENOMEM;
>> > }
>> >
>> > onkey->input = input_dev;
>> > @@ -108,7 +107,7 @@ static int da9052_onkey_probe(struct
>> > platform_device *pdev)
>> > if (error < 0) {
>> > dev_err(onkey->da9052->dev,
>> > "Failed to register ONKEY IRQ: %d\n", error);
>> > - goto err_free_mem;
>> > + return error;
>> > }
>> >
>> > error = input_register_device(onkey->input);
>> > @@ -124,9 +123,6 @@ static int da9052_onkey_probe(struct
>> > platform_device *pdev)
>> > err_free_irq:
>> > da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
>> > cancel_delayed_work_sync(&onkey->work);
>> > -err_free_mem:
>> > - input_free_device(input_dev);
>> > - kfree(onkey);
>> >
>> > return error;
>> > }
>> > @@ -138,9 +134,6 @@ static int da9052_onkey_remove(struct
>> > platform_device *pdev)
>> > da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
>> > cancel_delayed_work_sync(&onkey->work);
>> >
>> > - input_unregister_device(onkey->input);
>> > - kfree(onkey);
>> > -
>> > return 0;
>> > }
>> >
>> > --
>> > 1.9.1
>>
>> Acked-by: Steve Twiss <stwiss.opensource@diasemi.com>
>>
>
> I prefer not to mix stategies of managing resources in a single driver.
> I.e. either everything is devm* or nothing is.
Yeah, I understand. I guess this is an old patch. You can drop it.
Thanks
> Thanks.
>
> --
> Dmitry
--
Vaishali
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-10-02 18:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-27 2:56 [PATCH] Input: da9052_onkey: Convert to managed resources Vaishali Thakkar
2015-08-04 12:52 ` Opensource [Steve Twiss]
2015-10-02 17:43 ` Dmitry Torokhov
2015-10-02 18:35 ` Vaishali Thakkar
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.