From: "Henrik Rydberg" <rydberg@euromail.se>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Nikolai Kondrashov <spbnick@gmail.com>, linux-input@vger.kernel.org
Subject: Re: [PATCH 1/1] HID: add have_special_driver hid module parameter
Date: Tue, 3 Apr 2012 16:46:44 +0200 [thread overview]
Message-ID: <20120403144644.GA16506@polaris.bitmath.org> (raw)
In-Reply-To: <4F78BF82.70903@gmail.com>
Hi Jiri,
> From: Jiri Kosina <jkosina@xxxxxxx>
> Subject: [PATCH] HID: make hid_parse() reentrant
> It is possible to rebind the drivers on HID bus manually from userspace
> (through sysfs bind/unbind facility). This way, we can easily allow drivers to
> claim device IDs even if this doesn't happen automatically through explicit
> hid_have_special_driver[] entry.
> If driver is rebound, hid_parse() sees the HID_STATE_PARSED flag set, and
> doesn't proceed parsing the report descriptor again.
> This might however be unwanted in cases when the newly rebound driver does
> a report descriptor fixup, as it doesn't get parsed again with the replaced
> values.
> Instead of bailing out directly when HID_STAT_PARSED flag is set, throw
> away the old report descriptor stored in hid_device->rdesc, and let the
> whole rdesc parsing be restarted (with ->report_fixup callback of the newly
> rebound driver being called prior to the actual parsing).
> Signed-off-by: Jiri Kosina <jkosina@xxxxxxx>
> ---
> include/linux/hid.h | 12 ++++++++++--
> 1 files changed, 10 insertions(+), 2 deletions(-)
> diff --git a/include/linux/hid.h b/include/linux/hid.h
> index 3a95da6..f771eba 100644
> --- a/include/linux/hid.h
> +++ b/include/linux/hid.h
> @@ -807,8 +807,16 @@ static inline int __must_check hid_parse(struct hid_devic> e *hdev)
> {
> int ret;
>
> - if (hdev->status & HID_STAT_PARSED)
> - return 0;
> + if (hdev->status & HID_STAT_PARSED) {
> + /*
> + * We want to be re-entrant to allow for dynamic driver
> + * rebinding and still allow rdescs to be replaced and
> + * and re-parsed once the driver has been dynamically
> + * rebound
> + */
> + kfree(hdev->rdesc);
> + hdev->status &= ~HID_STAT_PARSED;
> + }
>
> ret = hdev->ll_driver->parse(hdev);
> if (!ret)
It seems an equivalent patch would be to remove HID_STAT_PARSED
altogether, replacing it with something like this:
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 1e68543..456fdbf 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -454,7 +454,6 @@ struct hid_output_fifo {
#define HID_CLAIMED_HIDRAW 4
#define HID_STAT_ADDED 1
-#define HID_STAT_PARSED 2
struct hid_input {
struct list_head list;
@@ -811,16 +810,10 @@ static inline void hid_map_usage_clear(struct hid_input *hidinput,
*/
static inline int __must_check hid_parse(struct hid_device *hdev)
{
- int ret;
+ kfree(hdev->rdesc);
+ hdev->rdesc = NULL;
- if (hdev->status & HID_STAT_PARSED)
- return 0;
-
- ret = hdev->ll_driver->parse(hdev);
- if (!ret)
- hdev->status |= HID_STAT_PARSED;
-
- return ret;
+ return hdev->ll_driver->parse(hdev);
}
which makes me wonder if something will break or be called
unnecessarily often as a result?
I think the main logic problem stems from viewing hid devices as being
on the same level as usb/bt devices. Perhaps report fixups should be
part of the hid_ll_driver layer instead.
Thanks,
Henrik
next prev parent reply other threads:[~2012-04-03 14:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 21:29 [PATCH 1/1] HID: add have_special_driver hid module parameter Nikolai Kondrashov
2012-02-27 14:15 ` Nikolai Kondrashov
2012-02-28 14:30 ` Jiri Kosina
2012-02-28 15:12 ` Nikolai Kondrashov
2012-02-29 21:23 ` Nikolai Kondrashov
2012-03-29 8:00 ` Nikolai Kondrashov
2012-03-30 13:49 ` Jiri Kosina
2012-03-30 15:22 ` Nikolai Kondrashov
2012-03-30 23:03 ` David Herrmann
2012-04-01 19:44 ` Nikolai Kondrashov
2012-04-01 19:49 ` Jiri Kosina
2012-04-01 20:11 ` Nikolai Kondrashov
2012-04-01 20:10 ` David Herrmann
2012-04-01 20:22 ` Nikolai Kondrashov
2012-04-01 19:33 ` Nikolai Kondrashov
2012-04-01 19:46 ` Jiri Kosina
2012-04-01 20:50 ` Nikolai Kondrashov
2012-04-02 23:41 ` Jiri Kosina
2012-04-04 8:27 ` Nikolai Kondrashov
2012-04-08 10:48 ` Nikolai Kondrashov
2012-04-03 14:46 ` Henrik Rydberg [this message]
2012-04-03 15:09 ` Jiri Kosina
2012-04-03 16:37 ` Henrik Rydberg
2012-04-03 17:01 ` Jiri Kosina
2012-04-03 17:11 ` Henrik Rydberg
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=20120403144644.GA16506@polaris.bitmath.org \
--to=rydberg@euromail.se \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=spbnick@gmail.com \
/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.