forked from Minki/linux
usb: usbtmc: Add ioctl for EOM bit
add USBTMC_IOCTL_EOM_ENABLE to specify EOM bit for next write() call. Sets Bit 0 of field 'bmTransferAttributes' of DEV_DEP_MSG_OUT Bulk-OUT Header. Allows fine grained control over end of message handling on a per file descriptor basis. Reviewed-by: Steve Bayless <steve_bayless@keysight.com> Tested-by: Dave Penkler <dpenkler@gmail.com> Signed-off-by: Dave Penkler <dpenkler@gmail.com> Signed-off-by: Guido Kiener <guido.kiener@rohde-schwarz.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
fe78a7c637
commit
fbd83971f9
@ -120,6 +120,7 @@ struct usbtmc_file_data {
|
||||
u32 timeout;
|
||||
u8 srq_byte;
|
||||
atomic_t srq_asserted;
|
||||
u8 eom_val;
|
||||
};
|
||||
|
||||
/* Forward declarations */
|
||||
@ -157,6 +158,7 @@ static int usbtmc_open(struct inode *inode, struct file *filp)
|
||||
file_data->data = data;
|
||||
|
||||
file_data->timeout = USBTMC_TIMEOUT;
|
||||
file_data->eom_val = 1;
|
||||
|
||||
INIT_LIST_HEAD(&file_data->file_elem);
|
||||
spin_lock_irq(&data->dev_lock);
|
||||
@ -855,7 +857,7 @@ static ssize_t usbtmc_write(struct file *filp, const char __user *buf,
|
||||
buffer[8] = 0;
|
||||
} else {
|
||||
this_part = remaining;
|
||||
buffer[8] = 1;
|
||||
buffer[8] = file_data->eom_val;
|
||||
}
|
||||
|
||||
/* Setup IO buffer for DEV_DEP_MSG_OUT message */
|
||||
@ -1277,6 +1279,25 @@ static int usbtmc_ioctl_set_timeout(struct usbtmc_file_data *file_data,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* enables/disables sending EOM on write
|
||||
*/
|
||||
static int usbtmc_ioctl_eom_enable(struct usbtmc_file_data *file_data,
|
||||
void __user *arg)
|
||||
{
|
||||
u8 eom_enable;
|
||||
|
||||
if (copy_from_user(&eom_enable, arg, sizeof(eom_enable)))
|
||||
return -EFAULT;
|
||||
|
||||
if (eom_enable > 1)
|
||||
return -EINVAL;
|
||||
|
||||
file_data->eom_val = eom_enable;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
struct usbtmc_file_data *file_data;
|
||||
@ -1327,6 +1348,11 @@ static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
|
||||
(void __user *)arg);
|
||||
break;
|
||||
|
||||
case USBTMC_IOCTL_EOM_ENABLE:
|
||||
retval = usbtmc_ioctl_eom_enable(file_data,
|
||||
(void __user *)arg);
|
||||
break;
|
||||
|
||||
case USBTMC488_IOCTL_GET_CAPS:
|
||||
retval = copy_to_user((void __user *)arg,
|
||||
&data->usb488_caps,
|
||||
|
@ -50,6 +50,8 @@
|
||||
#define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7)
|
||||
#define USBTMC_IOCTL_GET_TIMEOUT _IOR(USBTMC_IOC_NR, 9, __u32)
|
||||
#define USBTMC_IOCTL_SET_TIMEOUT _IOW(USBTMC_IOC_NR, 10, __u32)
|
||||
#define USBTMC_IOCTL_EOM_ENABLE _IOW(USBTMC_IOC_NR, 11, __u8)
|
||||
|
||||
#define USBTMC488_IOCTL_GET_CAPS _IOR(USBTMC_IOC_NR, 17, unsigned char)
|
||||
#define USBTMC488_IOCTL_READ_STB _IOR(USBTMC_IOC_NR, 18, unsigned char)
|
||||
#define USBTMC488_IOCTL_REN_CONTROL _IOW(USBTMC_IOC_NR, 19, unsigned char)
|
||||
|
Loading…
Reference in New Issue
Block a user