History

usb: usbtmc: Add ioctl for vendor specific write

The new ioctl USBTMC_IOCTL_WRITE sends a generic message to bulk OUT. This ioctl is used for vendor specific or asynchronous I/O as well. The message is split into chunks of 4k (page size). Message size is aligned to 32 bit boundaries. With flag USBTMC_FLAG_ASYNC the ioctl is non blocking. With flag USBTMC_FLAG_APPEND additional urbs are queued and out_status/out_transfer_size is not reset. EPOLLOUT | EPOLLWRNORM is signaled when all submitted urbs are completed. Flush flying urbs when file handle is closed or device is suspended or reset. This ioctl does not support compatibility for 32 bit applications running on 64 bit systems. However all other convenient ioctls of the USBTMC driver can still be used in 32 bit applications as well. Note that 32 bit applications running on 32 bit target systems are not affected by this limitation.

Guido Kiener committed 8 years ago

Commit 4ddc6451 parent 658f24f2 files · +388 −2Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/usb/tmc.h+14−0
@@ -59,6 +59,19 @@ struct usbtmc_termchar { · 58 unmodified lines
59 __u8 term_char_enabled;59 __u8 term_char_enabled;
60} __attribute__ ((packed));60} __attribute__ ((packed));
61 61
62/*
63 * usbtmc_message->flags:
64 */
65#define USBTMC_FLAG_ASYNC 0x0001
66#define USBTMC_FLAG_APPEND 0x0002
67
68struct usbtmc_message {
69 __u32 transfer_size; /* size of bytes to transfer */
70 __u32 transferred; /* size of received/written bytes */
71 __u32 flags; /* bit 0: 0 = synchronous; 1 = asynchronous */
72 void __user *message; /* pointer to header and data in user space */
73} __attribute__ ((packed));
74
62/* Request values for USBTMC driver's ioctl entry point */75/* Request values for USBTMC driver's ioctl entry point */
63#define USBTMC_IOC_NR 9176#define USBTMC_IOC_NR 91
64#define USBTMC_IOCTL_INDICATOR_PULSE _IO(USBTMC_IOC_NR, 1)77#define USBTMC_IOCTL_INDICATOR_PULSE _IO(USBTMC_IOC_NR, 1)
@@ -72,6 +85,7 @@ struct usbtmc_termchar { · 7 unmodified lines
72#define USBTMC_IOCTL_SET_TIMEOUT _IOW(USBTMC_IOC_NR, 10, __u32)85#define USBTMC_IOCTL_SET_TIMEOUT _IOW(USBTMC_IOC_NR, 10, __u32)
73#define USBTMC_IOCTL_EOM_ENABLE _IOW(USBTMC_IOC_NR, 11, __u8)86#define USBTMC_IOCTL_EOM_ENABLE _IOW(USBTMC_IOC_NR, 11, __u8)
74#define USBTMC_IOCTL_CONFIG_TERMCHAR _IOW(USBTMC_IOC_NR, 12, struct usbtmc_termchar)87#define USBTMC_IOCTL_CONFIG_TERMCHAR _IOW(USBTMC_IOC_NR, 12, struct usbtmc_termchar)
88#define USBTMC_IOCTL_WRITE _IOWR(USBTMC_IOC_NR, 13, struct usbtmc_message)
75 89
76#define USBTMC488_IOCTL_GET_CAPS _IOR(USBTMC_IOC_NR, 17, unsigned char)90#define USBTMC488_IOCTL_GET_CAPS _IOR(USBTMC_IOC_NR, 17, unsigned char)
77#define USBTMC488_IOCTL_READ_STB _IOR(USBTMC_IOC_NR, 18, unsigned char)91#define USBTMC488_IOCTL_READ_STB _IOR(USBTMC_IOC_NR, 18, unsigned char)