Re: [BK PATCH] More USB changes for 2.5.38

Greg KH (greg@kroah.com)
Fri, 27 Sep 2002 12:40:25 -0700


# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.611.1.1 -> 1.611.1.2
# drivers/usb/usb-skeleton.c 1.15 -> 1.16
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/09/26 greg@kroah.com 1.611.1.2
# USB: convert the usb-skeleton.c driver to work with the latest USB core changes.
# --------------------------------------------
#
diff -Nru a/drivers/usb/usb-skeleton.c b/drivers/usb/usb-skeleton.c
--- a/drivers/usb/usb-skeleton.c Fri Sep 27 12:30:25 2002
+++ b/drivers/usb/usb-skeleton.c Fri Sep 27 12:30:25 2002
@@ -1,12 +1,11 @@
/*
- * USB Skeleton driver - 0.7
+ * USB Skeleton driver - 0.8
*
- * Copyright (c) 2001 Greg Kroah-Hartman (greg@kroah.com)
+ * Copyright (c) 2001-2002 Greg Kroah-Hartman (greg@kroah.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
+ * published by the Free Software Foundation, version 2.
*
*
* This driver is to be used as a skeleton driver to be able to create a
@@ -22,6 +21,8 @@
*
* History:
*
+ * 2002_09_26 - 0.8 - changes due to USB core conversion to struct device
+ * driver.
* 2002_02_12 - 0.7 - zero out dev in probe function for devices that do
* not have both a bulk in and bulk out endpoint.
* Thanks to Holger Waechtler for the fix.
@@ -133,8 +134,8 @@
static int skel_open (struct inode *inode, struct file *file);
static int skel_release (struct inode *inode, struct file *file);

-static void * skel_probe (struct usb_device *dev, unsigned int ifnum, const struct usb_device_id *id);
-static void skel_disconnect (struct usb_device *dev, void *ptr);
+static int skel_probe (struct usb_interface *intf, const struct usb_device_id *id);
+static void skel_disconnect (struct usb_interface *intf);

static void skel_write_bulk_callback (struct urb *urb);

@@ -509,10 +510,10 @@
* Called by the usb core when a new device is connected that it thinks
* this driver might be interested in.
*/
-static void * skel_probe(struct usb_device *udev, unsigned int ifnum, const struct usb_device_id *id)
+static int skel_probe(struct usb_interface *interface, const struct usb_device_id *id)
{
+ struct usb_device *udev = interface_to_usbdev(interface);
struct usb_skel *dev = NULL;
- struct usb_interface *interface;
struct usb_interface_descriptor *iface_desc;
struct usb_endpoint_descriptor *endpoint;
int minor;
@@ -525,7 +526,7 @@
/* See if the device offered us matches what we can accept */
if ((udev->descriptor.idVendor != USB_SKEL_VENDOR_ID) ||
(udev->descriptor.idProduct != USB_SKEL_PRODUCT_ID)) {
- return NULL;
+ return -ENODEV;
}

down (&minor_table_mutex);
@@ -545,8 +546,6 @@
memset (dev, 0x00, sizeof (*dev));
minor_table[minor] = dev;

- interface = &udev->actconfig->interface[ifnum];
-
init_MUTEX (&dev->sem);
dev->udev = udev;
dev->interface = interface;
@@ -619,7 +618,11 @@

exit:
up (&minor_table_mutex);
- return dev;
+ if (dev) {
+ dev_set_drvdata (&interface->dev, dev);
+ return 0;
+ }
+ return -ENODEV;
}


@@ -628,13 +631,17 @@
*
* Called by the usb core when the device is removed from the system.
*/
-static void skel_disconnect(struct usb_device *udev, void *ptr)
+static void skel_disconnect(struct usb_interface *interface)
{
struct usb_skel *dev;
int minor;

- dev = (struct usb_skel *)ptr;
-
+ dev = dev_get_drvdata (&interface->dev);
+ dev_set_drvdata (&interface->dev, NULL);
+
+ if (!dev)
+ return;
+
down (&minor_table_mutex);
down (&dev->sem);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/