Re: [patch] rio500 devfs support
It's working beautifully here. I'll forward the patch to the maintainer, since I have no idea if he's seen this thread. Cheers! PGP signature
Re: [patch] rio500 devfs support
On Mon, Jun 25, 2001 at 05:12:01PM -0500, Gregory T. Norris wrote: > I was thinking of doing some similar updates this evening after work. > Darn it... now I have to find something else to do! :-) > > Going by this morning's comments from Richard Gooch, it sounds like the > > if (rio->devfs == NULL) > dbg("probe_rio: device node registration failed"); Just don't have it be using a call to "err()" like the printer.c file does. Loads of users wondering why they have an error message in their logs, yet their printers still work. That's why I made it dbg(). But yes, I agree that it doesn't have to be there at all. greg k-h - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [patch] rio500 devfs support
I was thinking of doing some similar updates this evening after work. Darn it... now I have to find something else to do! :-) Going by this morning's comments from Richard Gooch, it sounds like the if (rio->devfs == NULL) dbg("probe_rio: device node registration failed"); part should probably be removed... it looks good to me otherwise, tho. I'll try it out tonight and post the results. Cheers! On Mon, Jun 25, 2001 at 10:35:21AM -0700, Greg KH wrote: > Here's a small change that makes the node a child of the usb devfs > entry. It also enables the node to only be present when the device is > actually present. The patch is against 2.4.6-pre5. > > thanks, > > greg k-h PGP signature
Re: [patch] rio500 devfs support
On Tue, Jun 19, 2001 at 05:52:24PM -0500, Gregory T. Norris wrote: > The attached diff adds devfs support to the rio500 driver, so that > /dev/usb/rio500 gets created automagically. It was generated against > 2.4.5, but probably applies fine against any recent kernel. Comments > are welcome (but be gentle, this is my first attempt at a kernel > patch :-). Here's a small change that makes the node a child of the usb devfs entry. It also enables the node to only be present when the device is actually present. The patch is against 2.4.6-pre5. thanks, greg k-h diff -Nru a/drivers/usb/rio500.c b/drivers/usb/rio500.c --- a/drivers/usb/rio500.c Mon Jun 25 10:31:03 2001 +++ b/drivers/usb/rio500.c Mon Jun 25 10:31:03 2001 @@ -38,13 +38,14 @@ #include #include #include +#include #include "rio500_usb.h" /* * Version Information */ -#define DRIVER_VERSION "v1.0.0" +#define DRIVER_VERSION "v1.1" #define DRIVER_AUTHOR "Cesar Miquel <[EMAIL PROTECTED]>" #define DRIVER_DESC "USB Rio 500 driver" @@ -60,6 +61,7 @@ struct rio_usb_data { struct usb_device *rio_dev; /* init: probe_rio */ +devfs_handle_t devfs; /* devfs device */ unsigned int ifnum; /* Interface number of the USB device */ int isopen; /* nz if open */ int present;/* Device is present on the bus */ @@ -69,6 +71,8 @@ struct semaphore lock; /* general race avoidance */ }; +extern devfs_handle_t usb_devfs_handle;/* /dev/usb dir. */ + static struct rio_usb_data rio_instance; static int open_rio(struct inode *inode, struct file *file) @@ -416,6 +420,15 @@ return read_count; } +static struct +file_operations usb_rio_fops = { + read: read_rio, + write: write_rio, + ioctl: ioctl_rio, + open: open_rio, + release:close_rio, +}; + static void *probe_rio(struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id) { @@ -439,6 +452,14 @@ } dbg("probe_rio: ibuf address:%p", rio->ibuf); + rio->devfs = devfs_register(usb_devfs_handle, "rio500", + DEVFS_FL_DEFAULT, USB_MAJOR, + RIO_MINOR, + S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | + S_IWGRP, &usb_rio_fops, NULL); + if (rio->devfs == NULL) + dbg("probe_rio: device node registration failed"); + init_MUTEX(&(rio->lock)); return rio; @@ -448,6 +469,8 @@ { struct rio_usb_data *rio = (struct rio_usb_data *) ptr; + devfs_unregister(rio->devfs); + if (rio->isopen) { rio->isopen = 0; /* better let it finish - the release will do whats needed */ @@ -461,15 +484,6 @@ rio->present = 0; } - -static struct -file_operations usb_rio_fops = { - read: read_rio, - write: write_rio, - ioctl: ioctl_rio, - open: open_rio, - release:close_rio, -}; static struct usb_device_id rio_table [] = { { USB_DEVICE(0x0841, 1) }, /* Rio 500 */
Re: [patch] rio500 devfs support
Ok, back to the original version then. Thanx! On Mon, Jun 25, 2001 at 12:16:51AM -0600, Richard Gooch wrote: > No, it's a bad idea to test the error from devfs_register() unless you > *really* have a good reason. Most people who think they have a good > reason actually don't, they're just confused :-) > > The reason you don't want to test the return value is that way the > driver works fine with CONFIG_DEVFS=n. Otherwise, you have a driver > that doesn't work with devfs, or you have to put ugly #ifdef's in the > code. > > Regards, > > Richard > Permanent: [EMAIL PROTECTED] > Current: [EMAIL PROTECTED] PGP signature
Re: [patch] rio500 devfs support
Gregory T. Norris writes: > > --qlTNgmc+xy1dBmNv > Content-Type: multipart/mixed; boundary="0F1p//8PRICkK4MW" > Content-Disposition: inline Yuk! MIME! > --0F1p//8PRICkK4MW > Content-Type: text/plain; charset=us-ascii > Content-Disposition: inline > Content-Transfer-Encoding: quoted-printable Horrors! Quoted-printables! > Here's an updated version of the patch - the only real difference is > that rio500.c will printk an error message if devfs_register() fails.=20 > I left that out originally because devfs logs the error, but it's > probably a good idea to indicate which driver made the request. No, it's a bad idea to test the error from devfs_register() unless you *really* have a good reason. Most people who think they have a good reason actually don't, they're just confused :-) The reason you don't want to test the return value is that way the driver works fine with CONFIG_DEVFS=n. Otherwise, you have a driver that doesn't work with devfs, or you have to put ugly #ifdef's in the code. Regards, Richard Permanent: [EMAIL PROTECTED] Current: [EMAIL PROTECTED] - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [patch] rio500 devfs support
Here's an updated version of the patch - the only real difference is that rio500.c will printk an error message if devfs_register() fails. I left that out originally because devfs logs the error, but it's probably a good idea to indicate which driver made the request. Cheers! On Tue, Jun 19, 2001 at 05:52:24PM -0500, Gregory T. Norris wrote: > The attached diff adds devfs support to the rio500 driver, so that > /dev/usb/rio500 gets created automagically. It was generated against > 2.4.5, but probably applies fine against any recent kernel. Comments > are welcome (but be gentle, this is my first attempt at a kernel > patch :-). > > Cheers! diff -urN linux-2.4.5.orig/drivers/usb/rio500.c linux-2.4.5/drivers/usb/rio500.c --- linux-2.4.5.orig/drivers/usb/rio500.c Sun Jun 24 16:29:35 2001 +++ linux-2.4.5/drivers/usb/rio500.cSun Jun 24 16:45:08 2001 @@ -38,6 +38,7 @@ #include #include #include +#include #include "rio500_usb.h" @@ -70,6 +71,7 @@ }; static struct rio_usb_data rio_instance; +static devfs_handle_t rio500_devfs_handle; static int open_rio(struct inode *inode, struct file *file) { @@ -492,6 +494,14 @@ if (usb_register(&rio_driver) < 0) return -1; + rio500_devfs_handle = devfs_register(NULL, "usb/rio500", + DEVFS_FL_DEFAULT, + USB_MAJOR, RIO_MINOR, + S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | +S_IWGRP, + &usb_rio_fops, NULL); + if (rio500_devfs_handle == NULL) + printk(KERN_WARNING __FILE__ ": unable to register /dev/usb/rio500 +with devfs\n"); + info(DRIVER_VERSION " " DRIVER_AUTHOR); info(DRIVER_DESC); @@ -506,6 +516,8 @@ rio->present = 0; usb_deregister(&rio_driver); + if (rio500_devfs_handle != NULL) + devfs_unregister(rio500_devfs_handle); } PGP signature
[patch] rio500 devfs support
The attached diff adds devfs support to the rio500 driver, so that /dev/usb/rio500 gets created automagically. It was generated against 2.4.5, but probably applies fine against any recent kernel. Comments are welcome (but be gentle, this is my first attempt at a kernel patch :-). Cheers! diff -urN linux-2.4.5.orig/drivers/usb/rio500.c linux-2.4.5/drivers/usb/rio500.c --- linux-2.4.5.orig/drivers/usb/rio500.c Mon Jun 18 17:10:39 2001 +++ linux-2.4.5/drivers/usb/rio500.cTue Jun 19 17:12:26 2001 @@ -38,6 +38,7 @@ #include #include #include +#include #include "rio500_usb.h" @@ -70,6 +71,7 @@ }; static struct rio_usb_data rio_instance; +static devfs_handle_t rio500_devfs_handle; static int open_rio(struct inode *inode, struct file *file) { @@ -492,6 +494,12 @@ if (usb_register(&rio_driver) < 0) return -1; + rio500_devfs_handle = devfs_register(NULL, "usb/rio500", + DEVFS_FL_DEFAULT, + USB_MAJOR, RIO_MINOR, + S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | +S_IWGRP, + &usb_rio_fops, NULL); + info(DRIVER_VERSION " " DRIVER_AUTHOR); info(DRIVER_DESC); @@ -506,6 +514,7 @@ rio->present = 0; usb_deregister(&rio_driver); + devfs_unregister(rio500_devfs_handle); } PGP signature