This patch frees stmpe-keyboard driver from tension of freeing resources :)
devm_* derivatives of multiple routines are used while allocating resources,
which would be freed automatically by kernel.
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/input/keyboard/stmpe-keypad.c | 31 ++++++++++---------------------
1 file changed, 10 insertions(+), 21 deletions(-)
diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
index 470a877..6e25497 100644
--- a/drivers/input/keyboard/stmpe-keypad.c
+++ b/drivers/input/keyboard/stmpe-keypad.c
@@ -275,15 +275,14 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
if (irq < 0)
return irq;
- keypad = kzalloc(sizeof(struct stmpe_keypad), GFP_KERNEL);
+ keypad = devm_kzalloc(&pdev->dev, sizeof(struct stmpe_keypad),
+ GFP_KERNEL);
if (!keypad)
return -ENOMEM;
- input = input_allocate_device();
- if (!input) {
- ret = -ENOMEM;
- goto out_freekeypad;
- }
+ input = devm_input_allocate_device(&pdev->dev);
+ if (!input)
+ return -ENOMEM;
input->name = "STMPE keypad";
input->id.bustype = BUS_I2C;
@@ -294,7 +293,7 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
STMPE_KEYPAD_MAX_COLS,
keypad->keymap, input);
if (ret)
- goto out_freeinput;
+ return ret;
input_set_capability(input, EV_MSC, MSC_SCAN);
if (!plat->no_autorepeat)
@@ -314,17 +313,17 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
ret = stmpe_keypad_chip_init(keypad);
if (ret < 0)
- goto out_freeinput;
+ return ret;
ret = input_register_device(input);
if (ret) {
dev_err(&pdev->dev,
"unable to register input device: %d\n", ret);
- goto out_freeinput;
+ return ret;
}
- ret = request_threaded_irq(irq, NULL, stmpe_keypad_irq, IRQF_ONESHOT,
- "stmpe-keypad", keypad);
+ ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, stmpe_keypad_irq,
+ IRQF_ONESHOT, "stmpe-keypad", keypad);
if (ret) {
dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
goto out_unregisterinput;
@@ -336,11 +335,6 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
out_unregisterinput:
input_unregister_device(input);
- input = NULL;
-out_freeinput:
- input_free_device(input);
-out_freekeypad:
- kfree(keypad);
return ret;
}
@@ -348,14 +342,9 @@ static int __devexit stmpe_keypad_remove(struct platform_device *pdev)
{
struct stmpe_keypad *keypad = platform_get_drvdata(pdev);
struct stmpe *stmpe = keypad->stmpe;
- int irq = platform_get_irq(pdev, 0);
stmpe_disable(stmpe, STMPE_BLOCK_KEYPAD);
-
- free_irq(irq, keypad);
input_unregister_device(keypad->input);
- platform_set_drvdata(pdev, NULL);
- kfree(keypad);
return 0;
}
--
1.7.12.rc2.18.g61b472e
This patch frees stmpe-ts driver from tension of freeing resources :)
devm_* derivatives of multiple routines are used while allocating resources,
which would be freed automatically by kernel.
Signed-off-by: Viresh Kumar <[email protected]>
---
drivers/input/touchscreen/stmpe-ts.c | 45 +++++++++---------------------------
1 file changed, 11 insertions(+), 34 deletions(-)
diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index 692b685..66b932e 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -275,17 +275,13 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
if (ts_irq < 0)
return ts_irq;
- ts = kzalloc(sizeof(*ts), GFP_KERNEL);
- if (!ts) {
- ret = -ENOMEM;
- goto err_out;
- }
+ ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL);
+ if (!ts)
+ return -ENOMEM;
- idev = input_allocate_device();
- if (!idev) {
- ret = -ENOMEM;
- goto err_free_ts;
- }
+ idev = devm_input_allocate_device(&pdev->dev);
+ if (!idev)
+ return -ENOMEM;
platform_set_drvdata(pdev, ts);
ts->stmpe = stmpe;
@@ -309,16 +305,16 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
INIT_DELAYED_WORK(&ts->work, stmpe_work);
- ret = request_threaded_irq(ts_irq, NULL, stmpe_ts_handler,
- IRQF_ONESHOT, STMPE_TS_NAME, ts);
+ ret = devm_request_threaded_irq(&pdev->dev, ts_irq, NULL,
+ stmpe_ts_handler, IRQF_ONESHOT, STMPE_TS_NAME, ts);
if (ret) {
dev_err(&pdev->dev, "Failed to request IRQ %d\n", ts_irq);
- goto err_free_input;
+ return ret;
}
ret = stmpe_init_hw(ts);
if (ret)
- goto err_free_irq;
+ return ret;
idev->name = STMPE_TS_NAME;
idev->id.bustype = BUS_I2C;
@@ -335,39 +331,20 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
input_set_abs_params(idev, ABS_PRESSURE, 0x0, 0xff, 0, 0);
ret = input_register_device(idev);
- if (ret) {
+ if (ret)
dev_err(&pdev->dev, "Could not register input device\n");
- goto err_free_irq;
- }
-
- return ret;
-err_free_irq:
- free_irq(ts_irq, ts);
-err_free_input:
- input_free_device(idev);
- platform_set_drvdata(pdev, NULL);
-err_free_ts:
- kfree(ts);
-err_out:
return ret;
}
static int __devexit stmpe_ts_remove(struct platform_device *pdev)
{
struct stmpe_touch *ts = platform_get_drvdata(pdev);
- unsigned int ts_irq = platform_get_irq_byname(pdev, "FIFO_TH");
stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN);
- free_irq(ts_irq, ts);
-
- platform_set_drvdata(pdev, NULL);
-
input_unregister_device(ts->idev);
- kfree(ts);
-
return 0;
}
--
1.7.12.rc2.18.g61b472e
From: Vipul Kumar Samar <[email protected]>
Signed-off-by: Vipul Kumar Samar <[email protected]>
---
drivers/input/touchscreen/stmpe-ts.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index 66b932e..9896095 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -317,6 +317,7 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
return ret;
idev->name = STMPE_TS_NAME;
+ idev->phys = STMPE_TS_NAME"/input0";
idev->id.bustype = BUS_I2C;
idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
--
1.7.12.rc2.18.g61b472e
Hi Viresh,
On Fri, Nov 09, 2012 at 08:57:48PM +0530, Viresh Kumar wrote:
> This patch frees stmpe-keyboard driver from tension of freeing resources :)
> devm_* derivatives of multiple routines are used while allocating resources,
> which would be freed automatically by kernel.
>
> Signed-off-by: Viresh Kumar <[email protected]>
> ---
> drivers/input/keyboard/stmpe-keypad.c | 31 ++++++++++---------------------
> 1 file changed, 10 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
> index 470a877..6e25497 100644
> --- a/drivers/input/keyboard/stmpe-keypad.c
> +++ b/drivers/input/keyboard/stmpe-keypad.c
> @@ -275,15 +275,14 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
> if (irq < 0)
> return irq;
>
> - keypad = kzalloc(sizeof(struct stmpe_keypad), GFP_KERNEL);
> + keypad = devm_kzalloc(&pdev->dev, sizeof(struct stmpe_keypad),
> + GFP_KERNEL);
> if (!keypad)
> return -ENOMEM;
>
> - input = input_allocate_device();
> - if (!input) {
> - ret = -ENOMEM;
> - goto out_freekeypad;
> - }
> + input = devm_input_allocate_device(&pdev->dev);
> + if (!input)
> + return -ENOMEM;
>
> input->name = "STMPE keypad";
> input->id.bustype = BUS_I2C;
> @@ -294,7 +293,7 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
> STMPE_KEYPAD_MAX_COLS,
> keypad->keymap, input);
> if (ret)
> - goto out_freeinput;
> + return ret;
>
> input_set_capability(input, EV_MSC, MSC_SCAN);
> if (!plat->no_autorepeat)
> @@ -314,17 +313,17 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>
> ret = stmpe_keypad_chip_init(keypad);
> if (ret < 0)
> - goto out_freeinput;
> + return ret;
>
> ret = input_register_device(input);
> if (ret) {
> dev_err(&pdev->dev,
> "unable to register input device: %d\n", ret);
> - goto out_freeinput;
> + return ret;
> }
>
> - ret = request_threaded_irq(irq, NULL, stmpe_keypad_irq, IRQF_ONESHOT,
> - "stmpe-keypad", keypad);
> + ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, stmpe_keypad_irq,
> + IRQF_ONESHOT, "stmpe-keypad", keypad);
> if (ret) {
> dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
> goto out_unregisterinput;
> @@ -336,11 +335,6 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
>
> out_unregisterinput:
> input_unregister_device(input);
If input device was alocated with devm_* interface it does not need be
explicitly unregistered/freed.
Thanks.
--
Dmitry
On 9 November 2012 22:15, Dmitry Torokhov <[email protected]> wrote:
> If input device was alocated with devm_* interface it does not need be
> explicitly unregistered/freed.
Thanks for pointing out:
Fixup:
commit 4bf57c85f49f16a139af80f8de76fa01eee77a5d
Author: Viresh Kumar <[email protected]>
Date: Fri Nov 9 22:31:34 2012 +0530
fixup! input: stmpe-keyboard: Use devm_*() routines
---
drivers/input/keyboard/stmpe-keypad.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/input/keyboard/stmpe-keypad.c
b/drivers/input/keyboard/stmpe-keypad.c
index 6e25497..706b16f 100644
--- a/drivers/input/keyboard/stmpe-keypad.c
+++ b/drivers/input/keyboard/stmpe-keypad.c
@@ -326,16 +326,12 @@ static int __devinit stmpe_keypad_probe(struct
platform_device *pdev)
IRQF_ONESHOT, "stmpe-keypad", keypad);
if (ret) {
dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
- goto out_unregisterinput;
+ return ret;
}
platform_set_drvdata(pdev, keypad);
return 0;
-
-out_unregisterinput:
- input_unregister_device(input);
- return ret;
}
static int __devexit stmpe_keypad_remove(struct platform_device *pdev)
@@ -344,7 +340,6 @@ static int __devexit stmpe_keypad_remove(struct
platform_device *pdev)
struct stmpe *stmpe = keypad->stmpe;
stmpe_disable(stmpe, STMPE_BLOCK_KEYPAD);
- input_unregister_device(keypad->input);
return 0;
}
On 9 November 2012 20:57, Viresh Kumar <[email protected]> wrote:
> This patch frees stmpe-ts driver from tension of freeing resources :)
> devm_* derivatives of multiple routines are used while allocating resources,
> which would be freed automatically by kernel.
>
> Signed-off-by: Viresh Kumar <[email protected]>
Fixup:
commit dda6d45808d65aaf8b0d4153e7a418b255365818
Author: Viresh Kumar <[email protected]>
Date: Fri Nov 9 22:28:26 2012 +0530
fixup! input: stmpe-ts: Use devm_*() routines
---
drivers/input/touchscreen/stmpe-ts.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/input/touchscreen/stmpe-ts.c
b/drivers/input/touchscreen/stmpe-ts.c
index 9896095..f2cb15d 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -344,8 +344,6 @@ static int __devexit stmpe_ts_remove(struct
platform_device *pdev)
stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN);
- input_unregister_device(ts->idev);
-
return 0;
}
Hi Viresh,
On Fri, Nov 09, 2012 at 10:34:35PM +0530, Viresh Kumar wrote:
> On 9 November 2012 20:57, Viresh Kumar <[email protected]> wrote:
> > This patch frees stmpe-ts driver from tension of freeing resources :)
> > devm_* derivatives of multiple routines are used while allocating resources,
> > which would be freed automatically by kernel.
> >
> > Signed-off-by: Viresh Kumar <[email protected]>
>
> Fixup:
>
> commit dda6d45808d65aaf8b0d4153e7a418b255365818
> Author: Viresh Kumar <[email protected]>
> Date: Fri Nov 9 22:28:26 2012 +0530
>
> fixup! input: stmpe-ts: Use devm_*() routines
> ---
> drivers/input/touchscreen/stmpe-ts.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/drivers/input/touchscreen/stmpe-ts.c
> b/drivers/input/touchscreen/stmpe-ts.c
> index 9896095..f2cb15d 100644
> --- a/drivers/input/touchscreen/stmpe-ts.c
> +++ b/drivers/input/touchscreen/stmpe-ts.c
> @@ -344,8 +344,6 @@ static int __devexit stmpe_ts_remove(struct
> platform_device *pdev)
Sometimes your mailer does wrap long lines, please make sure to turn it
off for patches.
There is no need to resend this one.
Thanks.
--
Dmitry
On 10 November 2012 13:30, Dmitry Torokhov <[email protected]> wrote:
> Sometimes your mailer does wrap long lines, please make sure to turn it
> off for patches.
I am using gmail for replying on mails and this fixup was done using that. Don't
know why it happened.
I am doing the same step again to verify what's playing with patches.
On this copy
i can see that this issue isn't there till now.
commit dda6d45808d65aaf8b0d4153e7a418b255365818
Author: Viresh Kumar <[email protected]>
Date: Fri Nov 9 22:28:26 2012 +0530
fixup! input: stmpe-ts: Use devm_*() routines
---
drivers/input/touchscreen/stmpe-ts.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/input/touchscreen/stmpe-ts.c
b/drivers/input/touchscreen/stmpe-ts.c
index 9896095..f2cb15d 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -344,8 +344,6 @@ static int __devexit stmpe_ts_remove(struct
platform_device *pdev)
stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN);
- input_unregister_device(ts->idev);
-
return 0;
}
--
viresh
On 10 November 2012 13:33, Viresh Kumar <[email protected]> wrote:
> On 10 November 2012 13:30, Dmitry Torokhov <[email protected]> wrote:
>> Sometimes your mailer does wrap long lines, please make sure to turn it
>> off for patches.
>
> I am using gmail for replying on mails and this fixup was done using that. Don't
> know why it happened.
>
> I am doing the same step again to verify what's playing with patches.
> On this copy
> i can see that this issue isn't there till now.
>
> diff --git a/drivers/input/touchscreen/stmpe-ts.c
> @@ -344,8 +344,6 @@ static int __devexit stmpe_ts_remove(struct
> platform_device *pdev)
wrapped again.. Don't know how to disable it. :(
On Sat, Nov 10, 2012 at 01:34:33PM +0530, Viresh Kumar wrote:
> On 10 November 2012 13:33, Viresh Kumar <[email protected]> wrote:
> > On 10 November 2012 13:30, Dmitry Torokhov <[email protected]> wrote:
> >> Sometimes your mailer does wrap long lines, please make sure to turn it
> >> off for patches.
> >
> > I am using gmail for replying on mails and this fixup was done using that. Don't
> > know why it happened.
> >
> > I am doing the same step again to verify what's playing with patches.
> > On this copy
> > i can see that this issue isn't there till now.
> >
> > diff --git a/drivers/input/touchscreen/stmpe-ts.c
>
> > @@ -344,8 +344,6 @@ static int __devexit stmpe_ts_remove(struct
> > platform_device *pdev)
>
> wrapped again.. Don't know how to disable it. :(
I just use mutt...
--
Dmitry
On Sat, Nov 10, 2012 at 01:34:33PM +0530, Viresh Kumar wrote:
> wrapped again.. Don't know how to disable it. :(
To quote Documentation/email-clients.txt:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gmail (Web GUI)
Does not work for sending patches.
Gmail web client converts tabs to spaces automatically.
At the same time it wraps lines every 78 chars with CRLF style line breaks
although tab2space problem can be solved with external editor.
Another problem is that Gmail will base64-encode any message that has a
non-ASCII character. That includes things like European names.
On 9 November 2012 20:57, Viresh Kumar <[email protected]> wrote:
> From: Vipul Kumar Samar <[email protected]>
>
> Signed-off-by: Vipul Kumar Samar <[email protected]>
> ---
> drivers/input/touchscreen/stmpe-ts.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
> index 66b932e..9896095 100644
> --- a/drivers/input/touchscreen/stmpe-ts.c
> +++ b/drivers/input/touchscreen/stmpe-ts.c
> @@ -317,6 +317,7 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
> return ret;
>
> idev->name = STMPE_TS_NAME;
> + idev->phys = STMPE_TS_NAME"/input0";
> idev->id.bustype = BUS_I2C;
> idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
> idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
Missed this one too?
On Tue, Nov 20, 2012 at 12:28:08PM +0530, Viresh Kumar wrote:
> On 9 November 2012 20:57, Viresh Kumar <[email protected]> wrote:
> > From: Vipul Kumar Samar <[email protected]>
> >
> > Signed-off-by: Vipul Kumar Samar <[email protected]>
> > ---
> > drivers/input/touchscreen/stmpe-ts.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
> > index 66b932e..9896095 100644
> > --- a/drivers/input/touchscreen/stmpe-ts.c
> > +++ b/drivers/input/touchscreen/stmpe-ts.c
> > @@ -317,6 +317,7 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
> > return ret;
> >
> > idev->name = STMPE_TS_NAME;
> > + idev->phys = STMPE_TS_NAME"/input0";
> > idev->id.bustype = BUS_I2C;
> > idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
> > idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
>
> Missed this one too?
Nope, it's commit b8d52e2b9f7eb43075e6ef4e23f5e51e70548f11
Thanks.
--
Dmitry
On 20 November 2012 13:17, Dmitry Torokhov <[email protected]> wrote:
> Nope, it's commit b8d52e2b9f7eb43075e6ef4e23f5e51e70548f11
Sorry, my fault.
I searched for Viresh in git log of your master and next branches. And i
didn't signed-off this patch.