Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: gadgetfs: use helper functions to determine endpoint type and direction

Use helper functions to determine the type and direction of an endpoint
instead of fiddling with bEndpointAddress and bmAttributes

Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Matthias Kaehlcke and committed by
Greg Kroah-Hartman
fa4c86a0 9ab15651

+6 -8
+6 -8
drivers/usb/gadget/inode.c
··· 384 384 return value; 385 385 386 386 /* halt any endpoint by doing a "wrong direction" i/o call */ 387 - if (data->desc.bEndpointAddress & USB_DIR_IN) { 388 - if ((data->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 389 - == USB_ENDPOINT_XFER_ISOC) 387 + if (usb_endpoint_dir_in(&data->desc)) { 388 + if (usb_endpoint_xfer_isoc(&data->desc)) 390 389 return -EINVAL; 391 390 DBG (data->dev, "%s halt\n", data->name); 392 391 spin_lock_irq (&data->dev->lock); ··· 427 428 return value; 428 429 429 430 /* halt any endpoint by doing a "wrong direction" i/o call */ 430 - if (!(data->desc.bEndpointAddress & USB_DIR_IN)) { 431 - if ((data->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) 432 - == USB_ENDPOINT_XFER_ISOC) 431 + if (!usb_endpoint_dir_in(&data->desc)) { 432 + if (usb_endpoint_xfer_isoc(&data->desc)) 433 433 return -EINVAL; 434 434 DBG (data->dev, "%s halt\n", data->name); 435 435 spin_lock_irq (&data->dev->lock); ··· 689 691 struct ep_data *epdata = iocb->ki_filp->private_data; 690 692 char *buf; 691 693 692 - if (unlikely(epdata->desc.bEndpointAddress & USB_DIR_IN)) 694 + if (unlikely(usb_endpoint_dir_in(&epdata->desc))) 693 695 return -EINVAL; 694 696 695 697 buf = kmalloc(iocb->ki_left, GFP_KERNEL); ··· 709 711 size_t len = 0; 710 712 int i = 0; 711 713 712 - if (unlikely(!(epdata->desc.bEndpointAddress & USB_DIR_IN))) 714 + if (unlikely(!usb_endpoint_dir_in(&epdata->desc))) 713 715 return -EINVAL; 714 716 715 717 buf = kmalloc(iocb->ki_left, GFP_KERNEL);