NetBSD-Bugs archive

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

Re: kern/48715: Please support more USB modems



The following reply was made to PR kern/48715; it has been noted by GNATS.

From: Ryo ONODERA <ryo_on%yk.rim.or.jp@localhost>
To: mrg%eterna.com.au@localhost, gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: kern/48715: Please support more USB modems
Date: Sat, 25 Jun 2016 15:22:55 +0900 (JST)

 Hi,
 
 From: matthew green <mrg%eterna.com.au@localhost>, Date: Sat, 25 Jun 2016 13:30:45 +1000
 
 > hi Ryoon,
 > 
 > no comment about the general change, but ..
 > 
 >>  +static const struct usb_devno umodem_devs[] = {
 >>  +	/* Conexant USB Modem */
 >>  +	{ USB_VENDOR_CONEXANT, USB_PRODUCT_CONEXANT_MODEM_1 },
 >>  +};
 >>  +#define	umodem_lookup(v, p) usb_lookup(umodem_devs, v, p)
 >>  +
 >>   int             umodem_match(device_t, cfdata_t, void *);
 >>   void            umodem_attach(device_t, device_t, void *);
 >>   int             umodem_detach(device_t, int);
 >>  @@ -97,13 +103,17 @@
 >>   	struct usbif_attach_arg *uiaa = aux;
 >>   	usb_interface_descriptor_t *id;
 >>   	int cm, acm;
 >>  +	id = usbd_get_interface_descriptor(uiaa->uiaa_iface);
 >>  +
 >>  +	if (umodem_lookup(uiaa->uiaa_vendor, uiaa->uiaa_product) &&
 >>  +	    id->bInterfaceNumber == 1)
 >>  +		return (UMATCH_VENDOR_PRODUCT);
 > 
 > what's this magic "1" about?
 
 Thanks for your review.
 
 It is working interface number.
 However hardcoding it is bad idea.
 
 The following new patch may useful for other USB modems.
 And usbif_attach_arg is used.
 
 Index: umodem.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/usb/umodem.c,v
 retrieving revision 1.68
 diff -u -r1.68 umodem.c
 --- umodem.c	23 Apr 2016 10:15:32 -0000	1.68
 +++ umodem.c	25 Jun 2016 06:18:50 -0000
 @@ -81,6 +81,27 @@
  	.ucom_write = NULL,
  };
  
 +static const struct umodem_devno {
 +	int	vendor;
 +	int	product;
 +	int	interface;
 +	int	match;
 +} umodem_devs[] = {
 +	/* Conexant USB Modem */
 +	{ /* Ignore interface 0 */
 +		USB_VENDOR_CONEXANT,
 +		USB_PRODUCT_CONEXANT_MODEM_1,
 +		0,
 +		UMATCH_NONE
 +	},
 +	{ /* Detect interface 1 only */
 +		USB_VENDOR_CONEXANT,
 +		USB_PRODUCT_CONEXANT_MODEM_1,
 +		1,
 +		UMATCH_VENDOR_PRODUCT
 +	},
 +};
 +
  int             umodem_match(device_t, cfdata_t, void *);
  void            umodem_attach(device_t, device_t, void *);
  int             umodem_detach(device_t, int);
 @@ -97,6 +118,21 @@
  	struct usbif_attach_arg *uiaa = aux;
  	usb_interface_descriptor_t *id;
  	int cm, acm;
 +	size_t i;
 +
 +	for (i = 0; i < __arraycount(umodem_devs); i++) {
 +		if (umodem_devs[i].vendor != -1
 +		    && umodem_devs[i].vendor != uiaa->uiaa_vendor)
 +                        continue;
 +		if (umodem_devs[i].product != -1
 +		    && umodem_devs[i].product != uiaa->uiaa_product)
 +                        continue;
 +		if (umodem_devs[i].interface != -1
 +		    && umodem_devs[i].interface != uiaa->uiaa_ifaceno)
 +                        continue;
 +
 +                return umodem_devs[i].match;
 +        }
  
  	if (uiaa->uiaa_class != UICLASS_CDC ||
  	    uiaa->uiaa_subclass != UISUBCLASS_ABSTRACT_CONTROL_MODEL ||
 
 --
 Ryo ONODERA // ryo_on%yk.rim.or.jp@localhost
 PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3
 


Home | Main Index | Thread Index | Old Index