comedi: ni_usb6501: refactor endpoint lookup
PATCH 1/1 comedi: ni_usb6501: refactor endpoint lookup
Use the common USB helper for looking up bulk and interrupt endpoints instead of open coding.
Signed-off-by Johan Hovold <[email protected]>
--- drivers/comedi/drivers/ni_usb6501.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)
drivers/comedi/drivers/ni_usb6501.c +4 -19
@@ -477,31 +477,16 @@ static int ni6501_find_endpoints(struct comedi_device *dev)struct usb_interface *intf =comedi_to_usb_interface (dev);struct ni6501_private *devpriv = dev->private;struct usb_host_interface *iface_desc = intf->cur_altsetting; -struct usb_endpoint_descriptor *ep_desc; -int i; +int ret;if (iface_desc->desc.bNumEndpoints !=2 ) {dev_err (dev->class_dev,"Wrong number of endpoints\n" );return -ENODEV ; } -for (i =0 ; i < iface_desc->desc.bNumEndpoints; i++) { - ep_desc = &iface_desc->endpoint[i].desc; - -if (usb_endpoint_is_bulk_in (ep_desc)) { -if (!devpriv->ep_rx) - devpriv->ep_rx = ep_desc; -continue ; - } - -if (usb_endpoint_is_bulk_out (ep_desc)) { -if (!devpriv->ep_tx) - devpriv->ep_tx = ep_desc; -continue ; - } - } - -if (!devpriv->ep_rx || !devpriv->ep_tx) + ret =usb_find_common_endpoints (iface_desc, &devpriv->ep_rx, + &devpriv->ep_tx,NULL ,NULL ); +if (ret)return -ENODEV ;if (usb_endpoint_maxp (devpriv->ep_rx) <RX_MAX_SIZE )
Signature · 1 line
2.52.0
Quoted 38 lines · Johan Hovold
Use the common USB helper for looking up bulk and interrupt endpoints instead of open coding.
Signed-off-by Johan Hovold <[email protected]>--- drivers/comedi/drivers/ni_usb6501.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)drivers/comedi/drivers/ni_usb6501.c +1
-15@@ -477,31 +477,16 @@ static int ni6501_find_endpoints(struct comedi_device *dev)struct usb_interface *intf =comedi_to_usb_interface (dev);struct ni6501_private *devpriv = dev->private;struct usb_host_interface *iface_desc = intf->cur_altsetting; -struct usb_endpoint_descriptor *ep_desc; -int i; +int ret;if (iface_desc->desc.bNumEndpoints !=2 ) {dev_err (dev->class_dev,"Wrong number of endpoints\n" );return -ENODEV ; } -for (i =0 ; i < iface_desc->desc.bNumEndpoints; i++) { - ep_desc = &iface_desc->endpoint[i].desc; - -if (usb_endpoint_is_bulk_in (ep_desc)) { -if (!devpriv->ep_rx) - devpriv->ep_rx = ep_desc; -continue ; - } - -if (usb_endpoint_is_bulk_out (ep_desc)) { -if (!devpriv->ep_tx) - devpriv->ep_tx = ep_desc; -continue ;
drivers/comedi/drivers/ni_usb6501.c static int ni6501_find_endpoints(struct comedi_device *dev) · line 492
Quoted 10 lines
drivers/comedi/drivers/ni_usb6501.c +3
-4- } - } - -if (!devpriv->ep_rx || !devpriv->ep_tx) + ret =usb_find_common_endpoints (iface_desc, &devpriv->ep_rx, + &devpriv->ep_tx,NULL ,NULL ); +if (ret)return -ENODEV ;if (usb_endpoint_maxp (devpriv->ep_rx) <RX_MAX_SIZE )
Looks good, thanks!
Reviewed-by Ian Abbott <[email protected]>
Signature · 4 lines
-=( Ian Abbott <[email protected]> || MEV Ltd. is a company )=- -=( registered in England & Wales. Regd. number: 02862268. )=- -=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=- -=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-