* [patch] rio500 devfs support
@ 2001-06-19 22:52 Gregory T. Norris
2001-06-24 22:37 ` Gregory T. Norris
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Gregory T. Norris @ 2001-06-19 22:52 UTC (permalink / raw)
To: rio500-devel, linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 292 bytes --]
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!
[-- Attachment #1.2: rio500-devfs.diff --]
[-- Type: text/plain, Size: 1047 bytes --]
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.c Tue Jun 19 17:12:26 2001
@@ -38,6 +38,7 @@
#include <linux/spinlock.h>
#include <linux/usb.h>
#include <linux/smp_lock.h>
+#include <linux/devfs_fs_kernel.h>
#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);
}
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] rio500 devfs support
2001-06-19 22:52 [patch] rio500 devfs support Gregory T. Norris
@ 2001-06-24 22:37 ` Gregory T. Norris
2001-06-25 6:16 ` Richard Gooch
2001-06-25 17:35 ` Greg KH
2 siblings, 0 replies; 8+ messages in thread
From: Gregory T. Norris @ 2001-06-24 22:37 UTC (permalink / raw)
To: rio500-devel; +Cc: linux-kernel
[-- Attachment #1.1: Type: text/plain, Size: 668 bytes --]
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!
[-- Attachment #1.2: rio500-devfs-02.diff --]
[-- Type: text/plain, Size: 1207 bytes --]
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.c Sun Jun 24 16:45:08 2001
@@ -38,6 +38,7 @@
#include <linux/spinlock.h>
#include <linux/usb.h>
#include <linux/smp_lock.h>
+#include <linux/devfs_fs_kernel.h>
#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);
}
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] rio500 devfs support
2001-06-19 22:52 [patch] rio500 devfs support Gregory T. Norris
2001-06-24 22:37 ` Gregory T. Norris
@ 2001-06-25 6:16 ` Richard Gooch
2001-06-25 11:43 ` Gregory T. Norris
2001-06-25 17:35 ` Greg KH
2 siblings, 1 reply; 8+ messages in thread
From: Richard Gooch @ 2001-06-25 6:16 UTC (permalink / raw)
To: Gregory T. Norris; +Cc: rio500-devel, linux-kernel
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: rgooch@atnf.csiro.au
Current: rgooch@ras.ucalgary.ca
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] rio500 devfs support
2001-06-25 6:16 ` Richard Gooch
@ 2001-06-25 11:43 ` Gregory T. Norris
0 siblings, 0 replies; 8+ messages in thread
From: Gregory T. Norris @ 2001-06-25 11:43 UTC (permalink / raw)
To: rio500-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 654 bytes --]
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: rgooch@atnf.csiro.au
> Current: rgooch@ras.ucalgary.ca
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] rio500 devfs support
2001-06-19 22:52 [patch] rio500 devfs support Gregory T. Norris
2001-06-24 22:37 ` Gregory T. Norris
2001-06-25 6:16 ` Richard Gooch
@ 2001-06-25 17:35 ` Greg KH
2001-06-25 22:12 ` Gregory T. Norris
2 siblings, 1 reply; 8+ messages in thread
From: Greg KH @ 2001-06-25 17:35 UTC (permalink / raw)
To: rio500-devel, linux-kernel; +Cc: linux-usb-devel
[-- Attachment #1: Type: text/plain, Size: 570 bytes --]
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
[-- Attachment #2: usb-rio500-2.4.6-pre5.patch --]
[-- Type: text/plain, Size: 2405 bytes --]
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 <linux/spinlock.h>
#include <linux/usb.h>
#include <linux/smp_lock.h>
+#include <linux/devfs_fs_kernel.h>
#include "rio500_usb.h"
/*
* Version Information
*/
-#define DRIVER_VERSION "v1.0.0"
+#define DRIVER_VERSION "v1.1"
#define DRIVER_AUTHOR "Cesar Miquel <miquel@df.uba.ar>"
#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 */
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] rio500 devfs support
2001-06-25 17:35 ` Greg KH
@ 2001-06-25 22:12 ` Gregory T. Norris
2001-06-26 5:07 ` Greg KH
2001-07-01 20:55 ` Gregory T. Norris
0 siblings, 2 replies; 8+ messages in thread
From: Gregory T. Norris @ 2001-06-25 22:12 UTC (permalink / raw)
To: rio500-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 710 bytes --]
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
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] rio500 devfs support
2001-06-25 22:12 ` Gregory T. Norris
@ 2001-06-26 5:07 ` Greg KH
2001-07-01 20:55 ` Gregory T. Norris
1 sibling, 0 replies; 8+ messages in thread
From: Greg KH @ 2001-06-26 5:07 UTC (permalink / raw)
To: rio500-devel, linux-kernel
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [patch] rio500 devfs support
2001-06-25 22:12 ` Gregory T. Norris
2001-06-26 5:07 ` Greg KH
@ 2001-07-01 20:55 ` Gregory T. Norris
1 sibling, 0 replies; 8+ messages in thread
From: Gregory T. Norris @ 2001-07-01 20:55 UTC (permalink / raw)
To: rio500-devel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 130 bytes --]
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!
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2001-07-01 20:55 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-19 22:52 [patch] rio500 devfs support Gregory T. Norris
2001-06-24 22:37 ` Gregory T. Norris
2001-06-25 6:16 ` Richard Gooch
2001-06-25 11:43 ` Gregory T. Norris
2001-06-25 17:35 ` Greg KH
2001-06-25 22:12 ` Gregory T. Norris
2001-06-26 5:07 ` Greg KH
2001-07-01 20:55 ` Gregory T. Norris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).