diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2022-08-02 20:00:00 +0300 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2022-08-02 20:01:16 +0300 |
commit | 7c744d00990ea999d27f306f6db5ccb61b1304b2 (patch) | |
tree | 449d6e73cfa8c696ac1b3c44dcea3777f84e5636 /drivers/input | |
parent | e4bb7fee188dab08b7e589fff7616716cdbd5c3b (diff) | |
download | linux-7c744d00990ea999d27f306f6db5ccb61b1304b2.tar.xz |
Input: adc-joystick - fix ordering in adc_joystick_probe()
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.
Acked-by: Artur Rojek <contact@artur-rojek.eu>
Link: https://lore.kernel.org/r/YskFh4NHnlcryMkk@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/joystick/adc-joystick.c | 15 |
1 files 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; } |