From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mario Limonciello Date: Thu, 06 Aug 2009 22:03:52 +0000 Subject: Re: [PATCH 2/2] hid2hci: when recovering from S3 use parent devpath Message-Id: <4A7B5348.10902@dell.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------enig2920D8FCA3C8A9C503256B20" List-Id: References: <4A6E19FF.5070207@dell.com> In-Reply-To: <4A6E19FF.5070207@dell.com> To: linux-hotplug@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig2920D8FCA3C8A9C503256B20 Content-Type: multipart/mixed; boundary="------------060309090005000102040108" This is a multi-part message in MIME format. --------------060309090005000102040108 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Kay: Kay Sievers wrote: > On Fri, Jul 31, 2009 at 21:35, Mario Limonciello wrote: > =20 > > I guess, we can get rid of all these hacks and the search code, by > tagging the mouse device we need to find, with: > ..., ENV{HID2HCI_SWITCH}=3D"1", RUN+=3D"hid2hci --method=3Ddell --devpa= th=3D%p" > > and for the bluetooth device we just let it trigger the > tagged mouse device when it goes away, with: > ..., ENV{REMOVE_CMD}=3D"/sbin/udevadm trigger --action=3Dchange --subsy= stem-match=3Dusb --property-match=3DHID2HCI_SWITCH=3D1" > > That way the disappearing bluetooth device would just cause > a "change" event at the mouse device, which would trigger > the original rule again. > It would not need any further search logic, and the resume case > would run the same rules as the plug-in case. > > =20 Thanks for the suggestion! I've cleaned up per this advice and am attaching a new patch. --=20 Mario Limonciello *Dell | Linux Engineering* mario_limonciello@dell.com --------------060309090005000102040108 Content-Type: text/x-patch; name="remove_sibling.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="remove_sibling.diff" =3D=3D=3D modified file 'extras/hid2hci/70-hid2hci.rules' --- extras/hid2hci/70-hid2hci.rules 2009-07-24 16:06:22 +0000 +++ extras/hid2hci/70-hid2hci.rules 2009-08-06 11:45:36 +0000 @@ -1,6 +1,6 @@ # do not edit this file, it will be overwritten on update =20 -ACTION!=3D"add", GOTO=3D"hid2hci_end" +ACTION!=3D"add|change", GOTO=3D"hid2hci_end" SUBSYSTEM!=3D"usb", GOTO=3D"hid2hci_end" =20 # Variety of Dell Bluetooth devices - match on a mouse device that is @@ -8,7 +8,7 @@ # 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{idVendor}=3D=3D"413c", ATTRS{bmAt= tributes}=3D=3D"e0", \ - RUN+=3D"hid2hci --method=3Ddell --devpath=3D%p" + RUN+=3D"hid2hci --method=3Ddell --devpath=3D%p", ENV{HID2HCI_SWITCH}=3D= "1" =20 # Logitech devices (hidraw) KERNEL=3D=3D"hidraw*", ATTRS{idVendor}=3D=3D"046d", ATTRS{idProduct}=3D=3D= "c70[345abce]|c71[34bc]", \ @@ -21,7 +21,7 @@ # 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", \ - ENV{REMOVE_CMD}=3D"hid2hci --method=3Ddell --devpath=3D%p --find-sibli= ng-intf=3D03:01:02" + ENV{REMOVE_CMD}=3D"/sbin/udevadm trigger --action=3Dchange --subsystem= -match=3Dusb --property-match=3DHID2HCI_SWITCH=3D1" =20 # CSR devices ATTR{idVendor}=3D=3D"0a12|0458|05ac", ATTR{idProduct}=3D=3D"1000", RUN+=3D= "hid2hci --method=3Dcsr --devpath=3D%p" =3D=3D=3D modified file 'extras/hid2hci/hid2hci.c' --- extras/hid2hci/hid2hci.c 2009-07-24 16:06:22 +0000 +++ extras/hid2hci/hid2hci.c 2009-08-05 08:07:51 +0000 @@ -191,70 +191,14 @@ return NULL; } =20 -static struct usb_dev_handle *find_device(struct udev_device *udev_dev, = const char *sibling_intf) +static struct usb_dev_handle *find_device(struct udev_device *udev_dev) { - struct udev *udev =3D udev_device_get_udev(udev_dev); struct usb_device *dev; - struct udev_device *udev_parent; - char str[UTIL_NAME_SIZE]; - struct udev_enumerate *enumerate; - struct udev_list_entry *entry; - struct usb_dev_handle *handle =3D NULL; - - if (sibling_intf =3D=3D NULL) { - dev =3D usb_device_open_from_udev(udev_dev); - if (dev =3D=3D NULL) - return NULL; - return usb_open(dev); - } - - /* find matching sibling of the current usb_device, they share the same= hub */ - udev_parent =3D udev_device_get_parent_with_subsystem_devtype(udev_dev,= "usb", "usb_device"); - if (udev_parent =3D=3D NULL) - return NULL; - - enumerate =3D udev_enumerate_new(udev); - if (enumerate =3D=3D NULL) - return NULL; - - udev_enumerate_add_match_subsystem(enumerate, "usb"); - - /* match all childs of the parent */ - util_strscpyl(str, sizeof(str), udev_device_get_sysname(udev_parent), "= *", NULL); - udev_enumerate_add_match_sysname(enumerate, str); - - /* match the specified interface */ - util_strscpy(str, sizeof(str), sibling_intf); - str[2] =3D '\0'; - str[5] =3D '\0'; - str[8] =3D '\0'; - if (strcmp(str, "-1") !=3D 0) - udev_enumerate_add_match_sysattr(enumerate, "bInterfaceClass", str); - if (strcmp(&str[3], "-1") !=3D 0) - udev_enumerate_add_match_sysattr(enumerate, "bInterfaceSubClass", &str= [3]); - if (strcmp(&str[6], "-1") !=3D 0) - udev_enumerate_add_match_sysattr(enumerate, "bInterfaceProtocol", &str= [6]); - - udev_enumerate_scan_devices(enumerate); - udev_list_entry_foreach(entry, udev_enumerate_get_list_entry(enumerate)= ) { - struct udev_device *udev_device; - - udev_device =3D udev_device_new_from_syspath(udev, udev_list_entry_get= _name(entry)); - if (udev_device !=3D NULL) { - /* get the usb_device of the usb_interface we matched */ - udev_parent =3D udev_device_get_parent_with_subsystem_devtype(udev_de= vice, "usb", "usb_device"); - if (udev_parent =3D=3D NULL) - continue; - /* only look at the first matching device */ - dev =3D usb_device_open_from_udev(udev_parent); - if (dev !=3D NULL) - handle =3D usb_open(dev); - udev_device_unref(udev_device); - break; - } -} - udev_enumerate_unref(enumerate); - return handle; + + dev =3D usb_device_open_from_udev(udev_dev); + if (dev =3D=3D NULL) + return NULL; + return usb_open(dev); } =20 static void usage(const char *error) @@ -268,7 +212,6 @@ " --mode=3D mode to switch to [hid|hci] (default hci)\n= " " --devpath=3D sys device path\n" " --method=3D method to use to switch [csr|logitech-hid|d= ell]\n" - " --find-sibling-intf=3D find the sibling device with 00:00:00 (clas= s:subclass:prot)\n" " --help\n\n"); } =20 @@ -279,7 +222,6 @@ { "mode", required_argument, NULL, 'm' }, { "devpath", required_argument, NULL, 'p' }, { "method", required_argument, NULL, 'M' }, - { "find-sibling-intf", required_argument, NULL, 'I' }, { } }; enum method { @@ -294,14 +236,13 @@ int (*usb_switch)(struct usb_dev_handle *dev, enum mode mode) =3D NULL;= enum mode mode =3D HCI; const char *devpath =3D NULL; - const char *sibling_intf =3D NULL; int err =3D -1; int rc =3D 1; =20 for (;;) { int option; =20 - option =3D getopt_long(argc, argv, "m:p:M:I:qh", options, NULL); + option =3D getopt_long(argc, argv, "m:p:M:qh", options, NULL); if (option =3D=3D -1) break; =20 @@ -333,9 +274,6 @@ exit(1); } break; - case 'I': - sibling_intf =3D optarg; - break; case 'h': usage(NULL); default: @@ -377,10 +315,10 @@ } } =20 - handle =3D find_device(dev, sibling_intf); + handle =3D find_device(dev); if (handle =3D=3D NULL) { - fprintf(stderr, "error: unable to handle '%s' (intf=3D%s)\n", - udev_device_get_syspath(dev), sibling_intf); + fprintf(stderr, "error: unable to handle '%s'\n", + udev_device_get_syspath(dev)); goto exit; } err =3D usb_switch(handle, mode); @@ -402,8 +340,8 @@ } =20 if (err < 0) - fprintf(stderr, "error: switching device '%s' (intf=3D%s) failed.\n", - udev_device_get_syspath(udev_dev), sibling_intf); + fprintf(stderr, "error: switching device '%s' failed.\n", + udev_device_get_syspath(udev_dev)); exit: udev_device_unref(udev_dev); udev_unref(udev); --------------060309090005000102040108-- --------------enig2920D8FCA3C8A9C503256B20 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 iEYEARECAAYFAkp7U0gACgkQ2CrZjkA73Yvo0QCfStqLyCmoi3CWFD6YCxFU0Fel JFAAoIPfTEGtZ2YFkHK4NvObefG9uZgl =43Ts -----END PGP SIGNATURE----- --------------enig2920D8FCA3C8A9C503256B20--