]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/base/core.c
[PATCH] v4l: hybrid dvb: move #defines to Makefile
[linux-2.6-omap-h63xx.git] / drivers / base / core.c
index 0eb1d424bd1d14b77345e726bd656a685a373ec4..efe03a024a5bc39bf958881143d740312c3b09bc 100644 (file)
@@ -39,7 +39,7 @@ dev_attr_show(struct kobject * kobj, struct attribute * attr, char * buf)
        ssize_t ret = -EIO;
 
        if (dev_attr->show)
-               ret = dev_attr->show(dev, buf);
+               ret = dev_attr->show(dev, dev_attr, buf);
        return ret;
 }
 
@@ -52,7 +52,7 @@ dev_attr_store(struct kobject * kobj, struct attribute * attr,
        ssize_t ret = -EIO;
 
        if (dev_attr->store)
-               ret = dev_attr->store(dev, buf, count);
+               ret = dev_attr->store(dev, dev_attr, buf, count);
        return ret;
 }
 
@@ -207,10 +207,7 @@ void device_initialize(struct device *dev)
 {
        kobj_set_kset_s(dev, devices_subsys);
        kobject_init(&dev->kobj);
-       INIT_LIST_HEAD(&dev->node);
-       INIT_LIST_HEAD(&dev->children);
-       INIT_LIST_HEAD(&dev->bus_list);
-       INIT_LIST_HEAD(&dev->driver_list);
+       klist_init(&dev->klist_children);
        INIT_LIST_HEAD(&dev->dma_pools);
        init_MUTEX(&dev->sem);
 }
@@ -251,10 +248,8 @@ int device_add(struct device *dev)
                goto PMError;
        if ((error = bus_add_device(dev)))
                goto BusError;
-       down_write(&devices_subsys.rwsem);
        if (parent)
-               list_add_tail(&dev->node, &parent->children);
-       up_write(&devices_subsys.rwsem);
+               klist_add_tail(&parent->klist_children, &dev->knode_parent);
 
        /* notify platform of device entry */
        if (platform_notify)
@@ -337,10 +332,8 @@ void device_del(struct device * dev)
 {
        struct device * parent = dev->parent;
 
-       down_write(&devices_subsys.rwsem);
        if (parent)
-               list_del_init(&dev->node);
-       up_write(&devices_subsys.rwsem);
+               klist_del(&dev->knode_parent);
 
        /* Notify the platform of the removal, in case they
         * need to do anything...
@@ -374,6 +367,12 @@ void device_unregister(struct device * dev)
 }
 
 
+static struct device * next_device(struct klist_iter * i)
+{
+       struct klist_node * n = klist_next(i);
+       return n ? container_of(n, struct device, knode_parent) : NULL;
+}
+
 /**
  *     device_for_each_child - device child iterator.
  *     @dev:   parent struct device.
@@ -386,18 +385,17 @@ void device_unregister(struct device * dev)
  *     We check the return of @fn each time. If it returns anything
  *     other than 0, we break out and return that value.
  */
-int device_for_each_child(struct device * dev, void * data,
+int device_for_each_child(struct device * parent, void * data,
                     int (*fn)(struct device *, void *))
 {
+       struct klist_iter i;
        struct device * child;
        int error = 0;
 
-       down_read(&devices_subsys.rwsem);
-       list_for_each_entry(child, &dev->children, node) {
-               if((error = fn(child, data)))
-                       break;
-       }
-       up_read(&devices_subsys.rwsem);
+       klist_iter_init(&parent->klist_children, &i);
+       while ((child = next_device(&i)) && !error)
+               error = fn(child, data);
+       klist_iter_exit(&i);
        return error;
 }