ChangeSet 1.1075, 2003/05/07 00:23:31-07:00, greg@kroah.com [PATCH] USB: converted usb-skeleton over to new usb_register_dev() changes. drivers/usb/usb-skeleton.c | 41 +++++++++++++++++------------------------ 1 files changed, 17 insertions(+), 24 deletions(-) diff -Nru a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c --- a/drivers/usb/usb-skeleton.c Wed May 7 11:11:59 2003 +++ b/drivers/usb/usb-skeleton.c Wed May 7 11:11:59 2003 @@ -1,5 +1,5 @@ /* - * 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 #include #include -#include #include #include @@ -159,6 +159,16 @@ .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 @@ 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 @@ 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 @@ 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 @@ 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 @@ dev = NULL; exit_minor: - usb_deregister_dev (1, minor); + usb_deregister_dev (intf, &skel_class); exit: if (dev) { @@ -657,11 +653,8 @@ 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)) {