On Fri, Jun 02, 2017 at 01:27:48PM -0400, Alan Stern wrote:
> The usbfs interface does not provide any way for the user to learn the
> speed at which a device is connected.  The current API includes a
> USBDEVFS_CONNECTINFO ioctl, but all it provides is the device's
> address and a one-bit value indicating whether the connection is low
> speed.  That may have sufficed in the era of USB-1.1, but it isn't
> good enough today.
> 
> This patch introduces a new ioctl, USBDEVFS_GET_SPEED, which returns a
> numeric value indicating the speed of the connection: unknown, low,
> full, high, wireless, super, or super-plus.
> 
> Similar information (not exactly the same) is available through sysfs,
> but it seems reasonable to provide the actual value in usbfs.
> 
> Signed-off-by: Alan Stern <st...@rowland.harvard.edu>
> Reported-by: Reinhard Huck <reinhard.h...@thesycon.de>
> 
> ---
> 
> 
> [as1832]
> 
> 
>  drivers/usb/core/devio.c          |   24 ++++++++++++++++++++++++
>  include/uapi/linux/usbdevice_fs.h |   10 ++++++++++
>  2 files changed, 34 insertions(+)
> 
> Index: usb-4.x/drivers/usb/core/devio.c
> ===================================================================
> --- usb-4.x.orig/drivers/usb/core/devio.c
> +++ usb-4.x/drivers/usb/core/devio.c
> @@ -1322,6 +1322,27 @@ static int proc_connectinfo(struct usb_d
>       return 0;
>  }
>  
> +static int proc_get_speed(struct usb_dev_state *ps)
> +{
> +     switch (ps->dev->speed) {
> +     case USB_SPEED_UNKNOWN:
> +             return USBDEVFS_SPEED_UNKNOWN;
> +     case USB_SPEED_LOW:
> +             return USBDEVFS_SPEED_LOW;
> +     case USB_SPEED_FULL:
> +             return USBDEVFS_SPEED_FULL;
> +     case USB_SPEED_HIGH:
> +             return USBDEVFS_SPEED_HIGH;
> +     case USB_SPEED_WIRELESS:
> +             return USBDEVFS_SPEED_WIRELESS;
> +     case USB_SPEED_SUPER:
> +             return USBDEVFS_SPEED_SUPER;
> +     case USB_SPEED_SUPER_PLUS:
> +             return USBDEVFS_SPEED_SUPER_PLUS;
> +     }
> +     return -ERANGE;

We already export the USB_SPEED values to userspace, why not just use
those already, so we don't have to define yet-another-value?

That would make this function much simple :)

thanks,

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to