From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mario Limonciello Date: Tue, 14 Jul 2009 21:00:46 +0000 Subject: Re: [PATCH] Explicitly disable BT radio using rfkill interface on Message-Id: <4A5CF1FE.2050109@dell.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------enig6CA94CB357C32B11CDE82EBC" List-Id: References: <4A4A8B6D.3060509@dell.com> In-Reply-To: <4A4A8B6D.3060509@dell.com> To: linux-hotplug@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6CA94CB357C32B11CDE82EBC Content-Type: multipart/mixed; boundary="------------000108070002080307010004" This is a multi-part message in MIME format. --------------000108070002080307010004 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Kay: Kay Sievers wrote: > On Tue, Jul 14, 2009 at 20:46, Marcel Holtmann wro= te: > =20 > > That looks crazy. What are you trying to solve here? > =20 My apologies. I'll split that up into some more readable for loops. I was just trying to walk through the bus to find the appropriate usb_device to match and return. > We also don't want these weird multiline rules with on match per line, > and the use of properties merged by earlier rules. I complained too > many times about this now. > =20 I'll switch over to one line. I had thought it was more readable as multiline. Since the rule is referring to the parent's information, I wasn't sure that this was doable without importing the properties of the parent's earlier rules. > That whole thing get pretty annoying, it does not seem to be ready to > be shipped with udev.=20 > Please properly fix _and_ test the stuff now. > Your earlier version already broke random keyboards and hubs, because > you obviously did not test it properly. If you don't provide a sane > solution now, I'm going to remove it from udev, and you need to create > your own package. > =20 The utility itself is stable. The previous error with the matching against hubs within docking stations was something I didn't anticipate matching up the chain, indeed my mistake. It was corrected by being more specific on things to match on, which is what I am attempting again with this second rule.=20 Attached is an updated patch. Again, i'm having to rely on earlier rules for parent device information. If there is a better way to do this, can you please advise rather than be rash about removing this utility from udev? There shouldn't be any worry for mismatching devices this time. The new rule looks specifically for Dell Wireless Class Controllers, with a Bluetooth protocol not matching further up the chain.= I broke up the for loops by relying on find_device instead. My code is quite similar to the example that is on the libusb documentation for matching a property: http://libusb.sourceforge.net/doc/examples-code.htm= l I'm not really sure of any way to make it more readable other than adding superfluous spacing and comments as it's a very basic example. Thanks, --=20 Mario Limonciello *Dell | Linux Engineering* mario_limonciello@dell.com --------------000108070002080307010004 Content-Type: text/x-patch; name="resuscitate.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="resuscitate.patch" =3D=3D=3D modified file 'extras/hid2hci/70-hid2hci.rules' --- extras/hid2hci/70-hid2hci.rules 2009-06-26 06:17:23 +0000 +++ extras/hid2hci/70-hid2hci.rules 2009-07-14 20:56:36 +0000 @@ -11,6 +11,11 @@ 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" =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" + ENV{DEVTYPE}!=3D"usb_device", GOTO=3D"hid2hci_end" =20 # Logitech devices =3D=3D=3D modified file 'extras/hid2hci/hid2hci.c' --- extras/hid2hci/hid2hci.c 2009-06-16 17:30:22 +0000 +++ extras/hid2hci/hid2hci.c 2009-07-14 20:56:39 +0000 @@ -271,6 +271,23 @@ return 0; } =20 +static int find_resuscitated_device(struct device_info* devinfo, uint8_t= bInterfaceProtocol) +{ + int i,j,k,l; + + /* Using the base device, attempt to find the child with the + * matching bInterfaceProtocol */ + for (i =3D 0; i < devinfo->dev->num_children; i++) + for (j =3D 0; j < devinfo->dev->children[i]->descriptor.bNumConfigurat= ions; j++) + for (k =3D 0; k < devinfo->dev->children[i]->config[j].bNumInterfaces= ; k++) + for (l =3D 0; l < devinfo->dev->children[i]->config[j].interface[k].= num_altsetting; l++) + if (devinfo->dev->children[i]->config[j].interface[k].altsetting[l]= =2EbInterfaceProtocol =3D=3D bInterfaceProtocol) { + devinfo->dev =3D devinfo->dev->children[i]; + return 1; + } + return 0; +} + static void usage(char* error) { if (error) @@ -289,6 +306,7 @@ "\t-v, --vendor=3D Vendor ID to act upon\n" "\t-p, --product=3D Product ID to act upon\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"); if (error) exit(1); @@ -301,6 +319,7 @@ { "vendor", required_argument, 0, 'v' }, { "product", required_argument, 0, 'p' }, { "method", required_argument, 0, 'm' }, + { "resuscitate",required_argument, 0, 's' }, { 0, 0, 0, 0 } }; =20 @@ -309,8 +328,9 @@ struct device_info dev =3D { NULL, HCI, 0, 0 }; int opt, quiet =3D 0; int (*method)(struct device_info *dev) =3D NULL; + uint8_t resuscitate =3D 0; =20 - while ((opt =3D getopt_long(argc, argv, "+r:v:p:m:qh", main_options, NU= LL)) !=3D -1) { + while ((opt =3D getopt_long(argc, argv, "+s:r:v:p:m:qh", main_options, = NULL)) !=3D -1) { switch (opt) { case 'r': if (optarg && !strcmp(optarg, "hid")) @@ -339,6 +359,9 @@ case 'q': quiet =3D 1; break; + case 's': + sscanf(optarg, "%2hx", (short unsigned int*) &resuscitate); + break; case 'h': usage(NULL); default: @@ -362,6 +385,13 @@ 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); + exit(1); + } + if (!quiet) printf("Attempting to switch device %04x:%04x to %s mode ", dev.vendor, dev.product, dev.mode ? "HID" : "HCI"); --------------000108070002080307010004-- --------------enig6CA94CB357C32B11CDE82EBC 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 iEYEARECAAYFAkpc8f4ACgkQ2CrZjkA73YuqzwCfSVtywjFEXUXC8dNC+qrz+IGj Qj4An2CyC9uAo85Rpowb5N3OSl/lqZbR =lUC1 -----END PGP SIGNATURE----- --------------enig6CA94CB357C32B11CDE82EBC--