Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 67969
b: refs/heads/master
c: 44b760a
h: refs/heads/master
i:
  67967: a3690ac
v: v3
  • Loading branch information
Akinobu Mita authored and Greg Kroah-Hartman committed Oct 12, 2007
1 parent 16cfd61 commit d901545
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 58 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a93720eeb4b3bedc1fe15e4b6ca364e6be577d20
refs/heads/master: 44b760a825fae65629fb04b1deeab68c6bef5c50
71 changes: 14 additions & 57 deletions trunk/drivers/base/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,25 +153,22 @@ void sysdev_class_unregister(struct sysdev_class * cls)
EXPORT_SYMBOL_GPL(sysdev_class_register);
EXPORT_SYMBOL_GPL(sysdev_class_unregister);


static LIST_HEAD(sysdev_drivers);
static DEFINE_MUTEX(sysdev_drivers_lock);

/**
* sysdev_driver_register - Register auxillary driver
* @cls: Device class driver belongs to.
* @cls: Device class driver belongs to.
* @drv: Driver.
*
* If @cls is valid, then @drv is inserted into @cls->drivers to be
* @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 sysdev_drivers, and called for
* each device.
*/

int sysdev_driver_register(struct sysdev_class * cls,
struct sysdev_driver * drv)
int sysdev_driver_register(struct sysdev_class *cls, struct sysdev_driver *drv)
{
int err = 0;

mutex_lock(&sysdev_drivers_lock);
if (cls && kset_get(&cls->kset)) {
list_add_tail(&drv->entry, &cls->drivers);
Expand All @@ -182,10 +179,13 @@ int sysdev_driver_register(struct sysdev_class * cls,
list_for_each_entry(dev, &cls->kset.list, kobj.entry)
drv->add(dev);
}
} else
list_add_tail(&drv->entry, &sysdev_drivers);
} else {
err = -EINVAL;
printk(KERN_ERR "%s: invalid device class\n", __FUNCTION__);
WARN_ON(1);
}
mutex_unlock(&sysdev_drivers_lock);
return 0;
return err;
}


Expand Down Expand Up @@ -251,12 +251,6 @@ int sysdev_register(struct sys_device * sysdev)
* code that should have called us.
*/

/* Notify global drivers */
list_for_each_entry(drv, &sysdev_drivers, entry) {
if (drv->add)
drv->add(sysdev);
}

/* Notify class auxillary drivers */
list_for_each_entry(drv, &cls->drivers, entry) {
if (drv->add)
Expand All @@ -272,11 +266,6 @@ void sysdev_unregister(struct sys_device * sysdev)
struct sysdev_driver * drv;

mutex_lock(&sysdev_drivers_lock);
list_for_each_entry(drv, &sysdev_drivers, entry) {
if (drv->remove)
drv->remove(sysdev);
}

list_for_each_entry(drv, &sysdev->cls->drivers, entry) {
if (drv->remove)
drv->remove(sysdev);
Expand All @@ -293,7 +282,7 @@ 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,
* each driver registered for the device - the auxillaries,
* and the class driver.
*
* Note: The list is iterated in reverse order, so that we shut down
Expand All @@ -320,13 +309,7 @@ void sysdev_shutdown(void)
struct sysdev_driver * drv;
pr_debug(" %s\n", kobject_name(&sysdev->kobj));

/* Call global drivers first. */
list_for_each_entry(drv, &sysdev_drivers, entry) {
if (drv->shutdown)
drv->shutdown(sysdev);
}

/* Call auxillary drivers next. */
/* Call auxillary drivers first */
list_for_each_entry(drv, &cls->drivers, entry) {
if (drv->shutdown)
drv->shutdown(sysdev);
Expand Down Expand Up @@ -354,12 +337,6 @@ static void __sysdev_resume(struct sys_device *dev)
if (drv->resume)
drv->resume(dev);
}

/* Call global drivers. */
list_for_each_entry(drv, &sysdev_drivers, entry) {
if (drv->resume)
drv->resume(dev);
}
}

/**
Expand Down Expand Up @@ -393,16 +370,7 @@ int sysdev_suspend(pm_message_t state)
list_for_each_entry(sysdev, &cls->kset.list, kobj.entry) {
pr_debug(" %s\n", kobject_name(&sysdev->kobj));

/* Call global drivers first. */
list_for_each_entry(drv, &sysdev_drivers, entry) {
if (drv->suspend) {
ret = drv->suspend(sysdev, state);
if (ret)
goto gbl_driver;
}
}

/* Call auxillary drivers next. */
/* Call auxillary drivers first */
list_for_each_entry(drv, &cls->drivers, entry) {
if (drv->suspend) {
ret = drv->suspend(sysdev, state);
Expand Down Expand Up @@ -436,18 +404,7 @@ int sysdev_suspend(pm_message_t state)
if (err_drv->resume)
err_drv->resume(sysdev);
}
drv = NULL;

gbl_driver:
if (drv)
printk(KERN_ERR "sysdev driver suspend failed for %s\n",
kobject_name(&sysdev->kobj));
list_for_each_entry(err_drv, &sysdev_drivers, entry) {
if (err_drv == drv)
break;
if (err_drv->resume)
err_drv->resume(sysdev);
}
/* resume other sysdevs in current class */
list_for_each_entry(err_dev, &cls->kset.list, kobj.entry) {
if (err_dev == sysdev)
Expand Down

0 comments on commit d901545

Please sign in to comment.