This patch adds ioctls to get the active config# and interface setting# 
through usbfs.  

As far as I can tell, the only way to currently get the active config is 
via the devices file (generates bus traffic, I'd rather not use it) and 
there is no way from userspace to determine the active interface alternate 
setting.

The get-interface ioctl uses "struct usbdevfs_setinterface".  It could 
be changed to use "struct usbdevfs_getinterface", and just add a
#define usbdevfs_getinterface usbdevfs_setinterface
above the struct definition.


--- usb-2.5/include/linux/usbdevice_fs.h        Tue Oct  8 18:53:43 2002
+++ linux-bk/include/linux/usbdevice_fs.h       Tue Oct 29 00:32:18 2002
@@ -128,6 +128,8 @@
 #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_GETCONFIGURATION  _IOW('U', 6, unsigned int)
+#define USBDEVFS_GETINTERFACE      _IOW('U', 7, struct usbdevfs_setinterface)
 #define USBDEVFS_GETDRIVER         _IOW('U', 8, struct usbdevfs_getdriver)
 #define USBDEVFS_SUBMITURB         _IOR('U', 10, struct usbdevfs_urb)
 #define USBDEVFS_DISCARDURB        _IO('U', 11)
--- usb-2.5/drivers/usb/core/devio.c    Tue Oct  8 18:53:39 2002
+++ linux-bk/drivers/usb/core/devio.c   Tue Oct 29 01:56:57 2002
@@ -709,6 +709,25 @@
        return 0;
 }
 
+static int proc_getintf(struct dev_state *ps, void *arg)
+{
+       struct usbdevfs_setinterface setintf;
+       struct usb_interface *interface;
+       int ret;
+
+       if (copy_from_user(&setintf, arg, sizeof(setintf)))
+               return -EFAULT;
+       if ((ret = findintfif(ps->dev, setintf.interface)) < 0)
+               return ret;
+       interface = usb_ifnum_to_if(ps->dev, setintf.interface);
+       if (!interface)
+               return -EINVAL;
+       setintf.altsetting = interface->act_altsetting;
+       if (copy_to_user(arg, &setintf, sizeof(setintf)))
+               return -EFAULT;
+       return 0;
+}
+
 static int proc_setintf(struct dev_state *ps, void *arg)
 {
        struct usbdevfs_setinterface setintf;
@@ -731,6 +750,16 @@
        return 0;
 }
 
+static int proc_getconfig(struct dev_state *ps, void *arg)
+{
+       unsigned int u;
+
+       u = ps->dev->actconfig->bConfigurationValue;
+       if (put_user(u, (unsigned int *)arg))
+               return -EFAULT;
+       return 0;
+}
+
 static int proc_setconfig(struct dev_state *ps, void *arg)
 {
        unsigned int u;
@@ -1178,8 +1207,16 @@
                ret = proc_connectinfo(ps, (void *)arg);
                break;
 
+       case USBDEVFS_GETINTERFACE:
+               ret = proc_getintf(ps, (void *)arg);
+               break;
+
        case USBDEVFS_SETINTERFACE:
                ret = proc_setintf(ps, (void *)arg);
+               break;
+
+       case USBDEVFS_GETCONFIGURATION:
+               ret = proc_getconfig(ps, (void *)arg);
                break;
 
        case USBDEVFS_SETCONFIGURATION:



-------------------------------------------------------
This sf.net email is sponsored by: Influence the future 
of Java(TM) technology. Join the Java Community 
Process(SM) (JCP(SM)) program now. 
http://ads.sourceforge.net/cgi-bin/redirect.pl?sunm0004en
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to