From: Mario Limonciello <mario_limonciello@dell.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: [PATCH] Explicitly disable BT radio using rfkill interface on
Date: Tue, 14 Jul 2009 21:00:46 +0000 [thread overview]
Message-ID: <4A5CF1FE.2050109@dell.com> (raw)
In-Reply-To: <4A4A8B6D.3060509@dell.com>
[-- Attachment #1.1: Type: text/plain, Size: 2358 bytes --]
Hi Kay:
Kay Sievers wrote:
> On Tue, Jul 14, 2009 at 20:46, Marcel Holtmann<marcel@holtmann.org> wrote:
>
>
> That looks crazy. What are you trying to solve here?
>
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.
>
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.
> 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.
>
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.
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.html
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,
--
Mario Limonciello
*Dell | Linux Engineering*
mario_limonciello@dell.com
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: resuscitate.patch --]
[-- Type: text/x-patch; name="resuscitate.patch", Size: 3596 bytes --]
=== 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}=="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"
+# 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"
+
ENV{DEVTYPE}!="usb_device", GOTO="hid2hci_end"
# Logitech devices
=== 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;
}
+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 = 0; i < devinfo->dev->num_children; i++)
+ for (j = 0; j < devinfo->dev->children[i]->descriptor.bNumConfigurations; j++)
+ for (k = 0; k < devinfo->dev->children[i]->config[j].bNumInterfaces; k++)
+ for (l = 0; l < devinfo->dev->children[i]->config[j].interface[k].num_altsetting; l++)
+ if (devinfo->dev->children[i]->config[j].interface[k].altsetting[l].bInterfaceProtocol == bInterfaceProtocol) {
+ devinfo->dev = devinfo->dev->children[i];
+ return 1;
+ }
+ return 0;
+}
+
static void usage(char* error)
{
if (error)
@@ -289,6 +306,7 @@
"\t-v, --vendor= Vendor ID to act upon\n"
"\t-p, --product= Product ID to act upon\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");
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 }
};
@@ -309,8 +328,9 @@
struct device_info dev = { NULL, HCI, 0, 0 };
int opt, quiet = 0;
int (*method)(struct device_info *dev) = NULL;
+ uint8_t resuscitate = 0;
- while ((opt = getopt_long(argc, argv, "+r:v:p:m:qh", main_options, NULL)) != -1) {
+ while ((opt = getopt_long(argc, argv, "+s:r:v:p:m:qh", main_options, NULL)) != -1) {
switch (opt) {
case 'r':
if (optarg && !strcmp(optarg, "hid"))
@@ -339,6 +359,9 @@
case 'q':
quiet = 1;
break;
+ case 's':
+ sscanf(optarg, "%2hx", (short unsigned int*) &resuscitate);
+ break;
case 'h':
usage(NULL);
default:
@@ -362,6 +385,13 @@
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);
+ exit(1);
+ }
+
if (!quiet)
printf("Attempting to switch device %04x:%04x to %s mode ",
dev.vendor, dev.product, dev.mode ? "HID" : "HCI");
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 260 bytes --]
next prev parent reply other threads:[~2009-07-14 21:00 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-30 22:02 [PATCH] Explicitly disable BT radio using rfkill interface on Mario Limonciello
2009-06-30 22:26 ` Kay Sievers
2009-07-01 3:53 ` [PATCH] Explicitly disable BT radio using rfkill interface on suspend Mario_Limonciello
2009-07-01 12:06 ` [PATCH] Explicitly disable BT radio using rfkill interface on Marcel Holtmann
2009-07-01 13:13 ` [PATCH] Explicitly disable BT radio using rfkill interface on suspend Mario_Limonciello
2009-07-01 15:03 ` [PATCH] Explicitly disable BT radio using rfkill interface on Marcel Holtmann
2009-07-01 17:12 ` Mario Limonciello
2009-07-01 17:18 ` Matthew Garrett
2009-07-01 22:13 ` Marcel Holtmann
2009-07-01 22:16 ` Matthew Garrett
2009-07-01 22:23 ` Mario Limonciello
2009-07-01 22:49 ` Marcel Holtmann
2009-07-01 22:52 ` Matthew Garrett
2009-07-02 14:02 ` Alan Stern
2009-07-10 14:46 ` Alan Stern
2009-07-14 16:40 ` Mario Limonciello
2009-07-14 16:51 ` Alan Stern
2009-07-14 16:52 ` Kay Sievers
2009-07-14 17:32 ` Mario Limonciello
2009-07-14 18:46 ` Marcel Holtmann
2009-07-14 19:12 ` Kay Sievers
2009-07-14 21:00 ` Mario Limonciello [this message]
2009-07-14 21:20 ` Marcel Holtmann
2009-07-14 21:24 ` Kay Sievers
2009-07-14 22:45 ` Kay Sievers
2009-07-15 2:07 ` Alan Stern
2009-07-15 2:26 ` Kay Sievers
2009-07-15 22:15 ` Mario Limonciello
2009-07-15 22:24 ` Mario Limonciello
2009-07-15 23:27 ` Kay Sievers
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=4A5CF1FE.2050109@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).