ChangeSet 1.1031, 2003/03/05 21:38:48-08:00, go@turbolinux.co.jp [PATCH] USB: Multiple interfaces with usb hotplug Some HID devices have multiple interfaces. e.x. Keyboard + Mouse Keyboard + Mouse + Pointer. Cuurent(2.4.21pre5) code of usb hotplug supports the first interface only. OKI/Fijitsu use this type of kerbaord. IBM Blade Center do USB emulation as PS2. And USB emulation has multiple interfaces. Below are IBM Blade Center's devices. T: Bus=01 Lev=02 Prnt=03 Port=02 Cnt=02 Dev#= 5 Spd=12 MxCh= 0 D: Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1 P: Vendor=04b3 ProdID=4004 Rev= 0.01 S: Manufacturer=Cypress S: Product=HID K/M C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr= 0mA I: If#= 0 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=01 Driver=hid <-- 1st E: Ad=81(I) Atr=03(Int.) MxPS= 8 Ivl=10ms I: If#= 1 Alt= 0 #EPs= 1 Cls=03(HID ) Sub=01 Prot=02 Driver=hid <-- 2nd. E: Ad=82(I) Atr=03(Int.) MxPS= 4 Ivl=10ms As for blade server, keyboard which has multiple interfaces are often used. However, mouse dose not use with hotplug. This patch activates hotplug in accordance with number of interface. drivers/usb/usb.c | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-) diff -Nru a/drivers/usb/usb.c b/drivers/usb/usb.c --- a/drivers/usb/usb.c Thu Mar 6 14:20:24 2003 +++ b/drivers/usb/usb.c Thu Mar 6 14:20:24 2003 @@ -782,7 +782,7 @@ * cases, we know no other thread can recycle our address, since we must * already have been serialized enough to prevent that. */ -static void call_policy (char *verb, struct usb_device *dev) +static void call_policy_interface (char *verb, struct usb_device *dev, int interface) { char *argv [3], **envp, *buf, *scratch; int i = 0, value; @@ -861,20 +861,14 @@ dev->descriptor.bDeviceSubClass, dev->descriptor.bDeviceProtocol) + 1; if (dev->descriptor.bDeviceClass == 0) { - int alt = dev->actconfig->interface [0].act_altsetting; + int alt = dev->actconfig->interface [interface].act_altsetting; - /* a simple/common case: one config, one interface, one driver - * with current altsetting being a reasonable setting. - * everything needs a smart agent and usbdevfs; or can rely on - * device-specific binding policies. - */ envp [i++] = scratch; scratch += sprintf (scratch, "INTERFACE=%d/%d/%d", - dev->actconfig->interface [0].altsetting [alt].bInterfaceClass, - dev->actconfig->interface [0].altsetting [alt].bInterfaceSubClass, - dev->actconfig->interface [0].altsetting [alt].bInterfaceProtocol) + dev->actconfig->interface [interface].altsetting [alt].bInterfaceClass, + dev->actconfig->interface [interface].altsetting [alt].bInterfaceSubClass, + dev->actconfig->interface [interface].altsetting [alt].bInterfaceProtocol) + 1; - /* INTERFACE-0, INTERFACE-1, ... ? */ } envp [i++] = 0; /* assert: (scratch - buf) < sizeof buf */ @@ -887,6 +881,14 @@ kfree (envp); if (value != 0) dbg ("kusbd policy returned 0x%x", value); +} + +static void call_policy (char *verb, struct usb_device *dev) +{ + int i; + for (i = 0; i < dev->actconfig->bNumInterfaces; i++) { + call_policy_interface (verb, dev, i); + } } #else