Commit fa4c86a0 authored by Matthias Kaehlcke's avatar Matthias Kaehlcke Committed by Greg Kroah-Hartman

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: default avatarMatthias Kaehlcke <matthias@kaehlcke.net>
Acked-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9ab15651
...@@ -384,9 +384,8 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr) ...@@ -384,9 +384,8 @@ ep_read (struct file *fd, char __user *buf, size_t len, loff_t *ptr)
return value; return value;
/* halt any endpoint by doing a "wrong direction" i/o call */ /* halt any endpoint by doing a "wrong direction" i/o call */
if (data->desc.bEndpointAddress & USB_DIR_IN) { if (usb_endpoint_dir_in(&data->desc)) {
if ((data->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) if (usb_endpoint_xfer_isoc(&data->desc))
== USB_ENDPOINT_XFER_ISOC)
return -EINVAL; return -EINVAL;
DBG (data->dev, "%s halt\n", data->name); DBG (data->dev, "%s halt\n", data->name);
spin_lock_irq (&data->dev->lock); spin_lock_irq (&data->dev->lock);
...@@ -428,9 +427,8 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr) ...@@ -428,9 +427,8 @@ ep_write (struct file *fd, const char __user *buf, size_t len, loff_t *ptr)
return value; return value;
/* halt any endpoint by doing a "wrong direction" i/o call */ /* halt any endpoint by doing a "wrong direction" i/o call */
if (!(data->desc.bEndpointAddress & USB_DIR_IN)) { if (!usb_endpoint_dir_in(&data->desc)) {
if ((data->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) if (usb_endpoint_xfer_isoc(&data->desc))
== USB_ENDPOINT_XFER_ISOC)
return -EINVAL; return -EINVAL;
DBG (data->dev, "%s halt\n", data->name); DBG (data->dev, "%s halt\n", data->name);
spin_lock_irq (&data->dev->lock); spin_lock_irq (&data->dev->lock);
...@@ -691,7 +689,7 @@ ep_aio_read(struct kiocb *iocb, const struct iovec *iov, ...@@ -691,7 +689,7 @@ ep_aio_read(struct kiocb *iocb, const struct iovec *iov,
struct ep_data *epdata = iocb->ki_filp->private_data; struct ep_data *epdata = iocb->ki_filp->private_data;
char *buf; char *buf;
if (unlikely(epdata->desc.bEndpointAddress & USB_DIR_IN)) if (unlikely(usb_endpoint_dir_in(&epdata->desc)))
return -EINVAL; return -EINVAL;
buf = kmalloc(iocb->ki_left, GFP_KERNEL); buf = kmalloc(iocb->ki_left, GFP_KERNEL);
...@@ -711,7 +709,7 @@ ep_aio_write(struct kiocb *iocb, const struct iovec *iov, ...@@ -711,7 +709,7 @@ ep_aio_write(struct kiocb *iocb, const struct iovec *iov,
size_t len = 0; size_t len = 0;
int i = 0; int i = 0;
if (unlikely(!(epdata->desc.bEndpointAddress & USB_DIR_IN))) if (unlikely(!usb_endpoint_dir_in(&epdata->desc)))
return -EINVAL; return -EINVAL;
buf = kmalloc(iocb->ki_left, GFP_KERNEL); buf = kmalloc(iocb->ki_left, GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment