From: Dmitry Torokhov <dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Quentin Schulz
<quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Cc: jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
knaack.h-Mmb7MZpHnFY@public.gmane.org,
lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org,
pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org,
maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org,
wens-jdAy2FN1RRM@public.gmane.org,
lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
antoine.tenart-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org,
thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 4/5] input: touchscreen: support Allwinner SoCs' touchscreen
Date: Sat, 24 Sep 2016 11:39:54 -0700 [thread overview]
Message-ID: <20160924183954.GE40187@dtor-ws> (raw)
In-Reply-To: <ca39a2e7-6116-6f6e-3f61-78abfdefcbb7-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
Hi Quentin,
On Sat, Sep 24, 2016 at 08:26:08PM +0200, Quentin Schulz wrote:
> Hi Dimitry,
>
> Sorry for the (long) delay, I did not have time to work on it. I'll
> mainly work in my free time now.
>
> On 20/07/2016 19:25, Dmitry Torokhov wrote:
> > Hi Quentin,
> >
> > On Wed, Jul 20, 2016 at 10:29:10AM +0200, Quentin Schulz wrote:
> >> This adds support for Allwinner SoCs' (A10, A13 and A31) resistive
> >> touchscreen. This driver is probed by the MFD sunxi-gpadc-mfd.
> >>
> >> This driver uses ADC channels exposed through the IIO framework by
> >> sunxi-gpadc-iio to get its data. When opening this input device, it will
> >> start buffering in the ADC driver and enable a TP_UP_PENDING irq. The ADC
> >> driver will fill in a buffer with all data and call the callback the input
> >> device associated with this buffer. The input device will then read the
> >> buffer two by two and send X and Y coordinates to the input framework based
> >> on what it received from the ADC's buffer. When closing this input device,
> >> the buffering is stopped.
> >>
> >> Note that locations in the first received buffer after an TP_UP_PENDING irq
> >> occurred are unreliable, thus dropped.
> >>
> >> Signed-off-by: Quentin Schulz <quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> >> ---
> [...]
> >> + info->buffer = iio_channel_get_all_cb(&pdev->dev,
> >> + &sunxi_gpadc_ts_callback,
> >> + (void *)info);
> >
> > Any chance we could introduce devm-variant here? If you do not want to
> > wait for IIO to add it you can temporarily add call
> > devm_add_action_or_reset() after getting channels and remove it when IIO
> > API catches up.
> >
>
> Something like:
>
> release_iio_channels(void* data)
> {
> struct sunxi_gpadc_ts *info = data;
> iio_channel_release_all_cb(info->buffer);
> }
>
> [...]
> info->buffer = iio_channel_get_all_cb(&pdev->dev,
> &sunxi_gpadc_ts_callback,
> (void *)info);
> ret = devm_add_action_or_reset(&pdev->dev,
> release_iio_channels,
> (void *)info);
> if (ret)
> return ret;
>
> ?
>
> May I know why you prefer that way instead of explicit removing in
> remove function of the platform device? I understand for devm-variant
> already in the framework but I am curious for this one.
So that you release all resources in the same order they were allocated.
When mixing devm and non-devm allocation/release order is often
incorrect.
>
> [...]
> >> +static int sunxi_gpadc_ts_remove(struct platform_device *pdev)
> >> +{
> >> + struct sunxi_gpadc_ts *info = platform_get_drvdata(pdev);
> >> +
> >> + iio_channel_stop_all_cb(info->buffer);
> >> + iio_channel_release_all_cb(info->buffer);
> >> +
> >> + disable_irq(info->tp_up_irq);
> >
> > You are mixing devm and non-devm so your unwind order is completely out
> > of wack. If input device is opened while you are unloading (or
> > unbinding) the dirver, then you'll release channels, then input device's
> > close() will be called, which will try to stop the IIO channels again
> > and disable IRQ yet again.
> >
>
> Do you mean that I should be using exclusively devm or non-devm functions?
Yes. Sometimes you can get away with mixing style (you have all devm
resources allocated first, then non-devm), but it is much clearer and
safer if you use one style or another exclusively.
> Do you mean input device's close will always be called when
> unloading/unbinding the driver?
If ->open() has been called() then input core will ensure that ->close()
is called as part of input_unregister_device(). If ->open() has not been
called, then ->close() will not be called either.
Thanks.
--
Dmitry
WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Quentin Schulz <quentin.schulz@free-electrons.com>
Cc: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de,
pmeerw@pmeerw.net, maxime.ripard@free-electrons.com,
wens@csie.org, lee.jones@linaro.org,
antoine.tenart@free-electrons.com,
thomas.petazzoni@free-electrons.com,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-input@vger.kernel.org
Subject: Re: [PATCH 4/5] input: touchscreen: support Allwinner SoCs' touchscreen
Date: Sat, 24 Sep 2016 11:39:54 -0700 [thread overview]
Message-ID: <20160924183954.GE40187@dtor-ws> (raw)
In-Reply-To: <ca39a2e7-6116-6f6e-3f61-78abfdefcbb7@free-electrons.com>
Hi Quentin,
On Sat, Sep 24, 2016 at 08:26:08PM +0200, Quentin Schulz wrote:
> Hi Dimitry,
>
> Sorry for the (long) delay, I did not have time to work on it. I'll
> mainly work in my free time now.
>
> On 20/07/2016 19:25, Dmitry Torokhov wrote:
> > Hi Quentin,
> >
> > On Wed, Jul 20, 2016 at 10:29:10AM +0200, Quentin Schulz wrote:
> >> This adds support for Allwinner SoCs' (A10, A13 and A31) resistive
> >> touchscreen. This driver is probed by the MFD sunxi-gpadc-mfd.
> >>
> >> This driver uses ADC channels exposed through the IIO framework by
> >> sunxi-gpadc-iio to get its data. When opening this input device, it will
> >> start buffering in the ADC driver and enable a TP_UP_PENDING irq. The ADC
> >> driver will fill in a buffer with all data and call the callback the input
> >> device associated with this buffer. The input device will then read the
> >> buffer two by two and send X and Y coordinates to the input framework based
> >> on what it received from the ADC's buffer. When closing this input device,
> >> the buffering is stopped.
> >>
> >> Note that locations in the first received buffer after an TP_UP_PENDING irq
> >> occurred are unreliable, thus dropped.
> >>
> >> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> >> ---
> [...]
> >> + info->buffer = iio_channel_get_all_cb(&pdev->dev,
> >> + &sunxi_gpadc_ts_callback,
> >> + (void *)info);
> >
> > Any chance we could introduce devm-variant here? If you do not want to
> > wait for IIO to add it you can temporarily add call
> > devm_add_action_or_reset() after getting channels and remove it when IIO
> > API catches up.
> >
>
> Something like:
>
> release_iio_channels(void* data)
> {
> struct sunxi_gpadc_ts *info = data;
> iio_channel_release_all_cb(info->buffer);
> }
>
> [...]
> info->buffer = iio_channel_get_all_cb(&pdev->dev,
> &sunxi_gpadc_ts_callback,
> (void *)info);
> ret = devm_add_action_or_reset(&pdev->dev,
> release_iio_channels,
> (void *)info);
> if (ret)
> return ret;
>
> ?
>
> May I know why you prefer that way instead of explicit removing in
> remove function of the platform device? I understand for devm-variant
> already in the framework but I am curious for this one.
So that you release all resources in the same order they were allocated.
When mixing devm and non-devm allocation/release order is often
incorrect.
>
> [...]
> >> +static int sunxi_gpadc_ts_remove(struct platform_device *pdev)
> >> +{
> >> + struct sunxi_gpadc_ts *info = platform_get_drvdata(pdev);
> >> +
> >> + iio_channel_stop_all_cb(info->buffer);
> >> + iio_channel_release_all_cb(info->buffer);
> >> +
> >> + disable_irq(info->tp_up_irq);
> >
> > You are mixing devm and non-devm so your unwind order is completely out
> > of wack. If input device is opened while you are unloading (or
> > unbinding) the dirver, then you'll release channels, then input device's
> > close() will be called, which will try to stop the IIO channels again
> > and disable IRQ yet again.
> >
>
> Do you mean that I should be using exclusively devm or non-devm functions?
Yes. Sometimes you can get away with mixing style (you have all devm
resources allocated first, then non-devm), but it is much clearer and
safer if you use one style or another exclusively.
> Do you mean input device's close will always be called when
> unloading/unbinding the driver?
If ->open() has been called() then input core will ensure that ->close()
is called as part of input_unregister_device(). If ->open() has not been
called, then ->close() will not be called either.
Thanks.
--
Dmitry
WARNING: multiple messages have this Message-ID (diff)
From: dmitry.torokhov@gmail.com (Dmitry Torokhov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/5] input: touchscreen: support Allwinner SoCs' touchscreen
Date: Sat, 24 Sep 2016 11:39:54 -0700 [thread overview]
Message-ID: <20160924183954.GE40187@dtor-ws> (raw)
In-Reply-To: <ca39a2e7-6116-6f6e-3f61-78abfdefcbb7@free-electrons.com>
Hi Quentin,
On Sat, Sep 24, 2016 at 08:26:08PM +0200, Quentin Schulz wrote:
> Hi Dimitry,
>
> Sorry for the (long) delay, I did not have time to work on it. I'll
> mainly work in my free time now.
>
> On 20/07/2016 19:25, Dmitry Torokhov wrote:
> > Hi Quentin,
> >
> > On Wed, Jul 20, 2016 at 10:29:10AM +0200, Quentin Schulz wrote:
> >> This adds support for Allwinner SoCs' (A10, A13 and A31) resistive
> >> touchscreen. This driver is probed by the MFD sunxi-gpadc-mfd.
> >>
> >> This driver uses ADC channels exposed through the IIO framework by
> >> sunxi-gpadc-iio to get its data. When opening this input device, it will
> >> start buffering in the ADC driver and enable a TP_UP_PENDING irq. The ADC
> >> driver will fill in a buffer with all data and call the callback the input
> >> device associated with this buffer. The input device will then read the
> >> buffer two by two and send X and Y coordinates to the input framework based
> >> on what it received from the ADC's buffer. When closing this input device,
> >> the buffering is stopped.
> >>
> >> Note that locations in the first received buffer after an TP_UP_PENDING irq
> >> occurred are unreliable, thus dropped.
> >>
> >> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
> >> ---
> [...]
> >> + info->buffer = iio_channel_get_all_cb(&pdev->dev,
> >> + &sunxi_gpadc_ts_callback,
> >> + (void *)info);
> >
> > Any chance we could introduce devm-variant here? If you do not want to
> > wait for IIO to add it you can temporarily add call
> > devm_add_action_or_reset() after getting channels and remove it when IIO
> > API catches up.
> >
>
> Something like:
>
> release_iio_channels(void* data)
> {
> struct sunxi_gpadc_ts *info = data;
> iio_channel_release_all_cb(info->buffer);
> }
>
> [...]
> info->buffer = iio_channel_get_all_cb(&pdev->dev,
> &sunxi_gpadc_ts_callback,
> (void *)info);
> ret = devm_add_action_or_reset(&pdev->dev,
> release_iio_channels,
> (void *)info);
> if (ret)
> return ret;
>
> ?
>
> May I know why you prefer that way instead of explicit removing in
> remove function of the platform device? I understand for devm-variant
> already in the framework but I am curious for this one.
So that you release all resources in the same order they were allocated.
When mixing devm and non-devm allocation/release order is often
incorrect.
>
> [...]
> >> +static int sunxi_gpadc_ts_remove(struct platform_device *pdev)
> >> +{
> >> + struct sunxi_gpadc_ts *info = platform_get_drvdata(pdev);
> >> +
> >> + iio_channel_stop_all_cb(info->buffer);
> >> + iio_channel_release_all_cb(info->buffer);
> >> +
> >> + disable_irq(info->tp_up_irq);
> >
> > You are mixing devm and non-devm so your unwind order is completely out
> > of wack. If input device is opened while you are unloading (or
> > unbinding) the dirver, then you'll release channels, then input device's
> > close() will be called, which will try to stop the IIO channels again
> > and disable IRQ yet again.
> >
>
> Do you mean that I should be using exclusively devm or non-devm functions?
Yes. Sometimes you can get away with mixing style (you have all devm
resources allocated first, then non-devm), but it is much clearer and
safer if you use one style or another exclusively.
> Do you mean input device's close will always be called when
> unloading/unbinding the driver?
If ->open() has been called() then input core will ensure that ->close()
is called as part of input_unregister_device(). If ->open() has not been
called, then ->close() will not be called either.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2016-09-24 18:39 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-20 8:29 [PATCH 0/5] add resistive touchscreen support for new Allwinner SoCs' GPADC's driver Quentin Schulz
2016-07-20 8:29 ` Quentin Schulz
2016-07-20 8:29 ` [PATCH 1/5] mfd: sunxi-gpadc-mfd: add TP_UP_PENDING irq Quentin Schulz
2016-07-20 8:29 ` Quentin Schulz
[not found] ` <1469003351-15263-1-git-send-email-quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-07-20 8:29 ` [PATCH 2/5] mfd: sunxi-gpadc-mfd: add buffer structure Quentin Schulz
2016-07-20 8:29 ` Quentin Schulz
2016-07-20 8:29 ` Quentin Schulz
[not found] ` <1469003351-15263-3-git-send-email-quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-07-24 10:32 ` Jonathan Cameron
2016-07-24 10:32 ` Jonathan Cameron
2016-07-24 10:32 ` Jonathan Cameron
2016-07-20 8:29 ` [PATCH 3/5] iio: adc: sunxi-gpadc-iio: enable iio_buffers Quentin Schulz
2016-07-20 8:29 ` Quentin Schulz
2016-07-20 8:29 ` Quentin Schulz
2016-07-20 8:38 ` Peter Meerwald-Stadler
2016-07-20 8:38 ` Peter Meerwald-Stadler
2016-07-20 8:57 ` Quentin Schulz
2016-07-20 8:57 ` Quentin Schulz
2016-07-24 11:03 ` Jonathan Cameron
2016-07-24 11:03 ` Jonathan Cameron
[not found] ` <ff7515ec-a064-95df-1118-93c7062c2237-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-09-24 17:40 ` Quentin Schulz
2016-09-24 17:40 ` Quentin Schulz
2016-09-24 17:40 ` Quentin Schulz
2016-09-25 9:10 ` Jonathan Cameron
2016-09-25 9:10 ` Jonathan Cameron
2016-09-25 19:57 ` Quentin Schulz
2016-09-25 19:57 ` Quentin Schulz
2016-09-27 19:38 ` Jonathan Cameron
2016-09-27 19:38 ` Jonathan Cameron
2016-07-20 8:29 ` [PATCH 4/5] input: touchscreen: support Allwinner SoCs' touchscreen Quentin Schulz
2016-07-20 8:29 ` Quentin Schulz
[not found] ` <1469003351-15263-5-git-send-email-quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-07-20 17:25 ` Dmitry Torokhov
2016-07-20 17:25 ` Dmitry Torokhov
2016-07-20 17:25 ` Dmitry Torokhov
2016-07-20 20:13 ` Jonathan Cameron
2016-07-20 20:13 ` Jonathan Cameron
2016-09-24 18:26 ` Quentin Schulz
2016-09-24 18:26 ` Quentin Schulz
2016-09-24 18:26 ` Quentin Schulz
[not found] ` <ca39a2e7-6116-6f6e-3f61-78abfdefcbb7-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-09-24 18:39 ` Dmitry Torokhov [this message]
2016-09-24 18:39 ` Dmitry Torokhov
2016-09-24 18:39 ` Dmitry Torokhov
2016-07-21 6:29 ` Maxime Ripard
2016-07-21 6:29 ` Maxime Ripard
2016-07-21 6:29 ` Maxime Ripard
2016-07-21 6:41 ` Dmitry Torokhov
2016-07-21 6:41 ` Dmitry Torokhov
2016-07-25 9:45 ` maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
2016-07-25 9:45 ` maxime.ripard at free-electrons.com
2016-07-25 9:45 ` maxime.ripard
2016-07-25 17:08 ` Dmitry Torokhov
2016-07-25 17:08 ` Dmitry Torokhov
2016-07-25 17:08 ` Dmitry Torokhov
2016-07-26 15:13 ` Maxime Ripard
2016-07-26 15:13 ` Maxime Ripard
2016-07-24 11:24 ` Jonathan Cameron
2016-07-24 11:24 ` Jonathan Cameron
2016-07-24 11:24 ` Jonathan Cameron
[not found] ` <8174039f-777e-b4b8-58c9-3509748f2799-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-09-25 19:44 ` Quentin Schulz
2016-09-25 19:44 ` Quentin Schulz
2016-09-25 19:44 ` Quentin Schulz
[not found] ` <db3ab94a-9dbb-3bd6-fe43-e530b42c9246-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2016-09-27 19:59 ` Jonathan Cameron
2016-09-27 19:59 ` Jonathan Cameron
2016-09-27 19:59 ` Jonathan Cameron
2016-07-20 8:29 ` [PATCH 5/5] mfd: sunxi-gpadc-mfd: probe sunxi-gpadc-ts driver Quentin Schulz
2016-07-20 8:29 ` Quentin Schulz
2016-07-21 6:08 ` Maxime Ripard
2016-07-21 6:08 ` Maxime Ripard
2016-07-24 11:26 ` Jonathan Cameron
2016-07-24 11:26 ` Jonathan Cameron
2016-07-25 9:51 ` Maxime Ripard
2016-07-25 9:51 ` Maxime Ripard
2016-07-25 10:08 ` Jonathan Cameron
2016-07-25 10:08 ` Jonathan Cameron
[not found] ` <11247e4f-d04d-d5bc-6ebf-a637820c011d-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2016-07-25 10:21 ` Lee Jones
2016-07-25 10:21 ` Lee Jones
2016-07-25 10:21 ` Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160924183954.GE40187@dtor-ws \
--to=dmitry.torokhov-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=antoine.tenart-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=jic23-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=knaack.h-Mmb7MZpHnFY@public.gmane.org \
--cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
--cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-iio-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=pmeerw-jW+XmwGofnusTnJN9+BGXg@public.gmane.org \
--cc=quentin.schulz-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=thomas.petazzoni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org \
--cc=wens-jdAy2FN1RRM@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.