Re: Reading the frame number field

Alan Stern <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Fri, 13 Apr 2007, Danny Budik wrote:

> I had to recompile the kernel with the changes I made. In the patch  
> that I sent yesterday, I forgot to include the changes that I made in  
> the file
> /include/linux/usbdevice_fs.h.  I added the constant for the ioctl call:
> 
> #define USBDEVFS_GETFRAMENUM       _IOW('U', 24, int)
> 
> After making these changes, recompiling the 2.6.15 kernel, and making  
> a quick and dirty test program, I get the following error before my  
> program dies:
> 
> opening card at path /dev/bus/usb/001/008
> opened card: 128
> errno: Inappropriate ioctl for device
> 
> So it seems that by adding the ioctl to usbdevice_fs.h isn't enough.  
> Is there a table somewhere else where I would need to define the  
> ioctl so that it's recognized by the kernel?

No; what you did was sufficient.  Most likely there is something wrong 
with your user program.

> My changes that I've made are below:

Your email client mangled the patch.  Here is a cleaned-up version.  If 
you like, I can submit it for inclusion in the kernel.

Alan Stern



Index: usb-2.6/drivers/usb/core/devio.c
===================================================================
--- usb-2.6.orig/drivers/usb/core/devio.c
+++ usb-2.6/drivers/usb/core/devio.c
@@ -831,6 +831,16 @@ static int proc_getdriver(struct dev_sta
 	return ret;
 }
 
+static int proc_getframenum(struct dev_state *ps, void __user *arg)
+{
+	int frame_number;
+
+	frame_number = usb_get_current_frame_number(ps->dev);
+	if (put_user(frame_number, (int __user *)arg))
+		return -EFAULT;
+	return 0;
+}
+
 static int proc_connectinfo(struct dev_state *ps, void __user *arg)
 {
 	struct usbdevfs_connectinfo ci;
@@ -1567,6 +1577,12 @@ static int usbdev_ioctl(struct inode *in
 		snoop(&dev->dev, "%s: IOCTL\n", __FUNCTION__);
 		ret = proc_ioctl_default(ps, p);
 		break;
+
+	case USBDEVFS_GETFRAMENUM:
+		snoop(&dev->dev, "%s: GETFRAMENUM\n", __FUNCTION__);
+		ret = proc_getframenum(ps, p);
+		break;
+
 	}
 	usb_unlock_device(dev);
 	if (ret >= 0)
Index: usb-2.6/include/linux/usbdevice_fs.h
===================================================================
--- usb-2.6.orig/include/linux/usbdevice_fs.h
+++ usb-2.6/include/linux/usbdevice_fs.h
@@ -173,4 +173,5 @@ struct usbdevfs_ioctl32 {
 #define USBDEVFS_CLEAR_HALT        _IOR('U', 21, unsigned int)
 #define USBDEVFS_DISCONNECT        _IO('U', 22)
 #define USBDEVFS_CONNECT           _IO('U', 23)
+#define USBDEVFS_GETFRAMENUM       _IOW('U', 24, int)
 #endif /* _LINUX_USBDEVICE_FS_H */


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.