VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / drivers / base / sys.c
index b0d55a9..9d10500 100644 (file)
@@ -5,8 +5,8 @@
  *               2002-3 Open Source Development Lab
  *
  * This file is released under the GPLv2
- * 
- * This exports a 'system' bus type. 
+ *
+ * This exports a 'system' bus type.
  * By default, a 'sys' bus gets added to the root of the system. There will
  * always be core system devices. Devices can use sysdev_register() to
  * add themselves as children of the system bus.
 
 extern struct subsystem devices_subsys;
 
-#define to_sysdev(k) container_of(k,struct sys_device,kobj)
-#define to_sysdev_attr(a) container_of(a,struct sysdev_attribute,attr)
+#define to_sysdev(k) container_of(k, struct sys_device, kobj)
+#define to_sysdev_attr(a) container_of(a, struct sysdev_attribute, attr)
 
 
-static ssize_t 
+static ssize_t
 sysdev_show(struct kobject * kobj, struct attribute * attr, char * buffer)
 {
        struct sys_device * sysdev = to_sysdev(kobj);
        struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);
 
        if (sysdev_attr->show)
-               return sysdev_attr->show(sysdev,buffer);
+               return sysdev_attr->show(sysdev, buffer);
        return 0;
 }
 
 
 static ssize_t
