Re: [PATCH] USB and driver core changes for 2.5.41

From: Greg KH (greg@kroah.com)
Date: Tue Oct 08 2002 - 18:20:32 EST


# 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.573.92.18 -> 1.573.92.19
# drivers/usb/core/driverfs.c 1.1 -> 1.2
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/10/08 greg@kroah.com 1.573.92.19
# USB: add device speed driverfs file.
# --------------------------------------------
#
diff -Nru a/drivers/usb/core/driverfs.c b/drivers/usb/core/driverfs.c
--- a/drivers/usb/core/driverfs.c Tue Oct 8 15:53:35 2002
+++ b/drivers/usb/core/driverfs.c Tue Oct 8 15:53:35 2002
@@ -99,6 +99,34 @@
 }
 static DEVICE_ATTR(serial,S_IRUGO,show_serial,NULL);
 
+static ssize_t
+show_speed (struct device *dev, char *buf, size_t count, loff_t off)
+{
+ struct usb_device *udev;
+ char *speed;
+
+ if (off)
+ return 0;
+ udev = to_usb_device (dev);
+
+ switch (udev->speed) {
+ case USB_SPEED_LOW:
+ speed = "1.5";
+ break;
+ case USB_SPEED_UNKNOWN:
+ case USB_SPEED_FULL:
+ speed = "12";
+ break;
+ case USB_SPEED_HIGH:
+ speed = "480";
+ break;
+ default:
+ speed = "unknown";
+ }
+ return sprintf (buf, "%s\n", speed);
+}
+static DEVICE_ATTR(speed, S_IRUGO, show_speed, NULL);
+
 /* Descriptor fields */
 #define usb_descriptor_attr(field, format_string) \
 static ssize_t \
@@ -136,6 +164,7 @@
         device_create_file (dev, &dev_attr_bDeviceClass);
         device_create_file (dev, &dev_attr_bDeviceSubClass);
         device_create_file (dev, &dev_attr_bDeviceProtocol);
+ device_create_file (dev, &dev_attr_speed);
 
         if (udev->descriptor.iManufacturer)
                 device_create_file (dev, &dev_attr_manufacturer);
-
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/



This archive was generated by hypermail 2b29 : Tue Oct 15 2002 - 22:00:29 EST