From: Andrew Duggan <aduggan@synaptics.com>
To: David Herrmann <dh.herrmann@gmail.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "Jiri Kosina" <jikos@kernel.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Jaikumar Ganesh" <jaikumarg@android.com>,
"Krzysztof Kozlowski" <k.kozlowski@samsung.com>,
"Sebastian Reichel" <sre@kernel.org>,
"James C Boyd" <jcboyd.dev@gmail.com>,
"Karl Relton" <karllinuxtest.relton@ntlworld.com>,
"Olivier Gay" <ogay@logitech.com>,
"Ross Skaliotis" <rskaliotis@gmail.com>,
"Jamie Lentin" <jm@lentin.co.uk>,
"Benjamin Tissoires" <benjamin.tissoires@gmail.com>,
"Andreas Fleig" <andreasfleig@gmail.com>,
"Alexey Khoroshilov" <khoroshilov@ispras.ru>,
"Peter Wu" <peter@lekensteyn.nl>,
"Goffredo Baroncelli" <kreijack@inwind.it>,
"Mathieu Magnaudet" <mathieu.magnaudet@gmail.com>,
"Brent Adam" <brentadamdev@gmail.com>,
"Yang Bo" <linuxsea@163.com>,
"Seth Forshee" <seth.forshee@canonical.com>,
"Dan Carpenter" <dan.carpenter@oracle.com>,
"Frank Praznik" <frank.praznik@oh.rr.com>,
"Simon Wood" <simon@munge>
Subject: Re: [PATCH] HID: hid-input: allow input_configured callback return errors
Date: Mon, 28 Sep 2015 15:22:50 -0700 [thread overview]
Message-ID: <5609BDBA.6030605@synaptics.com> (raw)
In-Reply-To: <CANq1E4SgM7ga9_gLg-Ysi+ki_TKyMogiHcJ5toKZBS+h7Nd8nA@mail.gmail.com>
On 09/28/2015 03:10 AM, David Herrmann wrote:
> Hi
>
> On Mon, Sep 28, 2015 at 2:23 AM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> [...]
>>>> }
>>>>
>>>> static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
>>> [snip]
>>>
>>>> diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
>>>> index 2c14812..33280f3 100644
>>>> --- a/drivers/hid/hid-rmi.c
>>>> +++ b/drivers/hid/hid-rmi.c
>>>> @@ -1173,7 +1173,7 @@ static int rmi_populate(struct hid_device *hdev)
>>>> return 0;
>>>> }
>>>>
>>>> -static void rmi_input_configured(struct hid_device *hdev, struct hid_input *hi)
>>>> +static int rmi_input_configured(struct hid_device *hdev, struct hid_input *hi)
>>>> {
>>>> struct rmi_data *data = hid_get_drvdata(hdev);
>>>> struct input_dev *input = hi->input;
>>>> @@ -1185,10 +1185,10 @@ static void rmi_input_configured(struct hid_device *hdev, struct hid_input *hi)
>>>> hid_dbg(hdev, "Opening low level driver\n");
>>>> ret = hid_hw_open(hdev);
>>>> if (ret)
>>>> - return;
>>>> + return ret;
>>>>
>>>> if (!(data->device_flags & RMI_DEVICE))
>>>> - return;
>>>> + return -ENXIO;
We should return 0 here. Otherwise, this will break certain keyboards on
composite USB devices which share a VID and PID with our touchpad. If
the RMI_DEVICE flag is not set then hid-rmi will pass those reports onto
hid-input for processing.
>>>> /* Allow incoming hid reports */
>>>> hid_device_io_start(hdev);
>>>> @@ -1228,7 +1228,9 @@ static void rmi_input_configured(struct hid_device *hdev, struct hid_input *hi)
>>>> input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 0x0f, 0, 0);
>>>> input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 0x0f, 0, 0);
>>>>
>>>> - input_mt_init_slots(input, data->max_fingers, INPUT_MT_POINTER);
>>>> + ret = input_mt_init_slots(input, data->max_fingers, INPUT_MT_POINTER);
>>>> + if (ret < 0)
>>>> + goto exit;
>>>>
>>>> if (data->button_count) {
>>>> __set_bit(EV_KEY, input->evbit);
>>>> @@ -1244,6 +1246,7 @@ static void rmi_input_configured(struct hid_device *hdev, struct hid_input *hi)
>>>> exit:
>>>> hid_device_io_stop(hdev);
>>>> hid_hw_close(hdev);
>>>> + return ret;
>>> rmi_probe() has an explicit comment that it *wants* hid_probe() to
>>> continue on failure, to make sure hidraw is loaded. Not sure what to
>>> make with that, but please either remove the comment in rmi_probe() or
>>> make sure to always return 0 from rmi_input_configured().
>> I think that comment is erroneous since the fact that we could not
>> attach hidinput interface should not affect hidraw in any shape or form.
> The comment might indeed be correct. If rmi_input_configured() failed,
> probing is continued, but the device-internal state might be
> different. rmi_probe() checks that, and explicitly continues device
> probing in that case (if it didn't, the device would indeed be
> rejected).
>
> Sorry for the confusion. Your changes to rmi do look correct.
I will fix the comment, it does incorrectly imply that returning an
error from rmi_probe() would disconnect hidraw. It is also hard to
understand without the context of the previous version. If you look at
the change (daebdd7) it was the call to hid_hw_stop() which disconnected
hidraw and not the return code, if rmi_populate() can't find F11 on the
device.
Otherwise, the changes to rmi look correct.
Andrew
WARNING: multiple messages have this Message-ID (diff)
From: Andrew Duggan <aduggan@synaptics.com>
To: David Herrmann <dh.herrmann@gmail.com>,
Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "Jiri Kosina" <jikos@kernel.org>,
"Arve Hjønnevåg" <arve@android.com>,
"Jaikumar Ganesh" <jaikumarg@android.com>,
"Krzysztof Kozlowski" <k.kozlowski@samsung.com>,
"Sebastian Reichel" <sre@kernel.org>,
"James C Boyd" <jcboyd.dev@gmail.com>,
"Karl Relton" <karllinuxtest.relton@ntlworld.com>,
"Olivier Gay" <ogay@logitech.com>,
"Ross Skaliotis" <rskaliotis@gmail.com>,
"Jamie Lentin" <jm@lentin.co.uk>,
"Benjamin Tissoires" <benjamin.tissoires@gmail.com>,
"Andreas Fleig" <andreasfleig@gmail.com>,
"Alexey Khoroshilov" <khoroshilov@ispras.ru>,
"Peter Wu" <peter@lekensteyn.nl>,
"Goffredo Baroncelli" <kreijack@inwind.it>,
"Mathieu Magnaudet" <mathieu.magnaudet@gmail.com>,
"Brent Adam" <brentadamdev@gmail.com>,
"Yang Bo" <linuxsea@163.com>,
"Seth Forshee" <seth.forshee@canonical.com>,
"Dan Carpenter" <dan.carpenter@oracle.com>,
"Frank Praznik" <frank.praznik@oh.rr.com>,
"Simon Wood" <simon@mungewell.org>, "Antonio Ospite" <ao2@ao2.it>,
"Nikolai Kondrashov" <Nikolai.Kondrashov@redhat.com>,
"JD Cole" <jd@jdc.me>,
"open list:HID CORE LAYER" <linux-input@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] HID: hid-input: allow input_configured callback return errors
Date: Mon, 28 Sep 2015 15:22:50 -0700 [thread overview]
Message-ID: <5609BDBA.6030605@synaptics.com> (raw)
In-Reply-To: <CANq1E4SgM7ga9_gLg-Ysi+ki_TKyMogiHcJ5toKZBS+h7Nd8nA@mail.gmail.com>
On 09/28/2015 03:10 AM, David Herrmann wrote:
> Hi
>
> On Mon, Sep 28, 2015 at 2:23 AM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> [...]
>>>> }
>>>>
>>>> static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
>>> [snip]
>>>
>>>> diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c
>>>> index 2c14812..33280f3 100644
>>>> --- a/drivers/hid/hid-rmi.c
>>>> +++ b/drivers/hid/hid-rmi.c
>>>> @@ -1173,7 +1173,7 @@ static int rmi_populate(struct hid_device *hdev)
>>>> return 0;
>>>> }
>>>>
>>>> -static void rmi_input_configured(struct hid_device *hdev, struct hid_input *hi)
>>>> +static int rmi_input_configured(struct hid_device *hdev, struct hid_input *hi)
>>>> {
>>>> struct rmi_data *data = hid_get_drvdata(hdev);
>>>> struct input_dev *input = hi->input;
>>>> @@ -1185,10 +1185,10 @@ static void rmi_input_configured(struct hid_device *hdev, struct hid_input *hi)
>>>> hid_dbg(hdev, "Opening low level driver\n");
>>>> ret = hid_hw_open(hdev);
>>>> if (ret)
>>>> - return;
>>>> + return ret;
>>>>
>>>> if (!(data->device_flags & RMI_DEVICE))
>>>> - return;
>>>> + return -ENXIO;
We should return 0 here. Otherwise, this will break certain keyboards on
composite USB devices which share a VID and PID with our touchpad. If
the RMI_DEVICE flag is not set then hid-rmi will pass those reports onto
hid-input for processing.
>>>> /* Allow incoming hid reports */
>>>> hid_device_io_start(hdev);
>>>> @@ -1228,7 +1228,9 @@ static void rmi_input_configured(struct hid_device *hdev, struct hid_input *hi)
>>>> input_set_abs_params(input, ABS_MT_TOUCH_MAJOR, 0, 0x0f, 0, 0);
>>>> input_set_abs_params(input, ABS_MT_TOUCH_MINOR, 0, 0x0f, 0, 0);
>>>>
>>>> - input_mt_init_slots(input, data->max_fingers, INPUT_MT_POINTER);
>>>> + ret = input_mt_init_slots(input, data->max_fingers, INPUT_MT_POINTER);
>>>> + if (ret < 0)
>>>> + goto exit;
>>>>
>>>> if (data->button_count) {
>>>> __set_bit(EV_KEY, input->evbit);
>>>> @@ -1244,6 +1246,7 @@ static void rmi_input_configured(struct hid_device *hdev, struct hid_input *hi)
>>>> exit:
>>>> hid_device_io_stop(hdev);
>>>> hid_hw_close(hdev);
>>>> + return ret;
>>> rmi_probe() has an explicit comment that it *wants* hid_probe() to
>>> continue on failure, to make sure hidraw is loaded. Not sure what to
>>> make with that, but please either remove the comment in rmi_probe() or
>>> make sure to always return 0 from rmi_input_configured().
>> I think that comment is erroneous since the fact that we could not
>> attach hidinput interface should not affect hidraw in any shape or form.
> The comment might indeed be correct. If rmi_input_configured() failed,
> probing is continued, but the device-internal state might be
> different. rmi_probe() checks that, and explicitly continues device
> probing in that case (if it didn't, the device would indeed be
> rejected).
>
> Sorry for the confusion. Your changes to rmi do look correct.
I will fix the comment, it does incorrectly imply that returning an
error from rmi_probe() would disconnect hidraw. It is also hard to
understand without the context of the previous version. If you look at
the change (daebdd7) it was the call to hid_hw_stop() which disconnected
hidraw and not the return code, if rmi_populate() can't find F11 on the
device.
Otherwise, the changes to rmi look correct.
Andrew
next prev parent reply other threads:[~2015-09-28 22:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-25 23:14 [PATCH] HID: hid-input: allow input_configured callback return errors Dmitry Torokhov
2015-09-25 23:14 ` Dmitry Torokhov
2015-09-26 15:16 ` David Herrmann
2015-09-26 15:16 ` David Herrmann
2015-09-28 0:23 ` Dmitry Torokhov
2015-09-28 0:23 ` Dmitry Torokhov
2015-09-28 10:10 ` David Herrmann
2015-09-28 10:10 ` David Herrmann
2015-09-28 22:22 ` Andrew Duggan [this message]
2015-09-28 22:22 ` Andrew Duggan
2015-09-26 17:48 ` Nikolai Kondrashov
2015-09-26 17:48 ` Nikolai Kondrashov
2015-09-29 22:52 ` [PATCH v2] " Dmitry Torokhov
2015-09-29 22:52 ` Dmitry Torokhov
2015-09-30 8:09 ` Jiri Kosina
2015-09-30 8:09 ` Jiri Kosina
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=5609BDBA.6030605@synaptics.com \
--to=aduggan@synaptics.com \
--cc=andreasfleig@gmail.com \
--cc=arve@android.com \
--cc=benjamin.tissoires@gmail.com \
--cc=brentadamdev@gmail.com \
--cc=dan.carpenter@oracle.com \
--cc=dh.herrmann@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=frank.praznik@oh.rr.com \
--cc=jaikumarg@android.com \
--cc=jcboyd.dev@gmail.com \
--cc=jikos@kernel.org \
--cc=jm@lentin.co.uk \
--cc=k.kozlowski@samsung.com \
--cc=karllinuxtest.relton@ntlworld.com \
--cc=khoroshilov@ispras.ru \
--cc=kreijack@inwind.it \
--cc=linuxsea@163.com \
--cc=mathieu.magnaudet@gmail.com \
--cc=ogay@logitech.com \
--cc=peter@lekensteyn.nl \
--cc=rskaliotis@gmail.com \
--cc=seth.forshee@canonical.com \
--cc=simon@munge \
--cc=sre@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 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.