mirror of https://lore.kernel.org/lkml/
 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
Subject: Re: [PATCH 1/5] hid: Add device group to modalias
Date: Thu, 19 Apr 2012 12:06:45 +0200	[thread overview]
Message-ID: <20120419100645.GA23480@polaris.bitmath.org> (raw)
In-Reply-To: <1334786457-2124-2-git-send-email-rydberg@euromail.se>

On Thu, Apr 19, 2012 at 12:00:53AM +0200, Henrik Rydberg wrote:
> HID devices are only partially presented to userland.  Hotplugged
> devices emit events containing a modalias based on the basic bus,
> vendor and product entities. However, in practise a hid device can
> depend on details such as a single usb interface or a particular item
> in a report descriptor.
> 
> This patch adds a device group to the hid device id, and broadcasts it
> using uevent and the device modalias.  The module alias generation is
> modified to match. As a consequence, a device with a non-zero group
> will be processed by the corresponding group driver instead of by the
> generic hid driver.
> 
> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
> ---

Addition for v2: store_new_id() needs to be modified as well, in order
for the added devices to match the right device group. Something like
the below should suffice.

Henrik

---

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 4845567..3c9bf3e 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -580,6 +576,17 @@ const struct hid_device_id *hid_match_id(struct hid_device *hdev,
 	return NULL;
 }
 
+static int hid_get_driver_group(const struct hid_driver *hdrv)
+{
+	const struct hid_device_id *id;
+	int group = 0;
+
+	for (id = hdrv->id_table; id->bus; id++)
+		group = id->group;
+
+	return group;
+}
+
 static const struct hid_device_id hid_hiddev_list[] = {
 	{ HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS) },
 	{ HID_USB_DEVICE(USB_VENDOR_ID_MGE, USB_DEVICE_ID_MGE_UPS1) },
@@ -977,6 +984,7 @@ static ssize_t store_new_id(struct device_driver *drv, const char *buf,
 		return -ENOMEM;
 
 	dynid->id.bus = bus;
+	dynid->id.group = hid_get_driver_group(hdrv);
 	dynid->id.vendor = vendor;
 	dynid->id.product = product;
 	dynid->id.driver_data = driver_data;

  reply	other threads:[~2012-04-19 10:03 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 [this message]
2012-04-18 22:00 ` [PATCH 2/5] hid: Parse the device before adding it Henrik Rydberg
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=20120419100645.GA23480@polaris.bitmath.org \
    --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

all inboxes | Powered by JetHome®