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)
*
......@@ -18,6 +18,7 @@
*
* 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
* disconnect. Fix transfer amount in read(). Use
* macros instead of magic numbers in probe(). Change
......@@ -47,7 +48,6 @@
#include <linux/module.h>
#include <linux/smp_lock.h>
#include <linux/completion.h>
#include <linux/devfs_fs_kernel.h>
#include <asm/uaccess.h>
#include <linux/usb.h>
......@@ -159,6 +159,16 @@ static struct file_operations skel_fops = {
.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 */
static struct usb_driver skel_driver = {
......@@ -493,7 +503,6 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
struct usb_skel *dev = NULL;
struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint;
int minor;
size_t buffer_size;
int i;
int retval;
......@@ -506,7 +515,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
return -ENODEV;
}
retval = usb_register_dev (&skel_fops, USB_SKEL_MINOR_BASE, 1, &minor);
retval = usb_register_dev (intf, &skel_class);
if (retval) {
/* something prevented us from registering this driver */
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
init_MUTEX (&dev->sem);
dev->udev = udev;
dev->interface = interface;
dev->minor = minor;
dev->minor = intf->minor;
/* set up the endpoint information */
/* check out the endpoints */
......@@ -591,22 +600,9 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
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 */
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;
error:
......@@ -614,7 +610,7 @@ static int skel_probe(struct usb_interface *interface, const struct usb_device_i
dev = NULL;
exit_minor:
usb_deregister_dev (1, minor);
usb_deregister_dev (intf, &skel_class);
exit:
if (dev) {
......@@ -657,11 +653,8 @@ static void skel_disconnect(struct usb_interface *interface)
minor = dev->minor;
/* remove our devfs node */
devfs_remove("usb/skel%d", dev->minor);
/* give back our dynamic minor */
usb_deregister_dev (1, minor);
/* give back our minor */
usb_deregister_dev (intf, &skel_class);
/* terminate an ongoing write */
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