Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1314446 > unrolled thread
| Started by | Oreste Salerno <oreste.salerno@tomtom.com> |
|---|---|
| First post | 2016-01-21 20:30 +0100 |
| Last post | 2016-01-21 22:40 +0100 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH v4 1/4] Input: cyttsp - use devres managed resource allocations Oreste Salerno <oreste.salerno@tomtom.com> - 2016-01-21 20:30 +0100
Re: [PATCH v4 1/4] Input: cyttsp - use devres managed resource allocations Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2016-01-21 20:30 +0100
Re: [PATCH v4 1/4] Input: cyttsp - use devres managed resource allocations Oreste Salerno <oreste.salerno@tomtom.com> - 2016-01-21 21:30 +0100
Re: [PATCH v4 1/4] Input: cyttsp - use devres managed resource allocations Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2016-01-21 22:40 +0100
| From | Oreste Salerno <oreste.salerno@tomtom.com> |
|---|---|
| Date | 2016-01-21 20:30 +0100 |
| Subject | [PATCH v4 1/4] Input: cyttsp - use devres managed resource allocations |
| Message-ID | <qTt5F-1hZ-27@gated-at.bofh.it> |
Use devm_() functions for allocating memory, input device and IRQ.
Signed-off-by: Oreste Salerno <oreste.salerno@tomtom.com>
---
drivers/input/touchscreen/cyttsp_core.c | 26 +++++++++-----------------
1 file changed, 9 insertions(+), 17 deletions(-)
diff --git a/drivers/input/touchscreen/cyttsp_core.c b/drivers/input/touchscreen/cyttsp_core.c
index 5b74e8b..3c2ee84 100644
--- a/drivers/input/touchscreen/cyttsp_core.c
+++ b/drivers/input/touchscreen/cyttsp_core.c
@@ -541,11 +541,11 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
goto err_out;
}
- ts = kzalloc(sizeof(*ts) + xfer_buf_size, GFP_KERNEL);
- input_dev = input_allocate_device();
+ ts = devm_kzalloc(dev, sizeof(*ts) + xfer_buf_size, GFP_KERNEL);
+ input_dev = devm_input_allocate_device(dev);
if (!ts || !input_dev) {
error = -ENOMEM;
- goto err_free_mem;
+ goto err_out;
}
ts->dev = dev;
@@ -562,7 +562,7 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
if (error) {
dev_err(ts->dev, "platform init failed, err: %d\n",
error);
- goto err_free_mem;
+ goto err_out;
}
}
@@ -586,9 +586,9 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
input_mt_init_slots(input_dev, CY_MAX_ID, 0);
- error = request_threaded_irq(ts->irq, NULL, cyttsp_irq,
- IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
- pdata->name, ts);
+ error = devm_request_threaded_irq(dev, ts->irq, NULL, cyttsp_irq,
+ IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
+ pdata->name, ts);
if (error) {
dev_err(ts->dev, "failed to request IRQ %d, err: %d\n",
ts->irq, error);
@@ -599,25 +599,20 @@ struct cyttsp *cyttsp_probe(const struct cyttsp_bus_ops *bus_ops,
error = cyttsp_power_on(ts);
if (error)
- goto err_free_irq;
+ goto err_platform_exit;
error = input_register_device(input_dev);
if (error) {
dev_err(ts->dev, "failed to register input device: %d\n",
error);
- goto err_free_irq;
+ goto err_platform_exit;
}
return ts;
-err_free_irq:
- free_irq(ts->irq, ts);
err_platform_exit:
if (pdata->exit)
pdata->exit();
-err_free_mem:
- input_free_device(input_dev);
- kfree(ts);
err_out:
return ERR_PTR(error);
}
@@ -625,11 +620,8 @@ EXPORT_SYMBOL_GPL(cyttsp_probe);
void cyttsp_remove(struct cyttsp *ts)
{
- free_irq(ts->irq, ts);
- input_unregister_device(ts->input);
if (ts->pdata->exit)
ts->pdata->exit();
- kfree(ts);
}
EXPORT_SYMBOL_GPL(cyttsp_remove);
--
1.9.1
[toc] | [next] | [standalone]
| From | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| Date | 2016-01-21 20:30 +0100 |
| Subject | Re: [PATCH v4 1/4] Input: cyttsp - use devres managed resource allocations |
| Message-ID | <qTt5F-1hZ-41@gated-at.bofh.it> |
| In reply to | #1314446 |
Hi Oreste,
On Thu, Jan 21, 2016 at 08:21:13PM +0100, Oreste Salerno wrote:
> Use devm_() functions for allocating memory, input device and IRQ.
>
...
> @@ -625,11 +620,8 @@ EXPORT_SYMBOL_GPL(cyttsp_probe);
>
> void cyttsp_remove(struct cyttsp *ts)
> {
> - free_irq(ts->irq, ts);
> - input_unregister_device(ts->input);
> if (ts->pdata->exit)
> ts->pdata->exit();
> - kfree(ts);
This is not quite correct as it changes the operations order... Given
that it is going to be removed in the next patch I guess it is OK, but
ideally you can add a custom devm action to shut off the chip.
Thanks.
--
Dmitry
[toc] | [prev] | [next] | [standalone]
| From | Oreste Salerno <oreste.salerno@tomtom.com> |
|---|---|
| Date | 2016-01-21 21:30 +0100 |
| Subject | Re: [PATCH v4 1/4] Input: cyttsp - use devres managed resource allocations |
| Message-ID | <qTu1I-1V0-29@gated-at.bofh.it> |
| In reply to | #1314453 |
On Thu, Jan 21, 2016 at 11:29:24AM -0800, Dmitry Torokhov wrote:
> Hi Oreste,
>
> On Thu, Jan 21, 2016 at 08:21:13PM +0100, Oreste Salerno wrote:
> > Use devm_() functions for allocating memory, input device and IRQ.
> >
>
> ...
>
> > @@ -625,11 +620,8 @@ EXPORT_SYMBOL_GPL(cyttsp_probe);
> >
> > void cyttsp_remove(struct cyttsp *ts)
> > {
> > - free_irq(ts->irq, ts);
> > - input_unregister_device(ts->input);
> > if (ts->pdata->exit)
> > ts->pdata->exit();
> > - kfree(ts);
>
> This is not quite correct as it changes the operations order... Given
> that it is going to be removed in the next patch I guess it is OK, but
> ideally you can add a custom devm action to shut off the chip.
>
You mean a devm action to call pdata->exit() ? OK, I could do that.
> Thanks.
>
> --
> Dmitry
[toc] | [prev] | [next] | [standalone]
| From | Dmitry Torokhov <dmitry.torokhov@gmail.com> |
|---|---|
| Date | 2016-01-21 22:40 +0100 |
| Subject | Re: [PATCH v4 1/4] Input: cyttsp - use devres managed resource allocations |
| Message-ID | <qTv7t-2E4-39@gated-at.bofh.it> |
| In reply to | #1314503 |
On Thu, Jan 21, 2016 at 09:22:05PM +0100, Oreste Salerno wrote:
> On Thu, Jan 21, 2016 at 11:29:24AM -0800, Dmitry Torokhov wrote:
> > Hi Oreste,
> >
> > On Thu, Jan 21, 2016 at 08:21:13PM +0100, Oreste Salerno wrote:
> > > Use devm_() functions for allocating memory, input device and IRQ.
> > >
> >
> > ...
> >
> > > @@ -625,11 +620,8 @@ EXPORT_SYMBOL_GPL(cyttsp_probe);
> > >
> > > void cyttsp_remove(struct cyttsp *ts)
> > > {
> > > - free_irq(ts->irq, ts);
> > > - input_unregister_device(ts->input);
> > > if (ts->pdata->exit)
> > > ts->pdata->exit();
> > > - kfree(ts);
> >
> > This is not quite correct as it changes the operations order... Given
> > that it is going to be removed in the next patch I guess it is OK, but
> > ideally you can add a custom devm action to shut off the chip.
> >
>
> You mean a devm action to call pdata->exit() ? OK, I could do that.
Yes.
Thanks.
--
Dmitry
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web