Commit fbb3b3eb authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

[PATCH] USB: converted usb-skeleton over to new usb_register_dev() changes.

parent 7a3156f2
/* /*
* USB Skeleton driver - 1.0 * USB Skeleton driver - 1.1
* *
* Copyright (c) 2001-2002 Greg Kroah-Hartman (greg@kroah.com) * Copyright (c) 2001-2002 Greg Kroah-Hartman (greg@kroah.com)
* *
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
* *
* History: * History:
* *
* 2003-05-06 - 1.1 - changes due to usb core changes with usb_register_dev()
* 2003-02-25 - 1.0 - fix races involving urb->status, unlink_urb(), and * 2003-02-25 - 1.0 - fix races involving urb->status, unlink_urb(), and
* disconnect. Fix transfer amount in read(). Use * disconnect. Fix transfer amount in read(). Use
* macros instead of magic numbers in probe(). Change * macros instead of magic numbers in probe(). Change
...@@ -47,7 +48,6 @@ ...@@ -47,7 +48,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/smp_lock.h> #include <linux/smp_lock.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/devfs_fs_kernel.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <linux/usb.h> #include <linux/usb.h>
...@@ -159,6 +159,16 @@ static struct file_operations skel_fops = { ...@@ -159,6 +159,16 @@ static struct file_operations skel_fops = {
.release = skel_release, .release = skel_release,
}; };
/*
* usb class driver info in order to get a minor number from the usb core,
* and to have the device registered with devfs and the driver core
*/
static struct usb_class_driver skell_class = {
.name = "usb/skel%d",
.fops = &skel_fops,
.mode = S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH,
.minor_base = USB_SKEL_MINOR_BASE,
};
/* usb specific object needed to register this driver with the usb subsystem */ /* usb specific object needed to register this driver with the usb subsystem */
static struct usb_driver skel_driver = { static struct usb_driver skel_driver = {
...@@ -493,7 +503,6 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i ...@@ -493,7 +503,6 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
struct usb_skel *dev = NULL; struct usb_skel *dev = NULL;
struct usb_host_interface *iface_desc; struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
int minor;
size_t buffer_size; size_t buffer_size;
int i; int i;
int retval; int retval;
...@@ -506,7 +515,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i ...@@ -506,7 +515,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
return -ENODEV; return -ENODEV;
} }
retval = usb_register_dev (&skel_fops, USB_SKEL_MINOR_BASE, 1, &minor); retval = usb_register_dev (intf, &skel_class);
if (retval) { if (retval) {
/* something prevented us from registering this driver */ /* something prevented us from registering this driver */
err ("Not able to get a minor for this device."); err ("Not able to get a minor for this device.");
...@@ -524,7 +533,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i ...@@ -524,7 +533,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
init_MUTEX (&dev->sem); init_MUTEX (&dev->sem);
dev->udev = udev; dev->udev = udev;
dev->interface = interface; dev->interface = interface;
dev->minor = minor; dev->minor = intf->minor;
/* set up the endpoint information */ /* set up the endpoint information */
/* check out the endpoints */ /* check out the endpoints */
...@@ -591,22 +600,9 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i ...@@ -591,22 +600,9 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
goto error; goto error;
} }
/* initialize the devfs node for this device and register it */
sprintf(name, "usb/skel%d", dev->minor);
devfs = devfs_register(NULL, name,
DEVFS_FL_DEFAULT, USB_MAJOR,
dev->minor,
S_IFCHR | S_IRUSR | S_IWUSR |
S_IRGRP | S_IWGRP | S_IROTH,
&skel_fops, NULL);
/* let the user know what node this device is now attached to */ /* let the user know what node this device is now attached to */
info ("USB Skeleton device now attached to USBSkel-%d", dev->minor); info ("USB Skeleton device now attached to USBSkel-%d", dev->minor);
/* set the minor of the interface, so open() works */
interface->minor = dev->minor;
goto exit; goto exit;
error: error:
...@@ -614,7 +610,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i ...@@ -614,7 +610,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
dev = NULL; dev = NULL;
exit_minor: exit_minor:
usb_deregister_dev (1, minor); usb_deregister_dev (intf, &skel_class);
exit: exit:
if (dev) { if (dev) {
...@@ -657,11 +653,8 @@ static void skel_disconnect(struct usb_interface *interface) ...@@ -657,11 +653,8 @@ static void skel_disconnect(struct usb_interface *interface)
minor = dev->minor; minor = dev->minor;
/* remove our devfs node */ /* give back our minor */
devfs_remove("usb/skel%d", dev->minor); usb_deregister_dev (intf, &skel_class);
/* give back our dynamic minor */
usb_deregister_dev (1, minor);
/* terminate an ongoing write */ /* terminate an ongoing write */
if (atomic_read (&dev->write_busy)) { if (atomic_read (&dev->write_busy)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment