From: Artur Rojek <contact@artur-rojek.eu>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH] Input: adc-joystick - fix ordering in adc_joystick_probe()
Date: Mon, 18 Jul 2022 11:25:12 +0200 [thread overview]
Message-ID: <c93f12598af6d708d702e0538b5c700e@artur-rojek.eu> (raw)
In-Reply-To: <YskFh4NHnlcryMkk@google.com>
On 2022-07-09 06:35, Dmitry Torokhov wrote:
> We should register the IIO buffer before we register the input device,
> because as soon as the device is registered input handlers may attach
> to
> it, resulting in a call to adc_joystick_open() which makes use of the
> said
> buffer.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>
> Not tested on hardware...
Hi Dmitry,
nice catch, thanks! I will verify the operation on hardware some time
over the weekend.
Small nitpick inline. With that changed:
Acked-by: Artur Rojek <contact@artur-rojek.eu>
>
> drivers/input/joystick/adc-joystick.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/input/joystick/adc-joystick.c
> b/drivers/input/joystick/adc-joystick.c
> index 78ebca7d400a..e0cfdc84763f 100644
> --- a/drivers/input/joystick/adc-joystick.c
> +++ b/drivers/input/joystick/adc-joystick.c
> @@ -222,13 +222,6 @@ static int adc_joystick_probe(struct
> platform_device *pdev)
> if (error)
> return error;
>
> - input_set_drvdata(input, joy);
> - error = input_register_device(input);
> - if (error) {
> - dev_err(dev, "Unable to register input device\n");
> - return error;
> - }
> -
> joy->buffer = iio_channel_get_all_cb(dev, adc_joystick_handle, joy);
> if (IS_ERR(joy->buffer)) {
> dev_err(dev, "Unable to allocate callback buffer\n");
> @@ -241,6 +234,14 @@ static int adc_joystick_probe(struct
> platform_device *pdev)
> return error;
> }
>
> + input_set_drvdata(input, joy);
> +
> + error = input_register_device(input);
> + if (error) {
> + dev_err(dev, "Unable to register input device\n");
> + return error;
> + }
> +
> return 0;
Since this is now the last thing the function does, we can simplify the
code a bit:
```
error = input_register_device(input);
if (error)
dev_err(dev, "Unable to register input device\n");
return error;
```
Cheers,
Artur
> }
>
> --
> 2.37.0.144.g8ac04bfd2-goog
prev parent reply other threads:[~2022-07-18 9:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-09 4:35 [PATCH] Input: adc-joystick - fix ordering in adc_joystick_probe() Dmitry Torokhov
2022-07-18 9:25 ` Artur Rojek [this message]
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=c93f12598af6d708d702e0538b5c700e@artur-rojek.eu \
--to=contact@artur-rojek.eu \
--cc=dmitry.torokhov@gmail.com \
--cc=jic23@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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 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).