Re: AW: add usb option device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Dec 03, 2016 at 07:47:11PM +0100, Giuseppe Lippolis wrote:
> Dear All,
> 
> > If possible you want to tell the option driver which interfaces to 
> > bind to (white-listing) rather than specifying which not to bind to 
> > (black-listing). The latter typically means probing all interfaces, 
> > checking the black list, and then bailing out for unsupported 
> > interfaces.
> 
> I try to use the blacklist to specify which interface not to bind:
> 
> 	static const struct option_blacklist_info dlink_dwm_158_ blacklist = {
> 		.reserved = BIT(0) | BIT(1),
> 	};
> 
> 	{ USB_DEVICE (0x2001, 0x7d04),
> 		.driver_info = (kernel_ulong_t)&dlink_dwm_158_blacklist },
> 
> The result seems positive, after boot:

> T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#=  2 Spd=480  MxCh= 0
> D:  Ver= 2.00 Cls=02(comm.) Sub=00 Prot=00 MxPS=64 #Cfgs=  1
> P:  Vendor=2001 ProdID=7d04 Rev= 3.00
> S:  Manufacturer=D-Link,Inc
> S:  Product=D-Link DWM-158
> C:* #Ifs= 7 Cfg#= 1 Atr=a0 MxPwr=500mA
> A:  FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=06 Prot=00
> I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=06 Prot=00 Driver=cdc_ether
> E:  Ad=88(I) Atr=03(Int.) MxPS=  64 Ivl=125us
> I:  If#= 1 Alt= 0 #EPs= 0 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether
> I:* If#= 1 Alt= 1 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_ether
> E:  Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E:  Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> I:* If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=02 Prot=01 Driver=option
> E:  Ad=87(I) Atr=03(Int.) MxPS=  64 Ivl=125us
> E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> I:* If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
> E:  Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E:  Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> I:* If#= 4 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
> E:  Ad=84(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E:  Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> I:* If#= 5 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=option
> E:  Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E:  Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> I:* If#= 6 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none)
> E:  Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
> E:  Ad=06(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms

Yes, that would work, but if you look at the interface definitions above
you see that simply matching all interfaces with class 0xff (i.e.
white-listing) would suffice and is therefore preferred.

> On the kernel v4.8.12, I see similar d-link devices with the same
> VENDOR_ID declared in this way:
> 
> 	{ USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x02, 0x01) },	/* D-Link DWM-156 (variant) */
> 	{ USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d01, 0xff, 0x00, 0x00) },	/* D-Link DWM-156 (variant) */
> 	{ USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x02, 0x01) },
> 	{ USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d02, 0xff, 0x00, 0x00) },
> 	{ USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x02, 0x01) },
> 	{ USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) },
> 	{ USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7e19, 0xff),			/* D-Link DWM-221 B1 */
> 	  .driver_info = (kernel_ulong_t)&net_intf4_blacklist },
> 
> Shall I declare a 
> 	#define DLINK_VENDOR_ID				0x2001
> Or use the hardcoded style ?

Just stick to the hard-coded 0x2001 for now. There are two (or three)
other VIDs used for D-Link in option and it looks like one of them is
really the PCI vendor id.

Either way, we can clean that up later.

> Another question when is appropriate to use USB_DEVICE and when
> USB_DEVICE_INTERFACE_CLASS ?

So if you just use USB_DEVICE_INTERFACE_CLASS() you don't need to do any
blacklisting at all:

 	{ USB_DEVICE_INTERFACE_CLASS(0x2001, 0x7d04, 0xff) },

Thanks,
Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux