From: Mario Limonciello <mario_limonciello@dell.com>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH 2/2] Use busnum/devnum rather than vid/pid for hid2hci
Date: Thu, 16 Jul 2009 21:37:47 +0000 [thread overview]
Message-ID: <4A5F9DAB.1040404@dell.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 515 bytes --]
Hi:
This is the second patch following up to the thread titled "Explicitly
disable BT radio using rfkill interface on suspend". It switches the
hid2hci utility to using the USB bus and device numbers rather than
vendor and product ID combinations.
Note that the S3 recovery rule unfortunately still does need to rely on
an environment variable set by other rules because it is using the
parent's device number.
Regards
--
Mario Limonciello
*Dell | Linux Engineering*
mario_limonciello@dell.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: bus_dev_num.patch --]
[-- Type: text/x-patch; name="bus_dev_num.patch", Size: 6796 bytes --]
=== modified file 'extras/hid2hci/70-hid2hci.rules'
--- extras/hid2hci/70-hid2hci.rules 2009-07-16 17:27:14 +0000
+++ extras/hid2hci/70-hid2hci.rules 2009-07-16 20:38:08 +0000
@@ -9,22 +9,22 @@
#
# Known supported devices: 413c:8154, 413c:8158, 413c:8162
ATTR{bInterfaceClass}=="03", ATTR{bInterfaceSubClass}=="01", ATTR{bInterfaceProtocol}=="02", ATTRS{bDeviceClass}=="00", ATTRS{idVendor}=="413c", ATTRS{bmAttributes}=="e0", \
- RUN+="hid2hci --method dell -v $attr{idVendor} -p $attr{idProduct} --mode hci"
+ RUN+="hid2hci --method dell -b $attr{busnum} -d $attr{devnum} --mode hci"
# When a Dell device recovers from S3, the mouse child needs to be repoked
# Unfortunately the only event seen is the BT device disappearing, so the mouse
# device needs to be chased down on the USB bus.
-ATTR{bDeviceClass}=="e0", ATTR{bDeviceSubClass}=="01", ATTR{bDeviceProtocol}=="01", ATTR{idVendor}=="413c", ATTR{bmAttributes}=="e0", IMPORT{parent}="ID_*", ENV{REMOVE_CMD}="hid2hci --method dell -v $env{ID_VENDOR_ID} -p $env{ID_MODEL_ID} --mode hci -s 02"
+ATTR{bDeviceClass}=="e0", ATTR{bDeviceSubClass}=="01", ATTR{bDeviceProtocol}=="01", ATTR{idVendor}=="413c", ATTR{bmAttributes}=="e0", IMPORT{parent}="DEVNUM", ENV{REMOVE_CMD}="hid2hci --method dell -b $attr{busnum} -d $env{DEVNUM} --mode hci -s 02"
ENV{DEVTYPE}!="usb_device", GOTO="hid2hci_end"
# Logitech devices
-ATTR{idVendor}=="046d", ATTR{idProduct}=="c70[345abce]", RUN+="hid2hci --method logitech -v $attr{idVendor} -p $attr{idProduct} --mode hci"
-ATTR{idVendor}=="046d", ATTR{idProduct}=="c71[34bc]", RUN+="hid2hci --method logitech -v $attr{idVendor} -p $attr{idProduct} --mode hci"
+ATTR{idVendor}=="046d", ATTR{idProduct}=="c70[345abce]", RUN+="hid2hci --method logitech -b $attr{busnum} -d $attr{devnum} --mode hci"
+ATTR{idVendor}=="046d", ATTR{idProduct}=="c71[34bc]", RUN+="hid2hci --method logitech -b $attr{busnum} -d $attr{devnum} --mode hci"
# CSR devices (in HID mode)
-ATTR{idVendor}=="0a12", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -v $attr{idVendor} -p $attr{idProduct} --mode hci"
-ATTR{idVendor}=="0458", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -v $attr{idVendor} -p $attr{idProduct} --mode hci"
-ATTR{idVendor}=="05ac", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -v $attr{idVendor} -p $attr{idProduct} --mode hci"
+ATTR{idVendor}=="0a12", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -b $attr{busnum} -d $attr{devnum} --mode hci"
+ATTR{idVendor}=="0458", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -b $attr{busnum} -d $attr{devnum} --mode hci"
+ATTR{idVendor}=="05ac", ATTR{idProduct}=="1000", RUN+="hid2hci --method csr -b $attr{busnum} -d $attr{devnum} --mode hci"
LABEL="hid2hci_end"
=== modified file 'extras/hid2hci/hid2hci.c'
--- extras/hid2hci/hid2hci.c 2009-07-16 17:27:14 +0000
+++ extras/hid2hci/hid2hci.c 2009-07-16 20:38:10 +0000
@@ -90,8 +90,8 @@
struct device_info {
struct usb_device *dev;
int mode;
- uint16_t vendor;
- uint16_t product;
+ int devnum;
+ int dirname;
};
static int switch_csr(struct device_info *devinfo)
@@ -261,13 +261,12 @@
usb_find_devices();
for (bus = usb_get_busses(); bus; bus = bus->next)
- for (dev = bus->devices; dev; dev = dev->next) {
- if (dev->descriptor.idVendor == devinfo->vendor &&
- dev->descriptor.idProduct == devinfo->product) {
- devinfo->dev=dev;
- return 1;
- }
- }
+ if (strtol(bus->dirname, NULL, 10) == devinfo->dirname)
+ for (dev = bus->devices; dev; dev = dev->next)
+ if (dev->devnum == devinfo->devnum) {
+ devinfo->dev=dev;
+ return 1;
+ }
return 0;
}
@@ -316,8 +315,8 @@
"\t-h, --help Display help\n"
"\t-q, --quiet Don't display any messages\n"
"\t-r, --mode= Mode to switch to [hid, hci]\n"
- "\t-v, --vendor= Vendor ID to act upon\n"
- "\t-p, --product= Product ID to act upon\n"
+ "\t-b, --busnum= USB Bus number to operate on\n"
+ "\t-d, --devnum= USB Device number to operate on\n"
"\t-m, --method= Method to use to switch [csr, logitech, dell]\n"
"\t-s, --resuscitate= Find the child device with this bInterfaceProtocol to run on \n"
"\n");
@@ -329,8 +328,8 @@
{ "help", no_argument, 0, 'h' },
{ "quiet", no_argument, 0, 'q' },
{ "mode", required_argument, 0, 'r' },
- { "vendor", required_argument, 0, 'v' },
- { "product", required_argument, 0, 'p' },
+ { "busnum", required_argument, 0, 'b' },
+ { "devnum", required_argument, 0, 'd' },
{ "method", required_argument, 0, 'm' },
{ "resuscitate",required_argument, 0, 's' },
{ 0, 0, 0, 0 }
@@ -343,7 +342,7 @@
int (*method)(struct device_info *dev) = NULL;
uint8_t resuscitate = 0;
- while ((opt = getopt_long(argc, argv, "+s:r:v:p:m:qh", main_options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "+s:r:b:d:m:qh", main_options, NULL)) != -1) {
switch (opt) {
case 'r':
if (optarg && !strcmp(optarg, "hid"))
@@ -353,11 +352,11 @@
else
usage("ERROR: Undefined radio mode\n");
break;
- case 'v':
- sscanf(optarg, "%4hx", &dev.vendor);
+ case 'd':
+ sscanf(optarg, "%d", &dev.devnum);
break;
- case 'p':
- sscanf(optarg, "%4hx", &dev.product);
+ case 'b':
+ sscanf(optarg, "%d", &dev.dirname);
break;
case 'm':
if (optarg && !strcmp(optarg, "csr"))
@@ -382,8 +381,8 @@
}
}
- if (!quiet && (!dev.vendor || !dev.product || !method))
- usage("ERROR: Vendor ID, Product ID, and Switching Method must all be defined.\n");
+ if (!quiet && (!dev.dirname || !dev.devnum || !method))
+ usage("ERROR: USB Bus number, USB Device number, and Switching Method must all be defined.\n");
argc -= optind;
argv += optind;
@@ -393,21 +392,21 @@
if (!find_device(&dev)) {
if (!quiet)
- fprintf(stderr, "Device %04x:%04x not found on USB bus.\n",
- dev.vendor, dev.product);
+ fprintf(stderr, "Bus %03d Device %03d not found.\n",
+ dev.dirname, dev.devnum);
exit(1);
}
if (resuscitate && !find_resuscitated_device(&dev, resuscitate)) {
if (!quiet)
- fprintf(stderr, "Device %04x:%04x was unable to resucitate any child devices.\n",
- dev.vendor,dev.product);
+ fprintf(stderr, "Bus %03d Device %03d was unable to resucitate any child devices.\n",
+ dev.dirname,dev.devnum);
exit(1);
}
if (!quiet)
- printf("Attempting to switch device %04x:%04x to %s mode ",
- dev.vendor, dev.product, dev.mode ? "HID" : "HCI");
+ printf("Attempting to switch device Bus %03d Device %03d to %s mode ",
+ dev.dirname, dev.devnum, dev.mode ? "HID" : "HCI");
fflush(stdout);
if (method(&dev) < 0 && !quiet)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
reply other threads:[~2009-07-16 21:37 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=4A5F9DAB.1040404@dell.com \
--to=mario_limonciello@dell.com \
--cc=linux-hotplug@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).