From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: David Herrmann <dh.herrmann@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>,
"Andrew Duggan" <aduggan@synaptics.com>,
"Dan Carpenter" <dan.carpenter@oracle.com>
Subject: Re: [PATCH] HID: hid-input: allow input_configured callback return errors
Date: Sun, 27 Sep 2015 17:23:28 -0700 [thread overview]
Message-ID: <20150928002328.GB17818@dtor-ws> (raw)
In-Reply-To: <CANq1E4SjLUWinuNzBN7MNSgEQTLsfFK-t-OqGXmnkN1X1bJ0Vg@mail.gmail.com>
Hi David,
On Sat, Sep 26, 2015 at 05:16:12PM +0200, David Herrmann wrote:
> Hi
>
> On Sat, Sep 26, 2015 at 1:14 AM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> > When configuring input device via input_configured callback we may
> > encounter errors (for example input_mt_init_slots() may fail). Instead
> > of continuing with half-initialized input device let's allow driver
> > indicate failures.
> >
> > Signed-off-by: Jaikumar Ganesh <jaikumarg@android.com>
> > Signed-off-by: Arve Hjønnevåg <arve@android.com>
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> > drivers/hid/hid-appleir.c | 4 +++-
> > drivers/hid/hid-elo.c | 4 +++-
> > drivers/hid/hid-input.c | 10 ++++++----
> > drivers/hid/hid-lenovo.c | 4 +++-
> > drivers/hid/hid-logitech-hidpp.c | 4 +++-
> > drivers/hid/hid-magicmouse.c | 8 ++++++--
> > drivers/hid/hid-multitouch.c | 19 ++++++++++++++-----
> > drivers/hid/hid-ntrig.c | 6 ++++--
> > drivers/hid/hid-rmi.c | 11 +++++++----
> > drivers/hid/hid-sony.c | 13 ++++++++++---
> > drivers/hid/hid-uclogic.c | 6 ++++--
> > include/linux/hid.h | 4 ++--
> > 12 files changed, 65 insertions(+), 28 deletions(-)
> >
> > diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> > index 53aeaf6..2ba6bf6 100644
> > --- a/drivers/hid/hid-input.c
> > +++ b/drivers/hid/hid-input.c
> > @@ -1510,8 +1510,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
> > * UGCI) cram a lot of unrelated inputs into the
> > * same interface. */
> > hidinput->report = report;
> > - if (drv->input_configured)
> > - drv->input_configured(hid, hidinput);
> > + if (drv->input_configured &&
> > + drv->input_configured(hid, hidinput))
> > + goto out_cleanup;
> > if (input_register_device(hidinput->input))
> > goto out_cleanup;
> > hidinput = NULL;
> > @@ -1532,8 +1533,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
> > }
> >
> > if (hidinput) {
> > - if (drv->input_configured)
> > - drv->input_configured(hid, hidinput);
> > + if (drv->input_configured &&
> > + drv->input_configured(hid, hidinput))
> > + goto out_cleanup;
> > if (input_register_device(hidinput->input))
> > goto out_cleanup;
> > }
>
> [snip]
>
> > diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> > index 426b2f1..73d7d59 100644
> > --- a/drivers/hid/hid-multitouch.c
> > +++ b/drivers/hid/hid-multitouch.c
> > @@ -725,12 +725,13 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report)
> > mt_sync_frame(td, report->field[0]->hidinput->input);
> > }
> >
> > -static void mt_touch_input_configured(struct hid_device *hdev,
> > +static int mt_touch_input_configured(struct hid_device *hdev,
> > struct hid_input *hi)
> > {
> > struct mt_device *td = hid_get_drvdata(hdev);
> > struct mt_class *cls = &td->mtclass;
> > struct input_dev *input = hi->input;
> > + int ret;
> >
> > if (!td->maxcontacts)
> > td->maxcontacts = MT_DEFAULT_MAXCONTACT;
> > @@ -752,9 +753,12 @@ static void mt_touch_input_configured(struct hid_device *hdev,
> > if (td->is_buttonpad)
> > __set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
> >
> > - input_mt_init_slots(input, td->maxcontacts, td->mt_flags);
> > + ret = input_mt_init_slots(input, td->maxcontacts, td->mt_flags);
> > + if (ret)
> > + return ret;
> >
> > td->mt_flags = 0;
> > + return 0;
> > }
> >
> > static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
> > @@ -930,15 +934,19 @@ static void mt_post_parse(struct mt_device *td)
> > cls->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE;
> > }
> >
> > -static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
> > +static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
> > {
> > struct mt_device *td = hid_get_drvdata(hdev);
> > char *name;
> > const char *suffix = NULL;
> > struct hid_field *field = hi->report->field[0];
> > + int ret = 0;
>
> int ret;
Right.
>
> >
> > - if (hi->report->id == td->mt_report_id)
> > - mt_touch_input_configured(hdev, hi);
> > + if (hi->report->id == td->mt_report_id) {
> > + ret = mt_touch_input_configured(hdev, hi);
> > + if (ret)
> > + return ret;
> > + }
> >
> > /*
> > * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN"
> > @@ -989,6 +997,7 @@ static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
> > hi->input->name = name;
> > }
> > }
> > + return ret;
>
> return 0;
>
> And maybe add an empty line before the final return, just like you did
> with all the other callbacks.
OK.
>
> > }
> >
> > 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;
> >
> > /* 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.
Andrew, can you double check?
Thanks.
--
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: David Herrmann <dh.herrmann@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>,
"Andrew Duggan" <aduggan@synaptics.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: Sun, 27 Sep 2015 17:23:28 -0700 [thread overview]
Message-ID: <20150928002328.GB17818@dtor-ws> (raw)
In-Reply-To: <CANq1E4SjLUWinuNzBN7MNSgEQTLsfFK-t-OqGXmnkN1X1bJ0Vg@mail.gmail.com>
Hi David,
On Sat, Sep 26, 2015 at 05:16:12PM +0200, David Herrmann wrote:
> Hi
>
> On Sat, Sep 26, 2015 at 1:14 AM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> > When configuring input device via input_configured callback we may
> > encounter errors (for example input_mt_init_slots() may fail). Instead
> > of continuing with half-initialized input device let's allow driver
> > indicate failures.
> >
> > Signed-off-by: Jaikumar Ganesh <jaikumarg@android.com>
> > Signed-off-by: Arve Hjønnevåg <arve@android.com>
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > ---
> > drivers/hid/hid-appleir.c | 4 +++-
> > drivers/hid/hid-elo.c | 4 +++-
> > drivers/hid/hid-input.c | 10 ++++++----
> > drivers/hid/hid-lenovo.c | 4 +++-
> > drivers/hid/hid-logitech-hidpp.c | 4 +++-
> > drivers/hid/hid-magicmouse.c | 8 ++++++--
> > drivers/hid/hid-multitouch.c | 19 ++++++++++++++-----
> > drivers/hid/hid-ntrig.c | 6 ++++--
> > drivers/hid/hid-rmi.c | 11 +++++++----
> > drivers/hid/hid-sony.c | 13 ++++++++++---
> > drivers/hid/hid-uclogic.c | 6 ++++--
> > include/linux/hid.h | 4 ++--
> > 12 files changed, 65 insertions(+), 28 deletions(-)
> >
> > diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c
> > index 53aeaf6..2ba6bf6 100644
> > --- a/drivers/hid/hid-input.c
> > +++ b/drivers/hid/hid-input.c
> > @@ -1510,8 +1510,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
> > * UGCI) cram a lot of unrelated inputs into the
> > * same interface. */
> > hidinput->report = report;
> > - if (drv->input_configured)
> > - drv->input_configured(hid, hidinput);
> > + if (drv->input_configured &&
> > + drv->input_configured(hid, hidinput))
> > + goto out_cleanup;
> > if (input_register_device(hidinput->input))
> > goto out_cleanup;
> > hidinput = NULL;
> > @@ -1532,8 +1533,9 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
> > }
> >
> > if (hidinput) {
> > - if (drv->input_configured)
> > - drv->input_configured(hid, hidinput);
> > + if (drv->input_configured &&
> > + drv->input_configured(hid, hidinput))
> > + goto out_cleanup;
> > if (input_register_device(hidinput->input))
> > goto out_cleanup;
> > }
>
> [snip]
>
> > diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
> > index 426b2f1..73d7d59 100644
> > --- a/drivers/hid/hid-multitouch.c
> > +++ b/drivers/hid/hid-multitouch.c
> > @@ -725,12 +725,13 @@ static void mt_touch_report(struct hid_device *hid, struct hid_report *report)
> > mt_sync_frame(td, report->field[0]->hidinput->input);
> > }
> >
> > -static void mt_touch_input_configured(struct hid_device *hdev,
> > +static int mt_touch_input_configured(struct hid_device *hdev,
> > struct hid_input *hi)
> > {
> > struct mt_device *td = hid_get_drvdata(hdev);
> > struct mt_class *cls = &td->mtclass;
> > struct input_dev *input = hi->input;
> > + int ret;
> >
> > if (!td->maxcontacts)
> > td->maxcontacts = MT_DEFAULT_MAXCONTACT;
> > @@ -752,9 +753,12 @@ static void mt_touch_input_configured(struct hid_device *hdev,
> > if (td->is_buttonpad)
> > __set_bit(INPUT_PROP_BUTTONPAD, input->propbit);
> >
> > - input_mt_init_slots(input, td->maxcontacts, td->mt_flags);
> > + ret = input_mt_init_slots(input, td->maxcontacts, td->mt_flags);
> > + if (ret)
> > + return ret;
> >
> > td->mt_flags = 0;
> > + return 0;
> > }
> >
> > static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
> > @@ -930,15 +934,19 @@ static void mt_post_parse(struct mt_device *td)
> > cls->quirks &= ~MT_QUIRK_CONTACT_CNT_ACCURATE;
> > }
> >
> > -static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
> > +static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
> > {
> > struct mt_device *td = hid_get_drvdata(hdev);
> > char *name;
> > const char *suffix = NULL;
> > struct hid_field *field = hi->report->field[0];
> > + int ret = 0;
>
> int ret;
Right.
>
> >
> > - if (hi->report->id == td->mt_report_id)
> > - mt_touch_input_configured(hdev, hi);
> > + if (hi->report->id == td->mt_report_id) {
> > + ret = mt_touch_input_configured(hdev, hi);
> > + if (ret)
> > + return ret;
> > + }
> >
> > /*
> > * some egalax touchscreens have "application == HID_DG_TOUCHSCREEN"
> > @@ -989,6 +997,7 @@ static void mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
> > hi->input->name = name;
> > }
> > }
> > + return ret;
>
> return 0;
>
> And maybe add an empty line before the final return, just like you did
> with all the other callbacks.
OK.
>
> > }
> >
> > 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;
> >
> > /* 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.
Andrew, can you double check?
Thanks.
--
Dmitry
next prev parent reply other threads:[~2015-09-28 0:23 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 [this message]
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
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=20150928002328.GB17818@dtor-ws \
--to=dmitry.torokhov@gmail.com \
--cc=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=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=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.