2005-04-16 16:20:36 -06:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* usbdevice_fs.h -- USB device file system.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000
|
|
|
|
* Thomas Sailer (sailer@ife.ee.ethz.ch)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* History:
|
|
|
|
* 0.1 04.01.2000 Created
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _LINUX_USBDEVICE_FS_H
|
|
|
|
#define _LINUX_USBDEVICE_FS_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
2006-09-24 09:13:19 -06:00
|
|
|
#include <linux/magic.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* usbdevfs ioctl codes */
|
|
|
|
|
|
|
|
struct usbdevfs_ctrltransfer {
|
|
|
|
__u8 bRequestType;
|
|
|
|
__u8 bRequest;
|
|
|
|
__u16 wValue;
|
|
|
|
__u16 wIndex;
|
|
|
|
__u16 wLength;
|
|
|
|
__u32 timeout; /* in milliseconds */
|
|
|
|
void __user *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_bulktransfer {
|
|
|
|
unsigned int ep;
|
|
|
|
unsigned int len;
|
|
|
|
unsigned int timeout; /* in milliseconds */
|
|
|
|
void __user *data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_setinterface {
|
|
|
|
unsigned int interface;
|
|
|
|
unsigned int altsetting;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_disconnectsignal {
|
|
|
|
unsigned int signr;
|
|
|
|
void __user *context;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define USBDEVFS_MAXDRIVERNAME 255
|
|
|
|
|
|
|
|
struct usbdevfs_getdriver {
|
|
|
|
unsigned int interface;
|
|
|
|
char driver[USBDEVFS_MAXDRIVERNAME + 1];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_connectinfo {
|
|
|
|
unsigned int devnum;
|
|
|
|
unsigned char slow;
|
|
|
|
};
|
|
|
|
|
2008-04-17 08:18:11 -06:00
|
|
|
#define USBDEVFS_URB_SHORT_NOT_OK 0x01
|
|
|
|
#define USBDEVFS_URB_ISO_ASAP 0x02
|
2009-09-01 09:09:56 -06:00
|
|
|
#define USBDEVFS_URB_BULK_CONTINUATION 0x04
|
2008-04-17 08:18:11 -06:00
|
|
|
#define USBDEVFS_URB_NO_FSBR 0x20
|
|
|
|
#define USBDEVFS_URB_ZERO_PACKET 0x40
|
|
|
|
#define USBDEVFS_URB_NO_INTERRUPT 0x80
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#define USBDEVFS_URB_TYPE_ISO 0
|
|
|
|
#define USBDEVFS_URB_TYPE_INTERRUPT 1
|
|
|
|
#define USBDEVFS_URB_TYPE_CONTROL 2
|
|
|
|
#define USBDEVFS_URB_TYPE_BULK 3
|
|
|
|
|
|
|
|
struct usbdevfs_iso_packet_desc {
|
|
|
|
unsigned int length;
|
|
|
|
unsigned int actual_length;
|
|
|
|
unsigned int status;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_urb {
|
|
|
|
unsigned char type;
|
|
|
|
unsigned char endpoint;
|
|
|
|
int status;
|
|
|
|
unsigned int flags;
|
|
|
|
void __user *buffer;
|
|
|
|
int buffer_length;
|
|
|
|
int actual_length;
|
|
|
|
int start_frame;
|
|
|
|
int number_of_packets;
|
|
|
|
int error_count;
|
2007-10-29 14:40:30 -06:00
|
|
|
unsigned int signr; /* signal to be sent on completion,
|
|
|
|
or 0 if none should be sent. */
|
2007-12-15 19:23:20 -07:00
|
|
|
void __user *usercontext;
|
2005-04-16 16:20:36 -06:00
|
|
|
struct usbdevfs_iso_packet_desc iso_frame_desc[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* ioctls for talking directly to drivers */
|
|
|
|
struct usbdevfs_ioctl {
|
|
|
|
int ifno; /* interface 0..N ; negative numbers reserved */
|
|
|
|
int ioctl_code; /* MUST encode size + direction of data so the
|
|
|
|
* macros in <asm/ioctl.h> give correct values */
|
|
|
|
void __user *data; /* param buffer (in, or out) */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* You can do most things with hubs just through control messages,
|
|
|
|
* except find out what device connects to what port. */
|
|
|
|
struct usbdevfs_hub_portinfo {
|
|
|
|
char nports; /* number of downstream ports in this hub */
|
|
|
|
char port [127]; /* e.g. port 3 connects to device 27 */
|
|
|
|
};
|
|
|
|
|
usbdevfs: Add a USBDEVFS_GET_CAPABILITIES ioctl
There are a few (new) usbdevfs capabilities which an application cannot
discover in any other way then checking the kernel version. There are 3
problems with this:
1) It is just not very pretty.
2) Given the tendency of enterprise distros to backport stuff it is not
reliable.
3) As discussed in length on the mailinglist, USBDEVFS_URB_BULK_CONTINUATION
does not work as it should when combined with USBDEVFS_URB_SHORT_NOT_OK
(which is its intended use) on devices attached to an XHCI controller.
So the availability of these features can be host controller dependent,
making depending on them based on the kernel version not a good idea.
This patch besides adding the new ioctl also adds flags for the following
existing capabilities:
USBDEVFS_CAP_ZERO_PACKET, available since 2.6.31
USBDEVFS_CAP_BULK_CONTINUATION, available since 2.6.32, except for XHCI
USBDEVFS_CAP_NO_PACKET_SIZE_LIM, available since 3.3
Note that this patch only does not advertise the USBDEVFS_URB_BULK_CONTINUATION
cap for XHCI controllers, bulk transfers with this flag set will still be
accepted when submitted to XHCI controllers.
Returning -EINVAL for them would break existing apps, and in most cases the
troublesome scenario wrt USBDEVFS_URB_SHORT_NOT_OK urbs on XHCI controllers
will never get hit, so this would break working use cases.
The disadvantage of not returning -EINVAL is that cases were it is causing
real trouble may go undetected / the cause of the trouble may be unclear,
but this is the best we can do.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-04 01:18:02 -06:00
|
|
|
/* Device capability flags */
|
|
|
|
#define USBDEVFS_CAP_ZERO_PACKET 0x01
|
|
|
|
#define USBDEVFS_CAP_BULK_CONTINUATION 0x02
|
|
|
|
#define USBDEVFS_CAP_NO_PACKET_SIZE_LIM 0x04
|
2012-07-04 01:18:03 -06:00
|
|
|
#define USBDEVFS_CAP_BULK_SCATTER_GATHER 0x08
|
usbdevfs: Add a USBDEVFS_GET_CAPABILITIES ioctl
There are a few (new) usbdevfs capabilities which an application cannot
discover in any other way then checking the kernel version. There are 3
problems with this:
1) It is just not very pretty.
2) Given the tendency of enterprise distros to backport stuff it is not
reliable.
3) As discussed in length on the mailinglist, USBDEVFS_URB_BULK_CONTINUATION
does not work as it should when combined with USBDEVFS_URB_SHORT_NOT_OK
(which is its intended use) on devices attached to an XHCI controller.
So the availability of these features can be host controller dependent,
making depending on them based on the kernel version not a good idea.
This patch besides adding the new ioctl also adds flags for the following
existing capabilities:
USBDEVFS_CAP_ZERO_PACKET, available since 2.6.31
USBDEVFS_CAP_BULK_CONTINUATION, available since 2.6.32, except for XHCI
USBDEVFS_CAP_NO_PACKET_SIZE_LIM, available since 3.3
Note that this patch only does not advertise the USBDEVFS_URB_BULK_CONTINUATION
cap for XHCI controllers, bulk transfers with this flag set will still be
accepted when submitted to XHCI controllers.
Returning -EINVAL for them would break existing apps, and in most cases the
troublesome scenario wrt USBDEVFS_URB_SHORT_NOT_OK urbs on XHCI controllers
will never get hit, so this would break working use cases.
The disadvantage of not returning -EINVAL is that cases were it is causing
real trouble may go undetected / the cause of the trouble may be unclear,
but this is the best we can do.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-04 01:18:02 -06:00
|
|
|
|
2006-04-25 08:14:50 -06:00
|
|
|
#ifdef __KERNEL__
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifdef CONFIG_COMPAT
|
2005-09-03 03:27:08 -06:00
|
|
|
#include <linux/compat.h>
|
2009-11-13 18:28:05 -07:00
|
|
|
|
|
|
|
struct usbdevfs_ctrltransfer32 {
|
|
|
|
u8 bRequestType;
|
|
|
|
u8 bRequest;
|
|
|
|
u16 wValue;
|
|
|
|
u16 wIndex;
|
|
|
|
u16 wLength;
|
|
|
|
u32 timeout; /* in milliseconds */
|
|
|
|
compat_caddr_t data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_bulktransfer32 {
|
|
|
|
compat_uint_t ep;
|
|
|
|
compat_uint_t len;
|
|
|
|
compat_uint_t timeout; /* in milliseconds */
|
|
|
|
compat_caddr_t data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct usbdevfs_disconnectsignal32 {
|
|
|
|
compat_int_t signr;
|
|
|
|
compat_caddr_t context;
|
|
|
|
};
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
struct usbdevfs_urb32 {
|
|
|
|
unsigned char type;
|
|
|
|
unsigned char endpoint;
|
|
|
|
compat_int_t status;
|
|
|
|
compat_uint_t flags;
|
|
|
|
compat_caddr_t buffer;
|
|
|
|
compat_int_t buffer_length;
|
|
|
|
compat_int_t actual_length;
|
|
|
|
compat_int_t start_frame;
|
|
|
|
compat_int_t number_of_packets;
|
|
|
|
compat_int_t error_count;
|
|
|
|
compat_uint_t signr;
|
|
|
|
compat_caddr_t usercontext; /* unused */
|
|
|
|
struct usbdevfs_iso_packet_desc iso_frame_desc[0];
|
|
|
|
};
|
[PATCH] usb: Patch for USBDEVFS_IOCTL from 32-bit programs
Dell supplied me with the following test:
#include<stdio.h>
#include<errno.h>
#include<sys/ioctl.h>
#include<fcntl.h>
#include<linux/usbdevice_fs.h>
main(int argc,char*argv[])
{
struct usbdevfs_hub_portinfo hubPortInfo = {0};
struct usbdevfs_ioctl command = {0};
command.ifno = 0;
command.ioctl_code = USBDEVFS_HUB_PORTINFO;
command.data = (void*)&hubPortInfo;
int fd, ret;
if(argc != 2) {
fprintf(stderr,"Usage: %s /proc/bus/usb/<BusNo>/<HubID>\n",argv[0]);
fprintf(stderr,"Example: %s /proc/bus/usb/001/001\n",argv[0]);
exit(1);
}
errno = 0;
fd = open(argv[1],O_RDWR);
if(fd < 0) {
perror("open failed:");
exit(errno);
}
errno = 0;
ret = ioctl(fd,USBDEVFS_IOCTL,&command);
printf("IOCTL return status:%d\n",ret);
if(ret<0) {
perror("IOCTL failed:");
close(fd);
exit(3);
} else {
printf("IOCTL passed:Num of ports %d\n",hubPortInfo.nports);
close(fd);
exit(0);
}
return 0;
}
I have verified that it breaks if built in 32 bit mode on x86_64 and that
the patch below fixes it.
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-10-17 19:15:54 -06:00
|
|
|
|
|
|
|
struct usbdevfs_ioctl32 {
|
|
|
|
s32 ifno;
|
|
|
|
s32 ioctl_code;
|
|
|
|
compat_caddr_t data;
|
|
|
|
};
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
2006-04-25 08:14:50 -06:00
|
|
|
#endif /* __KERNEL__ */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#define USBDEVFS_CONTROL _IOWR('U', 0, struct usbdevfs_ctrltransfer)
|
2009-11-13 18:28:05 -07:00
|
|
|
#define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32)
|
2005-04-16 16:20:36 -06:00
|
|
|
#define USBDEVFS_BULK _IOWR('U', 2, struct usbdevfs_bulktransfer)
|
2009-11-13 18:28:05 -07:00
|
|
|
#define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32)
|
2005-04-16 16:20:36 -06:00
|
|
|
#define USBDEVFS_RESETEP _IOR('U', 3, unsigned int)
|
|
|
|
#define USBDEVFS_SETINTERFACE _IOR('U', 4, struct usbdevfs_setinterface)
|
|
|
|
#define USBDEVFS_SETCONFIGURATION _IOR('U', 5, unsigned int)
|
|
|
|
#define USBDEVFS_GETDRIVER _IOW('U', 8, struct usbdevfs_getdriver)
|
|
|
|
#define USBDEVFS_SUBMITURB _IOR('U', 10, struct usbdevfs_urb)
|
|
|
|
#define USBDEVFS_SUBMITURB32 _IOR('U', 10, struct usbdevfs_urb32)
|
|
|
|
#define USBDEVFS_DISCARDURB _IO('U', 11)
|
|
|
|
#define USBDEVFS_REAPURB _IOW('U', 12, void *)
|
2007-02-05 17:41:03 -07:00
|
|
|
#define USBDEVFS_REAPURB32 _IOW('U', 12, __u32)
|
2005-04-16 16:20:36 -06:00
|
|
|
#define USBDEVFS_REAPURBNDELAY _IOW('U', 13, void *)
|
2007-02-05 17:41:03 -07:00
|
|
|
#define USBDEVFS_REAPURBNDELAY32 _IOW('U', 13, __u32)
|
2005-04-16 16:20:36 -06:00
|
|
|
#define USBDEVFS_DISCSIGNAL _IOR('U', 14, struct usbdevfs_disconnectsignal)
|
2009-11-13 18:28:05 -07:00
|
|
|
#define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32)
|
2005-04-16 16:20:36 -06:00
|
|
|
#define USBDEVFS_CLAIMINTERFACE _IOR('U', 15, unsigned int)
|
|
|
|
#define USBDEVFS_RELEASEINTERFACE _IOR('U', 16, unsigned int)
|
|
|
|
#define USBDEVFS_CONNECTINFO _IOW('U', 17, struct usbdevfs_connectinfo)
|
|
|
|
#define USBDEVFS_IOCTL _IOWR('U', 18, struct usbdevfs_ioctl)
|
[PATCH] usb: Patch for USBDEVFS_IOCTL from 32-bit programs
Dell supplied me with the following test:
#include<stdio.h>
#include<errno.h>
#include<sys/ioctl.h>
#include<fcntl.h>
#include<linux/usbdevice_fs.h>
main(int argc,char*argv[])
{
struct usbdevfs_hub_portinfo hubPortInfo = {0};
struct usbdevfs_ioctl command = {0};
command.ifno = 0;
command.ioctl_code = USBDEVFS_HUB_PORTINFO;
command.data = (void*)&hubPortInfo;
int fd, ret;
if(argc != 2) {
fprintf(stderr,"Usage: %s /proc/bus/usb/<BusNo>/<HubID>\n",argv[0]);
fprintf(stderr,"Example: %s /proc/bus/usb/001/001\n",argv[0]);
exit(1);
}
errno = 0;
fd = open(argv[1],O_RDWR);
if(fd < 0) {
perror("open failed:");
exit(errno);
}
errno = 0;
ret = ioctl(fd,USBDEVFS_IOCTL,&command);
printf("IOCTL return status:%d\n",ret);
if(ret<0) {
perror("IOCTL failed:");
close(fd);
exit(3);
} else {
printf("IOCTL passed:Num of ports %d\n",hubPortInfo.nports);
close(fd);
exit(0);
}
return 0;
}
I have verified that it breaks if built in 32 bit mode on x86_64 and that
the patch below fixes it.
Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2005-10-17 19:15:54 -06:00
|
|
|
#define USBDEVFS_IOCTL32 _IOWR('U', 18, struct usbdevfs_ioctl32)
|
2005-04-16 16:20:36 -06:00
|
|
|
#define USBDEVFS_HUB_PORTINFO _IOR('U', 19, struct usbdevfs_hub_portinfo)
|
|
|
|
#define USBDEVFS_RESET _IO('U', 20)
|
|
|
|
#define USBDEVFS_CLEAR_HALT _IOR('U', 21, unsigned int)
|
|
|
|
#define USBDEVFS_DISCONNECT _IO('U', 22)
|
|
|
|
#define USBDEVFS_CONNECT _IO('U', 23)
|
2009-06-29 08:56:54 -06:00
|
|
|
#define USBDEVFS_CLAIM_PORT _IOR('U', 24, unsigned int)
|
|
|
|
#define USBDEVFS_RELEASE_PORT _IOR('U', 25, unsigned int)
|
usbdevfs: Add a USBDEVFS_GET_CAPABILITIES ioctl
There are a few (new) usbdevfs capabilities which an application cannot
discover in any other way then checking the kernel version. There are 3
problems with this:
1) It is just not very pretty.
2) Given the tendency of enterprise distros to backport stuff it is not
reliable.
3) As discussed in length on the mailinglist, USBDEVFS_URB_BULK_CONTINUATION
does not work as it should when combined with USBDEVFS_URB_SHORT_NOT_OK
(which is its intended use) on devices attached to an XHCI controller.
So the availability of these features can be host controller dependent,
making depending on them based on the kernel version not a good idea.
This patch besides adding the new ioctl also adds flags for the following
existing capabilities:
USBDEVFS_CAP_ZERO_PACKET, available since 2.6.31
USBDEVFS_CAP_BULK_CONTINUATION, available since 2.6.32, except for XHCI
USBDEVFS_CAP_NO_PACKET_SIZE_LIM, available since 3.3
Note that this patch only does not advertise the USBDEVFS_URB_BULK_CONTINUATION
cap for XHCI controllers, bulk transfers with this flag set will still be
accepted when submitted to XHCI controllers.
Returning -EINVAL for them would break existing apps, and in most cases the
troublesome scenario wrt USBDEVFS_URB_SHORT_NOT_OK urbs on XHCI controllers
will never get hit, so this would break working use cases.
The disadvantage of not returning -EINVAL is that cases were it is causing
real trouble may go undetected / the cause of the trouble may be unclear,
but this is the best we can do.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-07-04 01:18:02 -06:00
|
|
|
#define USBDEVFS_GET_CAPABILITIES _IOR('U', 26, __u32)
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif /* _LINUX_USBDEVICE_FS_H */
|