From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mario Limonciello Date: Tue, 14 Jul 2009 17:32:15 +0000 Subject: Re: [PATCH] Explicitly disable BT radio using rfkill interface on Message-Id: <4A5CC11F.7020702@dell.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------enigD9D750312E142F1D9DA4719A" 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) --------------enigD9D750312E142F1D9DA4719A Content-Type: multipart/mixed; boundary="------------060701030407040609000500" This is a multi-part message in MIME format. --------------060701030407040609000500 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Kay: Kay Sievers wrote: > > What the action you want to take at removal? You can set > ENV{REMOVE_CMD}=3D and it will be passed to RUN+=3D for that exact devi= ce > when it goes away. > > You can also just store any other custom property in the udev > database, and it will be there on remove. > =20 Thanks for the recommendation on ENV{REMOVE_CMD}. With some minor modifications to my old patch, I've got it working using ENV{REMOVE_CMD} now reliably post suspend. Although rewalking the child devices to find the right one to prod might seem tedious, it should be more future-proof in case later hardware ends up changing. Would you mind reviewing the attached patch for submission to udev then? Thanks, --=20 Mario Limonciello *Dell | Linux Engineering* mario_limonciello@dell.com --------------060701030407040609000500 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 17:25:17 +0000 @@ -11,6 +11,17 @@ 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 +# Well, unfortunately the only event we see is the BT device disappearin= g, so +# we have to run with that and chase down the mouse device on USB bus as= a child. +ATTR{bDeviceClass}=3D=3D"e0", \ +ATTR{bDeviceSubClass}=3D=3D"01", \ +ATTR{bDeviceProtocol}=3D=3D"01", \ +ATTR{idVendor}=3D=3D"413c", \ +ATTR{bmAttributes}=3D=3D"e0", \ +IMPORT{parent}=3D"ID_*", \ +ENV{REMOVE_CMD}=3D"hid2hci --method dell -v $env{ID_VENDOR_ID} -p $env{I= D_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 17:20:01 +0000 @@ -271,6 +271,28 @@ return 0; } =20 +static struct usb_device* find_resuscitated_device(uint16_t base_vendor,= uint16_t base_product, uint8_t bInterfaceProtocol) +{ + struct usb_bus *bus; + struct usb_device *dev; + int i,j,k,l; + + usb_find_busses(); + usb_find_devices(); + + 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 base_vendor && + dev->descriptor.idProduct =3D=3D base_product) + for (i =3D 0; i < dev->num_children; i++) + for (j =3D 0; j < dev->children[i]->descriptor.bNumConfigurations; = j++) + for (k =3D 0; k < dev->children[i]->config[j].bNumInterfaces; k++)= + for (l =3D 0; l < dev->children[i]->config[j].interface[k].num_al= tsetting; l++) + if (dev->children[i]->config[j].interface[k].altsetting[l].bInte= rfaceProtocol =3D=3D bInterfaceProtocol) + return dev->children[i]; + return NULL; +} + static void usage(char* error) { if (error) @@ -289,6 +311,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 +324,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 +333,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 +364,9 @@ case 'q': quiet =3D 1; break; + case 's': + sscanf(optarg, "%2hx", (short unsigned int*) &resuscitate); + break; case 'h': usage(NULL); default: @@ -355,7 +383,16 @@ =20 usb_init(); =20 - if (!find_device(&dev)) { + if (resuscitate) { + dev.dev =3D find_resuscitated_device(dev.vendor, dev.product, resuscit= ate); + if (!quiet && !dev.dev) { + fprintf(stderr, "Device %04x:%04x was unable to resucitate any child = devices.\n",dev.vendor,dev.product); + exit(1); + } + dev.vendor =3D dev.dev->descriptor.idVendor; + dev.product =3D dev.dev->descriptor.idProduct; + } + else if (!find_device(&dev)) { if (!quiet) fprintf(stderr, "Device %04x:%04x not found on USB bus.\n", dev.vendor, dev.product); --------------060701030407040609000500-- --------------enigD9D750312E142F1D9DA4719A 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 iEYEARECAAYFAkpcwR8ACgkQ2CrZjkA73YvaCACbBGxdYq15w/4mPgCYMh5HqbR1 cRwAnRzqjSyRRpiOUoPqZvMk5+yYh97q =4LBk -----END PGP SIGNATURE----- --------------enigD9D750312E142F1D9DA4719A--