Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / base / transport_class.c
index 3bae11c..f25e7c6 100644 (file)
@@ -7,7 +7,7 @@
  * This file is licensed under GPLv2
  *
  * The basic idea here is to allow any "device controller" (which
- * would most often be a Host Bus Adapter" to use the services of one
+ * would most often be a Host Bus Adapter to use the services of one
  * or more tranport classes for performing transport specific
  * services.  Transport specific services are things that the generic
  * command layer doesn't want to know about (speed settings, line
@@ -64,7 +64,9 @@ void transport_class_unregister(struct transport_class *tclass)
 }
 EXPORT_SYMBOL_GPL(transport_class_unregister);
 
-static int anon_transport_dummy_function(struct device *dev)
+static int anon_transport_dummy_function(struct transport_container *tc,
+                                        struct device *dev,
+                                        struct class_device *cdev)
 {
        /* do nothing */
        return 0;
@@ -115,9 +117,10 @@ static int transport_setup_classdev(struct attribute_container *cont,
                                    struct class_device *classdev)
 {
        struct transport_class *tclass = class_to_transport_class(cont->class);
+       struct transport_container *tcont = attribute_container_to_transport_container(cont);
 
        if (tclass->setup)
-               tclass->setup(dev);
+               tclass->setup(tcont, dev, classdev);
 
        return 0;
 }
@@ -145,6 +148,20 @@ void transport_setup_device(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(transport_setup_device);
 
+static int transport_add_class_device(struct attribute_container *cont,
+                                     struct device *dev,
+                                     struct class_device *classdev)
+{
+       int error = attribute_container_add_class_device(classdev);
+       struct transport_container *tcont = 
+               attribute_container_to_transport_container(cont);
+
+       if (!error && tcont->statistics)
+               error = sysfs_create_group(&classdev->kobj, tcont->statistics);
+
+       return error;
+}
+
 
 /**
  * transport_add_device - declare a new dev for transport class association
@@ -159,18 +176,19 @@ EXPORT_SYMBOL_GPL(transport_setup_device);
 
 void transport_add_device(struct device *dev)
 {
-       attribute_container_device_trigger(dev,
-                          attribute_container_add_class_device_adapter);
+       attribute_container_device_trigger(dev, transport_add_class_device);
 }
 EXPORT_SYMBOL_GPL(transport_add_device);
 
 static int transport_configure(struct attribute_container *cont,
-                              struct device *dev)
+                              struct device *dev,
+                              struct class_device *cdev)
 {
        struct transport_class *tclass = class_to_transport_class(cont->class);
+       struct transport_container *tcont = attribute_container_to_transport_container(cont);
 
        if (tclass->configure)
-               tclass->configure(dev);
+               tclass->configure(tcont, dev, cdev);
 
        return 0;
 }
@@ -189,7 +207,7 @@ static int transport_configure(struct attribute_container *cont,
  */
 void transport_configure_device(struct device *dev)
 {
-       attribute_container_trigger(dev, transport_configure);
+       attribute_container_device_trigger(dev, transport_configure);
 }
 EXPORT_SYMBOL_GPL(transport_configure_device);
 
@@ -197,13 +215,18 @@ static int transport_remove_classdev(struct attribute_container *cont,
                                     struct device *dev,
                                     struct class_device *classdev)
 {
+       struct transport_container *tcont = 
+               attribute_container_to_transport_container(cont);
        struct transport_class *tclass = class_to_transport_class(cont->class);
 
        if (tclass->remove)
-               tclass->remove(dev);
+               tclass->remove(tcont, dev, classdev);
 
-       if (tclass->remove != anon_transport_dummy_function)
+       if (tclass->remove != anon_transport_dummy_function) {
+               if (tcont->statistics)
+                       sysfs_remove_group(&classdev->kobj, tcont->statistics);
                attribute_container_class_device_del(classdev);
+       }
 
        return 0;
 }