From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965700AbcAZSPh (ORCPT ); Tue, 26 Jan 2016 13:15:37 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34107 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965007AbcAZSPe (ORCPT ); Tue, 26 Jan 2016 13:15:34 -0500 Date: Tue, 26 Jan 2016 19:15:23 +0100 From: Dave Penkler To: Greg KH Cc: peter.chen@freescale.com, teuniz@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v6 4/5] Add ioctl to retrieve USBTMC-USB488 capabilities Message-ID: <20160126181523.GA1758@slacky> References: <20151129122251.GA7490@slacky> <20151129123551.GD7499@slacky> <20160125044254.GA14247@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160125044254.GA14247@kroah.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jan 24, 2016 at 08:42:54PM -0800, Greg KH wrote: > On Sun, Nov 29, 2015 at 01:35:51PM +0100, Dave Penkler wrote: > > This is a convenience function to obtain an instrument's > > capabilities from its file descriptor without having to access sysfs > > from the user program. > > > > Signed-off-by: Dave Penkler > > --- > > drivers/usb/class/usbtmc.c | 12 ++++++++++++ > > include/uapi/linux/usb/tmc.h | 21 ++++++++++++++++++--- > > 2 files changed, 30 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c > > index 3b85ef5..3a3264c 100644 > > --- a/drivers/usb/class/usbtmc.c > > +++ b/drivers/usb/class/usbtmc.c > > @@ -102,6 +102,9 @@ struct usbtmc_device_data { > > u16 iin_wMaxPacketSize; > > atomic_t srq_asserted; > > > > + /* coalesced usb488_caps from usbtmc_dev_capabilities */ > > + u8 usb488_caps; > > + > > u8 rigol_quirk; > > > > /* attributes from the USB TMC spec for this device */ > > @@ -992,6 +995,7 @@ static int get_capabilities(struct usbtmc_device_data *data) > > data->capabilities.device_capabilities = buffer[5]; > > data->capabilities.usb488_interface_capabilities = buffer[14]; > > data->capabilities.usb488_device_capabilities = buffer[15]; > > + data->usb488_caps = (buffer[14] & 0x07) | ((buffer[15] & 0x0f) << 4); > > rv = 0; > > > > err_out: > > @@ -1167,6 +1171,14 @@ static long usbtmc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > > retval = usbtmc_ioctl_abort_bulk_in(data); > > break; > > > > + case USBTMC488_IOCTL_GET_CAPS: > > + retval = copy_to_user((void __user *)arg, > > + &data->usb488_caps, > > + sizeof(data->usb488_caps)); > > + if (retval) > > + retval = -EFAULT; > > + break; > > + > > case USBTMC488_IOCTL_READ_STB: > > retval = usbtmc488_ioctl_read_stb(data, arg); > > break; > > diff --git a/include/uapi/linux/usb/tmc.h b/include/uapi/linux/usb/tmc.h > > index 7e5ced8..1dc3af1 100644 > > --- a/include/uapi/linux/usb/tmc.h > > +++ b/include/uapi/linux/usb/tmc.h > > @@ -2,12 +2,14 @@ > > * Copyright (C) 2007 Stefan Kopp, Gechingen, Germany > > * Copyright (C) 2008 Novell, Inc. > > * Copyright (C) 2008 Greg Kroah-Hartman > > + * Copyright (C) 2015 Dave Penkler > > * > > * This file holds USB constants defined by the USB Device Class > > - * Definition for Test and Measurement devices published by the USB-IF. > > + * and USB488 Subclass Definitions for Test and Measurement devices > > + * published by the USB-IF. > > * > > - * It also has the ioctl definitions for the usbtmc kernel driver that > > - * userspace needs to know about. > > + * It also has the ioctl and capability definitions for the > > + * usbtmc kernel driver that userspace needs to know about. > > */ > > > > #ifndef __LINUX_USB_TMC_H > > @@ -40,6 +42,19 @@ > > #define USBTMC_IOCTL_ABORT_BULK_IN _IO(USBTMC_IOC_NR, 4) > > #define USBTMC_IOCTL_CLEAR_OUT_HALT _IO(USBTMC_IOC_NR, 6) > > #define USBTMC_IOCTL_CLEAR_IN_HALT _IO(USBTMC_IOC_NR, 7) > > +#define USBTMC488_IOCTL_GET_CAPS _IO(USBTMC_IOC_NR, 17) > > Shouldn't there be a data structure mentioned here that gets passed back > to userspace? And are you sure the direction is correct as well? > Oops, it should read: #define USBTMC488_IOCTL_GET_CAPS _IOR(USBTMC_IOC_NR, 17, unsigned char) Thanks, -dave > thanks, > > greg k-h