From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mario Limonciello Date: Thu, 16 Jul 2009 21:37:47 +0000 Subject: [PATCH 2/2] Use busnum/devnum rather than vid/pid for hid2hci Message-Id: <4A5F9DAB.1040404@dell.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------enig989A9A0797904204EF908820" List-Id: To: linux-hotplug@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig989A9A0797904204EF908820 Content-Type: multipart/mixed; boundary="------------060309030504050101030505" This is a multi-part message in MIME format. --------------060309030504050101030505 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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 --=20 Mario Limonciello *Dell | Linux Engineering* mario_limonciello@dell.com --------------060309030504050101030505 Content-Type: text/x-patch; name="bus_dev_num.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="bus_dev_num.patch" =3D=3D=3D 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}=3D=3D"03", ATTR{bInterfaceSubClass}=3D=3D"01", ATT= R{bInterfaceProtocol}=3D=3D"02", ATTRS{bDeviceClass}=3D=3D"00", ATTRS{idV= endor}=3D=3D"413c", ATTRS{bmAttributes}=3D=3D"e0", \ - RUN+=3D"hid2hci --method dell -v $attr{idVendor} -p $attr{idProduct}= --mode hci" + RUN+=3D"hid2hci --method dell -b $attr{busnum} -d $attr{devnum} --mo= de hci" =20 # When a Dell device recovers from S3, the mouse child needs to be repok= ed # Unfortunately the only event seen is the BT device disappearing, so th= e mouse # device needs to be chased down on the USB bus. -ATTR{bDeviceClass}=3D=3D"e0", ATTR{bDeviceSubClass}=3D=3D"01", ATTR{bDev= iceProtocol}=3D=3D"01", ATTR{idVendor}=3D=3D"413c", ATTR{bmAttributes}=3D= =3D"e0", IMPORT{parent}=3D"ID_*", ENV{REMOVE_CMD}=3D"hid2hci --method del= l -v $env{ID_VENDOR_ID} -p $env{ID_MODEL_ID} --mode hci -s 02" +ATTR{bDeviceClass}=3D=3D"e0", ATTR{bDeviceSubClass}=3D=3D"01", ATTR{bDev= iceProtocol}=3D=3D"01", ATTR{idVendor}=3D=3D"413c", ATTR{bmAttributes}=3D= =3D"e0", IMPORT{parent}=3D"DEVNUM", ENV{REMOVE_CMD}=3D"hid2hci --method d= ell -b $attr{busnum} -d $env{DEVNUM} --mode hci -s 02" =20 ENV{DEVTYPE}!=3D"usb_device", GOTO=3D"hid2hci_end" =20 # Logitech devices -ATTR{idVendor}=3D=3D"046d", ATTR{idProduct}=3D=3D"c70[345abce]", RUN+=3D= "hid2hci --method logitech -v $attr{idVendor} -p $attr{idProduct} --mode = hci" -ATTR{idVendor}=3D=3D"046d", ATTR{idProduct}=3D=3D"c71[34bc]", RUN+=3D"hi= d2hci --method logitech -v $attr{idVendor} -p $attr{idProduct} --mode hci= " +ATTR{idVendor}=3D=3D"046d", ATTR{idProduct}=3D=3D"c70[345abce]", RUN+=3D= "hid2hci --method logitech -b $attr{busnum} -d $attr{devnum} --mode hci" +ATTR{idVendor}=3D=3D"046d", ATTR{idProduct}=3D=3D"c71[34bc]", RUN+=3D"hi= d2hci --method logitech -b $attr{busnum} -d $attr{devnum} --mode hci" =20 # CSR devices (in HID mode) -ATTR{idVendor}=3D=3D"0a12", ATTR{idProduct}=3D=3D"1000", RUN+=3D"hid2hci= --method csr -v $attr{idVendor} -p $attr{idProduct} --mode hci" -ATTR{idVendor}=3D=3D"0458", ATTR{idProduct}=3D=3D"1000", RUN+=3D"hid2hci= --method csr -v $attr{idVendor} -p $attr{idProduct} --mode hci" -ATTR{idVendor}=3D=3D"05ac", ATTR{idProduct}=3D=3D"1000", RUN+=3D"hid2hci= --method csr -v $attr{idVendor} -p $attr{idProduct} --mode hci" +ATTR{idVendor}=3D=3D"0a12", ATTR{idProduct}=3D=3D"1000", RUN+=3D"hid2hci= --method csr -b $attr{busnum} -d $attr{devnum} --mode hci" +ATTR{idVendor}=3D=3D"0458", ATTR{idProduct}=3D=3D"1000", RUN+=3D"hid2hci= --method csr -b $attr{busnum} -d $attr{devnum} --mode hci" +ATTR{idVendor}=3D=3D"05ac", ATTR{idProduct}=3D=3D"1000", RUN+=3D"hid2hci= --method csr -b $attr{busnum} -d $attr{devnum} --mode hci" =20 LABEL=3D"hid2hci_end" =3D=3D=3D 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; }; =20 static int switch_csr(struct device_info *devinfo) @@ -261,13 +261,12 @@ usb_find_devices(); =20 for (bus =3D usb_get_busses(); bus; bus =3D bus->next) - for (dev =3D bus->devices; dev; dev =3D dev->next) { - if (dev->descriptor.idVendor =3D=3D devinfo->vendor && - dev->descriptor.idProduct =3D=3D devinfo->product) { - devinfo->dev=3Ddev; - return 1; - } - } + if (strtol(bus->dirname, NULL, 10) =3D=3D devinfo->dirname) + for (dev =3D bus->devices; dev; dev =3D dev->next) + if (dev->devnum =3D=3D devinfo->devnum) { + devinfo->dev=3Ddev; + return 1; + } return 0; } =20 @@ -316,8 +315,8 @@ "\t-h, --help Display help\n" "\t-q, --quiet Don't display any messages\n" "\t-r, --mode=3D Mode to switch to [hid, hci]\n" - "\t-v, --vendor=3D Vendor ID to act upon\n" - "\t-p, --product=3D Product ID to act upon\n" + "\t-b, --busnum=3D USB Bus number to operate on\n" + "\t-d, --devnum=3D USB Device number to operate on\n" "\t-m, --method=3D Method to use to switch [csr, logitech, dell= ]\n" "\t-s, --resuscitate=3D Find the child device with this bInterfacePr= otocol 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) =3D NULL; uint8_t resuscitate =3D 0; =20 - while ((opt =3D getopt_long(argc, argv, "+s:r:v:p:m:qh", main_options, = NULL)) !=3D -1) { + while ((opt =3D getopt_long(argc, argv, "+s:r:b:d:m:qh", main_options, = NULL)) !=3D -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 @@ } } =20 - 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"); =20 argc -=3D optind; argv +=3D optind; @@ -393,21 +392,21 @@ =20 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); } =20 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 ch= ild devices.\n", + dev.dirname,dev.devnum); exit(1); } =20 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); =20 if (method(&dev) < 0 && !quiet) --------------060309030504050101030505-- --------------enig989A9A0797904204EF908820 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkpfnasACgkQ2CrZjkA73YsRuACdG3I78H+yo31fpT478Sl9CfE4 RcsAnRZLdunt/ni13a26FK3i70Vs19iL =Newn -----END PGP SIGNATURE----- --------------enig989A9A0797904204EF908820--