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

USB: usbfs: export the URB_NO_INTERRUPT flag to userspace

This patch (as1079) cleans up the way URB_* flags are exported in
usbfs.

The URB_NO_INTERRUPT flag is now exported (this is the
only behavioral change).

USBDEVFS_URB_* macros are added for URB_NO_FSBR,
URB_ZERO_PACKET, and URB_NO_INTERRUPT, making explicit the
fact that the kernel accepts them.

The flag matching takes into account that the URB_* values
may change as the kernel evolves, whereas the USBDEVFS_URB_*
values must remain fixed since they are a user API.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
14722ef4 aff6d18f

+28 -6
+23 -4
drivers/usb/core/devio.c
··· 948 948 int ret, ifnum = -1; 949 949 int is_in; 950 950 951 - if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP|USBDEVFS_URB_SHORT_NOT_OK| 952 - URB_NO_FSBR|URB_ZERO_PACKET)) 951 + if (uurb->flags & ~(USBDEVFS_URB_ISO_ASAP | 952 + USBDEVFS_URB_SHORT_NOT_OK | 953 + USBDEVFS_URB_NO_FSBR | 954 + USBDEVFS_URB_ZERO_PACKET | 955 + USBDEVFS_URB_NO_INTERRUPT)) 953 956 return -EINVAL; 954 957 if (!uurb->buffer) 955 958 return -EINVAL; ··· 1107 1104 as->urb->pipe = (uurb->type << 30) | 1108 1105 __create_pipe(ps->dev, uurb->endpoint & 0xf) | 1109 1106 (uurb->endpoint & USB_DIR_IN); 1110 - as->urb->transfer_flags = uurb->flags | 1111 - (is_in ? URB_DIR_IN : URB_DIR_OUT); 1107 + 1108 + /* This tedious sequence is necessary because the URB_* flags 1109 + * are internal to the kernel and subject to change, whereas 1110 + * the USBDEVFS_URB_* flags are a user API and must not be changed. 1111 + */ 1112 + u = (is_in ? URB_DIR_IN : URB_DIR_OUT); 1113 + if (uurb->flags & USBDEVFS_URB_ISO_ASAP) 1114 + u |= URB_ISO_ASAP; 1115 + if (uurb->flags & USBDEVFS_URB_SHORT_NOT_OK) 1116 + u |= URB_SHORT_NOT_OK; 1117 + if (uurb->flags & USBDEVFS_URB_NO_FSBR) 1118 + u |= URB_NO_FSBR; 1119 + if (uurb->flags & USBDEVFS_URB_ZERO_PACKET) 1120 + u |= URB_ZERO_PACKET; 1121 + if (uurb->flags & USBDEVFS_URB_NO_INTERRUPT) 1122 + u |= URB_NO_INTERRUPT; 1123 + as->urb->transfer_flags = u; 1124 + 1112 1125 as->urb->transfer_buffer_length = uurb->buffer_length; 1113 1126 as->urb->setup_packet = (unsigned char *)dr; 1114 1127 as->urb->start_frame = uurb->start_frame;
+5 -2
include/linux/usbdevice_fs.h
··· 77 77 unsigned char slow; 78 78 }; 79 79 80 - #define USBDEVFS_URB_SHORT_NOT_OK 1 81 - #define USBDEVFS_URB_ISO_ASAP 2 80 + #define USBDEVFS_URB_SHORT_NOT_OK 0x01 81 + #define USBDEVFS_URB_ISO_ASAP 0x02 82 + #define USBDEVFS_URB_NO_FSBR 0x20 83 + #define USBDEVFS_URB_ZERO_PACKET 0x40 84 + #define USBDEVFS_URB_NO_INTERRUPT 0x80 82 85 83 86 #define USBDEVFS_URB_TYPE_ISO 0 84 87 #define USBDEVFS_URB_TYPE_INTERRUPT 1