-sysdev_store(struct kobject * kobj, struct attribute * attr, 
+sysdev_store(struct kobject * kobj, struct attribute * attr,
             const char * buffer, size_t count)
 {
        struct sys_device * sysdev = to_sysdev(kobj);
        struct sysdev_attribute * sysdev_attr = to_sysdev_attr(attr);
 
        if (sysdev_attr->store)
-               return sysdev_attr->store(sysdev,buffer,count);
+               return sysdev_attr->store(sysdev, buffer, count);
        return 0;
 }
 
@@ -64,22 +64,22 @@ static struct kobj_type ktype_sysdev = {
 
 int sysdev_create_file(struct sys_device * s, struct sysdev_attribute * a)
 {
-       return sysfs_create_file(&s->kobj,&a->attr);
+       return sysfs_create_file(&s->kobj, &a->attr);
 }
 
 
 void sysdev_remove_file(struct sys_device * s, struct sysdev_attribute * a)
 {
-       sysfs_remove_file(&s->kobj,&a->attr);
+       sysfs_remove_file(&s->kobj, &a->attr);
 }
 
 EXPORT_SYMBOL(sysdev_create_file);
 EXPORT_SYMBOL(sysdev_remove_file);
 
-/* 
- * declare system_subsys 
+/*
+ * declare system_subsys
  */
-decl_subsys(system,&ktype_sysdev,NULL);
+decl_subsys(system, &ktype_sysdev, NULL);
 
 int sysdev_class_register(struct sysdev_class * cls)
 {
@@ -87,7 +87,7 @@ int sysdev_class_register(struct sysdev_class * cls)
                 kobject_name(&cls->kset.kobj));
        INIT_LIST_HEAD(&cls->drivers);
        cls->kset.subsys = &system_subsys;
-       kset_set_kset_s(cls,system_subsys);
+       kset_set_kset_s(cls, system_subsys);
        return kset_register(&cls->kset);
 }
 
@@ -109,19 +109,19 @@ static LIST_HEAD(global_drivers);
  *     @cls:   Device class driver belongs to.
  *     @drv:   Driver.
  *
- *     If @cls is valid, then @drv is inserted into @cls->drivers to be 
+ *     If @cls is valid, then @drv is inserted into @cls->drivers to be
  *     called on each operation on devices of that class. The refcount
- *     of @cls is incremented. 
- *     Otherwise, @drv is inserted into global_drivers, and called for 
+ *     of @cls is incremented.
+ *     Otherwise, @drv is inserted into global_drivers, and called for
  *     each device.
  */
 
-int sysdev_driver_register(struct sysdev_class * cls, 
+int sysdev_driver_register(struct sysdev_class * cls,
                           struct sysdev_driver * drv)
 {
        down_write(&system_subsys.rwsem);
        if (cls && kset_get(&cls->kset)) {
-               list_add_tail(&drv->entry,&cls->drivers);
+               list_add_tail(&drv->entry, &cls->drivers);
 
                /* If devices of this class already exist, tell the driver */
                if (drv->add) {
@@ -130,7 +130,7 @@ int sysdev_driver_register(struct sysdev_class * cls,
                                drv->add(dev);
                }
        } else
-               list_add_tail(&drv->entry,&global_drivers);
+               list_add_tail(&drv->entry, &global_drivers);
        up_write(&system_subsys.rwsem);
        return 0;
 }
@@ -180,12 +180,12 @@ int sysdev_register(struct sys_device * sysdev)
 
        /* But make sure we point to the right type for sysfs translation */
        sysdev->kobj.ktype = &ktype_sysdev;
-       error = kobject_set_name(&sysdev->kobj,"%s%d",
-                        kobject_name(&cls->kset.kobj),sysdev->id);
+       error = kobject_set_name(&sysdev->kobj, "%s%d",
+                        kobject_name(&cls->kset.kobj), sysdev->id);
        if (error)
                return error;
 
-       pr_debug("Registering sys device '%s'\n",kobject_name(&sysdev->kobj));
+       pr_debug("Registering sys device '%s'\n", kobject_name(&sysdev->kobj));
 
        /* Register the object */
        error = kobject_register(&sysdev->kobj);
@@ -194,18 +194,18 @@ int sysdev_register(struct sys_device * sysdev)
                struct sysdev_driver * drv;
 
                down_write(&system_subsys.rwsem);
-               /* Generic notification is implicit, because it's that 
-                * code that should have called us. 
+               /* Generic notification is implicit, because it's that
+                * code that should have called us.
                 */
 
                /* Notify global drivers */
-               list_for_each_entry(drv,&global_drivers,entry) {
+               list_for_each_entry(drv, &global_drivers, entry) {
                        if (drv->add)
                                drv->add(sysdev);
                }
 
                /* Notify class auxillary drivers */
-               list_for_each_entry(drv,&cls->drivers,entry) {
+               list_for_each_entry(drv, &cls->drivers, entry) {
                        if (drv->add)
                                drv->add(sysdev);
                }
@@ -219,12 +219,12 @@ void sysdev_unregister(struct sys_device * sysdev)
        struct sysdev_driver * drv;
 
        down_write(&system_subsys.rwsem);
-       list_for_each_entry(drv,&global_drivers,entry) {
+       list_for_each_entry(drv, &global_drivers, entry) {
                if (drv->remove)
                        drv->remove(sysdev);
        }
 
-       list_for_each_entry(drv,&sysdev->cls->drivers,entry) {
+       list_for_each_entry(drv, &sysdev->cls->drivers, entry) {
                if (drv->remove)
                        drv->remove(sysdev);
        }
@@ -241,12 +241,12 @@ void sysdev_unregister(struct sys_device * sysdev)
  *     Loop over each class of system devices, and the devices in each
  *     of those classes. For each device, we call the shutdown method for
  *     each driver registered for the device - the globals, the auxillaries,
- *     and the class driver. 
+ *     and the class driver.
  *
  *     Note: The list is iterated in reverse order, so that we shut down
  *     child devices before we shut down thier parents. The list ordering
  *     is guaranteed by virtue of the fact that child devices are registered
- *     after their parents. 
+ *     after their parents.
  */
 
 void sysdev_shutdown(void)
@@ -256,25 +256,25 @@ void sysdev_shutdown(void)
        pr_debug("Shutting Down System Devices\n");
 
        down_write(&system_subsys.rwsem);
-       list_for_each_entry_reverse(cls,&system_subsys.kset.list,
+       list_for_each_entry_reverse(cls, &system_subsys.kset.list,
                                    kset.kobj.entry) {
                struct sys_device * sysdev;
 
                pr_debug("Shutting down type '%s':\n",
                         kobject_name(&cls->kset.kobj));
 
-               list_for_each_entry(sysdev,&cls->kset.list,kobj.entry) {
+               list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
                        struct sysdev_driver * drv;
-                       pr_debug(" %s\n",kobject_name(&sysdev->kobj));
+                       pr_debug(" %s\n", kobject_name(&sysdev->kobj));
 
                        /* Call global drivers first. */
-                       list_for_each_entry(drv,&global_drivers,entry) {
+                       list_for_each_entry(drv, &global_drivers, entry) {
                                if (drv->shutdown)
                                        drv->shutdown(sysdev);
                        }
 
                        /* Call auxillary drivers next. */
-                       list_for_each_entry(drv,&cls->drivers,entry) {
+                       list_for_each_entry(drv, &cls->drivers, entry) {
                                if (drv->shutdown)
                                        drv->shutdown(sysdev);
                        }
@@ -295,7 +295,7 @@ void sysdev_shutdown(void)
  *     We perform an almost identical operation as sys_device_shutdown()
  *     above, though calling ->suspend() instead. Interrupts are disabled
  *     when this called. Devices are responsible for both saving state and
- *     quiescing or powering down the device. 
+ *     quiescing or powering down the device.
  *
  *     This is only called by the device PM core, so we let them handle
  *     all synchronization.
@@ -307,32 +307,32 @@ int sysdev_suspend(u32 state)
 
        pr_debug("Suspending System Devices\n");
 
-       list_for_each_entry_reverse(cls,&system_subsys.kset.list,
+       list_for_each_entry_reverse(cls, &system_subsys.kset.list,
                                    kset.kobj.entry) {
                struct sys_device * sysdev;
 
                pr_debug("Suspending type '%s':\n",
                         kobject_name(&cls->kset.kobj));
 
-               list_for_each_entry(sysdev,&cls->kset.list,kobj.entry) {
+               list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
                        struct sysdev_driver * drv;
-                       pr_debug(" %s\n",kobject_name(&sysdev->kobj));
+                       pr_debug(" %s\n", kobject_name(&sysdev->kobj));
 
                        /* Call global drivers first. */
-                       list_for_each_entry(drv,&global_drivers,entry) {
+                       list_for_each_entry(drv, &global_drivers, entry) {
                                if (drv->suspend)
-                                       drv->suspend(sysdev,state);
+                                       drv->suspend(sysdev, state);
                        }
 
                        /* Call auxillary drivers next. */
-                       list_for_each_entry(drv,&cls->drivers,entry) {
+                       list_for_each_entry(drv, &cls->drivers, entry) {
                                if (drv->suspend)
-                                       drv->suspend(sysdev,state);
+                                       drv->suspend(sysdev, state);
                        }
 
                        /* Now call the generic one */
                        if (cls->suspend)
-                               cls->suspend(sysdev,state);
+                               cls->suspend(sysdev, state);
                }
        }
        return 0;
@@ -345,7 +345,7 @@ int sysdev_suspend(u32 state)
  *     Similar to sys_device_suspend(), but we iterate the list forwards
  *     to guarantee that parent devices are resumed before their children.
  *
- *     Note: Interrupts are disabled when called. 
+ *     Note: Interrupts are disabled when called.
  */
 
 int sysdev_resume(void)
@@ -354,28 +354,28 @@ int sysdev_resume(void)
 
        pr_debug("Resuming System Devices\n");
 
-       list_for_each_entry(cls,&system_subsys.kset.list,kset.kobj.entry) {
+       list_for_each_entry(cls, &system_subsys.kset.list, kset.kobj.entry) {
                struct sys_device * sysdev;
 
                pr_debug("Resuming type '%s':\n",
                         kobject_name(&cls->kset.kobj));
 
-               list_for_each_entry(sysdev,&cls->kset.list,kobj.entry) {
+               list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
                        struct sysdev_driver * drv;
-                       pr_debug(" %s\n",kobject_name(&sysdev->kobj));
+                       pr_debug(" %s\n", kobject_name(&sysdev->kobj));
 
                        /* First, call the class-specific one */
                        if (cls->resume)
                                cls->resume(sysdev);
 
                        /* Call auxillary drivers next. */
-                       list_for_each_entry(drv,&cls->drivers,entry) {
+                       list_for_each_entry(drv, &cls->drivers, entry) {
                                if (drv->resume)
                                        drv->resume(sysdev);
                        }
 
                        /* Call global drivers. */
-                       list_for_each_entry(drv,&global_drivers,entry) {
+                       list_for_each_entry(drv, &global_drivers, entry) {
                                if (drv->resume)
                                        drv->resume(sysdev);
                        }