linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Henrik Rydberg" <rydberg@euromail.se>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Benjamin Tissoires <benjamin.tissoires@gmail.com>,
	Stephane Chatty <chatty@enac.fr>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Henrik Rydberg <rydberg@euromail.se>
Subject: [PATCH 2/5] hid: Parse the device before adding it
Date: Thu, 19 Apr 2012 00:00:54 +0200	[thread overview]
Message-ID: <1334786457-2124-3-git-send-email-rydberg@euromail.se> (raw)
In-Reply-To: <1334786457-2124-1-git-send-email-rydberg@euromail.se>

The hid bus is populated by devices created by the usb and bluetooth
subsystems. The hid device is then broadcast to userland via uevents.
Currently, the parsing of the hid reports is done during probe of
the hid device, after the device has been broadcast. In order to
allow for the report descriptors to influence the device properties,
it is desirable to parse the device _before_ it is broadcast to
userland.

Specific device drivers, in particular those with report fixup
routines, are not affected by this patch.

Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
---
 drivers/hid/hid-core.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index f5a9660..1c4db36 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -662,7 +662,7 @@ int hid_parse_report(struct hid_device *device, __u8 *start,
 		hid_parser_reserved
 	};
 
-	if (device->driver->report_fixup)
+	if (device->driver && device->driver->report_fixup)
 		start = device->driver->report_fixup(device, start, &size);
 
 	device->rdesc = kmemdup(start, size, GFP_KERNEL);
@@ -2093,6 +2093,16 @@ int hid_add_device(struct hid_device *hdev)
             && (hid_ignore(hdev) || (hdev->quirks & HID_QUIRK_IGNORE)))
 		return -ENODEV;
 
+	/*
+	 * Parse generically handled devices early to allow for
+	 * report-defined device groups.
+	 */
+	if (!hid_match_id(hdev, hid_have_special_driver)) {
+		ret = hid_parse(hdev);
+		if (ret)
+			return ret;
+	}
+
 	/* XXX hack, any other cleaner solution after the driver core
 	 * is converted to allow more than 20 bytes as the device name? */
 	dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
-- 
1.7.10


  parent reply	other threads:[~2012-04-18 21:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-18 22:00 [PATCH 0/5] hid: Introduce device groups Henrik Rydberg
2012-04-18 22:00 ` [PATCH 1/5] hid: Add device group to modalias Henrik Rydberg
2012-04-19 10:06   ` Henrik Rydberg
2012-04-18 22:00 ` Henrik Rydberg [this message]
2012-04-18 22:00 ` [PATCH 3/5] hid-multitouch: Prepare driver for device groups Henrik Rydberg
2012-04-18 22:00 ` [PATCH 4/5] hid-multitouch: Switch to " Henrik Rydberg
2012-04-18 22:00 ` [PATCH 5/5] hid-multitouch: Remove remnant quirk handling 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=1334786457-2124-3-git-send-email-rydberg@euromail.se \
    --to=rydberg@euromail.se \
    --cc=benjamin.tissoires@gmail.com \
    --cc=chatty@enac.fr \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jkosina@suse.cz \
    --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).