usb: dwc3: gadget: fix ep->maxburst for ep0
[linux-2.6.git] / drivers / base / class.c
index 4f1df2e..03243d4 100644 (file)
@@ -47,6 +47,18 @@ static ssize_t class_attr_store(struct kobject *kobj, struct attribute *attr,
        return ret;
 }
 
+static const void *class_attr_namespace(struct kobject *kobj,
+                                       const struct attribute *attr)
+{
+       struct class_attribute *class_attr = to_class_attr(attr);
+       struct subsys_private *cp = to_subsys_private(kobj);
+       const void *ns = NULL;
+
+       if (class_attr->namespace)
+               ns = class_attr->namespace(cp->class, class_attr);
+       return ns;
+}
+
 static void class_release(struct kobject *kobj)
 {
        struct subsys_private *cp = to_subsys_private(kobj);
@@ -72,8 +84,9 @@ static const struct kobj_ns_type_operations *class_child_ns_type(struct kobject
 }
 
 static const struct sysfs_ops class_sysfs_ops = {
-       .show   = class_attr_show,
-       .store  = class_attr_store,
+       .show      = class_attr_show,
+       .store     = class_attr_store,
+       .namespace = class_attr_namespace,
 };
 
 static struct kobj_type class_ktype = {
@@ -171,9 +184,9 @@ int __class_register(struct class *cls, struct lock_class_key *key)
        if (!cp)
                return -ENOMEM;
        klist_init(&cp->klist_devices, klist_class_dev_get, klist_class_dev_put);
-       INIT_LIST_HEAD(&cp->class_interfaces);
+       INIT_LIST_HEAD(&cp->interfaces);
        kset_init(&cp->glue_dirs);
-       __mutex_init(&cp->class_mutex, "struct class mutex", key);
+       __mutex_init(&cp->mutex, "subsys mutex", key);
        error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name);
        if (error) {
                kfree(cp);
@@ -447,15 +460,15 @@ int class_interface_register(struct class_interface *class_intf)
        if (!parent)
                return -EINVAL;
 
-       mutex_lock(&parent->p->class_mutex);
-       list_add_tail(&class_intf->node, &parent->p->class_interfaces);
+       mutex_lock(&parent->p->mutex);
+       list_add_tail(&class_intf->node, &parent->p->interfaces);
        if (class_intf->add_dev) {
                class_dev_iter_init(&iter, parent, NULL, NULL);
                while ((dev = class_dev_iter_next(&iter)))
                        class_intf->add_dev(dev, class_intf);
                class_dev_iter_exit(&iter);
        }
-       mutex_unlock(&parent->p->class_mutex);
+       mutex_unlock(&parent->p->mutex);
 
        return 0;
 }
@@ -469,7 +482,7 @@ void class_interface_unregister(struct class_interface *class_intf)
        if (!parent)
                return;
 
-       mutex_lock(&parent->p->class_mutex);
+       mutex_lock(&parent->p->mutex);
        list_del_init(&class_intf->node);
        if (class_intf->remove_dev) {
                class_dev_iter_init(&iter, parent, NULL, NULL);
@@ -477,7 +490,7 @@ void class_interface_unregister(struct class_interface *class_intf)
                        class_intf->remove_dev(dev, class_intf);
                class_dev_iter_exit(&iter);
        }
-       mutex_unlock(&parent->p->class_mutex);
+       mutex_unlock(&parent->p->mutex);
 
        class_put(parent);
 }