usb: usbtmc: Add ioctl for vendor specific write
Greg Kroah-Hartman
maintainerPATCH v2 9/29 usb: usbtmc: Add ioctl for vendor specific write
Quoted 55 lines · Guido Kiener
The new ioctl
USBTMC_IOCTL_WRITEsends 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_ASYNCthe ioctl is non blocking. With flagUSBTMC_FLAG_APPENDadditional 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.
Signed-off-by Guido Kiener <[email protected]>Reviewed-by Steve Bayless <[email protected]>--- drivers/usb/class/usbtmc.c | 416 ++++++++++++++++++++++++++++++++++- include/uapi/linux/usb/tmc.h | 14 ++ 2 files changed, 428 insertions(+), 2 deletions(-)drivers/usb/class/usbtmc.c +12
-0@@ -37,6 +37,8 @@/* Default USB timeout (in milliseconds) */ #define USBTMC_TIMEOUT 5000 +/* Max number of urbs used in write transfers */ +#define MAX_URBS_IN_FLIGHT 16/* I/O buffer size used in generic read/write functions */ #define USBTMC_BUFSIZE (4096)@@ -125,9 +127,19 @@ struct usbtmc_file_data {u32 timeout;u8 srq_byte;atomic_t srq_asserted; +u8 eom_val;u8 term_char;bool term_char_enabled; + +spinlock_t err_lock;/* lock for errors */ + +struct usb_anchor submitted; + +/* data for generic_write */ +struct semaphore limit_write_sem; +u32 out_transfer_size; +int out_status; };#ifdef CONFIG_COMPAT
drivers/usb/class/usbtmc.c struct compat_usbtmc_ctrlrequest { · line 157
Quoted 9 lines
drivers/usb/class/usbtmc.c +6
-0@@ -137,12 +149,21 @@ struct compat_usbtmc_ctrlrequest {compat_uptr_t data; } __packed; +struct compat_usbtmc_message { +__u32 transfer_size; +__u32 transferred; +__u32 flags; +compat_uptr_t message; +} __packed;
Same here, no need for this at all.
I've stopped reviewing in the series here. I've applied the first 6 patches in the series, please rework the remaining ones to not have any compatibility ioctls needed and resend. Or you can restructure what you already have and resend everything without the new ioctls so I can review/take them if you need more time to redo the ioctls stuff.
thanks,
greg k-h
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html