From 8634a0f46e5da7c9bc392a49979f56c86b733628 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=BB=84=E6=B6=9B?= Date: Sat, 30 Jul 2011 22:26:57 +0800 Subject: [PATCH] Revert "USB: composite: Add class driver for enabling and disabling USB functions." This reverts commit f8cf7f90ac799df1f9a34bd7cd6fb0dce063c8c5. --- drivers/usb/gadget/composite.c | 50 ++-------------------------------- include/linux/usb/composite.h | 6 ---- 2 files changed, 2 insertions(+), 54 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index a64fb6f4c7ff..39f61affbae6 100755 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -71,33 +71,6 @@ MODULE_PARM_DESC(iSerialNumber, "SerialNumber string"); /*-------------------------------------------------------------------------*/ -static ssize_t enable_show(struct device *dev, struct device_attribute *attr, - char *buf) -{ - struct usb_function *f = dev_get_drvdata(dev); - return sprintf(buf, "%d\n", !f->hidden); -} - -static ssize_t enable_store( - struct device *dev, struct device_attribute *attr, - const char *buf, size_t size) -{ - struct usb_function *f = dev_get_drvdata(dev); - struct usb_composite_driver *driver = f->config->cdev->driver; - int value; - - sscanf(buf, "%d", &value); - if (driver->enable_function) - driver->enable_function(f, value); - else - f->hidden = !value; - - return size; -} - -static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, enable_show, enable_store); - - /** * usb_add_function() - add a function to a configuration * @config: the configuration @@ -115,30 +88,15 @@ static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR, enable_show, enable_store); int __init usb_add_function(struct usb_configuration *config, struct usb_function *function) { - struct usb_composite_dev *cdev = config->cdev; int value = -EINVAL; - int index; - DBG(cdev, "adding '%s'/%p to config '%s'/%p\n", + DBG(config->cdev, "adding '%s'/%p to config '%s'/%p\n", function->name, function, config->label, config); if (!function->set_alt || !function->disable) goto done; - index = atomic_inc_return(&cdev->driver->function_count); - function->dev = device_create(cdev->driver->class, NULL, - MKDEV(0, index), NULL, function->name); - if (IS_ERR(function->dev)) - return PTR_ERR(function->dev); - - value = device_create_file(function->dev, &dev_attr_enable); - if (value < 0) { - device_destroy(cdev->driver->class, MKDEV(0, index)); - return value; - } - dev_set_drvdata(function->dev, function); - function->config = config; list_add_tail(&function->list, &config->functions); @@ -164,7 +122,7 @@ int __init usb_add_function(struct usb_configuration *config, done: if (value) - DBG(cdev, "adding '%s'/%p --> %d\n", + DBG(config->cdev, "adding '%s'/%p --> %d\n", function->name, function, value); return value; } @@ -1166,10 +1124,6 @@ int __init usb_composite_register(struct usb_composite_driver *driver) composite_driver.driver.name = driver->name; composite = driver; - driver->class = class_create(THIS_MODULE, "usb_composite"); - if (IS_ERR(driver->class)) - return PTR_ERR(driver->class); - return usb_gadget_register_driver(&composite_driver); } diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 66884030c58a..8f33ae3e00f3 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -128,7 +128,6 @@ struct usb_function { /* private: */ /* internals */ struct list_head list; - struct device *dev; }; int usb_add_function(struct usb_configuration *, struct usb_function *); @@ -269,9 +268,6 @@ struct usb_composite_driver { const struct usb_device_descriptor *dev; struct usb_gadget_strings **strings; - struct class *class; - atomic_t function_count; - /* REVISIT: bind() functions can be marked __init, which * makes trouble for section mismatch analysis. See if * we can't restructure things to avoid mismatching... @@ -283,8 +279,6 @@ struct usb_composite_driver { /* global suspend hooks */ void (*suspend)(struct usb_composite_dev *); void (*resume)(struct usb_composite_dev *); - - void (*enable_function)(struct usb_function *f, int enable); }; extern int usb_composite_register(struct usb_composite_driver *); -- 2.34.1