Re: Reading the frame number field

Danny Budik <[email protected]>
Newsgroups gmane.linux.usb.devel
Message-ID <[email protected]>
On Apr 13, 2007, at 12:01 PM, Alan Stern wrote:
> Depends what you mean.  The kernel-build system is smart enough to
> recompile only the files you have changed (and those that depend on  
> them).
> If what you changed is in a module instead of built into the main  
> kernel
> binary, then only that module needs to be rebuilt.  Then you can  
> rmmod the
> old module and insmod the new one without even rebooting.

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?

My changes that I've made are below:

--- linux-source-2.6.15/drivers/usb/core/devio.c	2006-03-02  
16:18:38.000000000 -0500
+++ devel/drivers/usb/core/devio.c	2007-04-13 17:07:16.000000000 -0400
@@ -815,6 +815,20 @@ static int proc_getdriver(struct dev_sta
	return ret;
}
+static int proc_getframenum(struct dev_state *ps, void __user *arg)
+{
+	int frame_number;
+	struct usb_device *dev = ps->dev;
+
+	frame_number = usb_get_current_frame_number(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;
@@ -1549,6 +1563,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)
--- linux-source-2.6.15/include/linux/usbdevice_fs.h	2006-03-02  
16:18:41.000000000 -0500
+++ devel/include/linux/usbdevice_fs.h	2007-04-13 17:09:29.000000000  
-0400
@@ -172,4 +172,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 */


----
Danny Budik
Research Engineer
Inductive Signature Technologies, Inc.
http://www.ist-traffic.com
(865) 673-9434




-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
[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.