Commit cd35449b authored by Dave Young's avatar Dave Young Committed by Greg Kroah-Hartman

driver core: convert to use class_find_device api

Convert to use class_find_device api in drivers/base/core.c
Signed-off-by: default avatarDave Young <hidave.darkstar@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9617c3e4
...@@ -1144,25 +1144,11 @@ struct device *device_create(struct class *class, struct device *parent, ...@@ -1144,25 +1144,11 @@ struct device *device_create(struct class *class, struct device *parent,
} }
EXPORT_SYMBOL_GPL(device_create); EXPORT_SYMBOL_GPL(device_create);
/** static int __match_devt(struct device *dev, void *data)
* find_device - finds a device that was created with device_create()
* @class: pointer to the struct class that this device was registered with
* @devt: the dev_t of the device that was previously registered
*/
static struct device *find_device(struct class *class, dev_t devt)
{ {
struct device *dev = NULL; dev_t *devt = data;
struct device *dev_tmp;
down(&class->sem); return dev->devt == *devt;
list_for_each_entry(dev_tmp, &class->devices, node) {
if (dev_tmp->devt == devt) {
dev = dev_tmp;
break;
}
}
up(&class->sem);
return dev;
} }
/** /**
...@@ -1177,9 +1163,11 @@ void device_destroy(struct class *class, dev_t devt) ...@@ -1177,9 +1163,11 @@ void device_destroy(struct class *class, dev_t devt)
{ {
struct device *dev; struct device *dev;
dev = find_device(class, devt); dev = class_find_device(class, &devt, __match_devt);
if (dev) if (dev) {
put_device(dev);
device_unregister(dev); device_unregister(dev);
}
} }
EXPORT_SYMBOL_GPL(device_destroy); EXPORT_SYMBOL_GPL(device_destroy);
...@@ -1203,9 +1191,11 @@ void destroy_suspended_device(struct class *class, dev_t devt) ...@@ -1203,9 +1191,11 @@ void destroy_suspended_device(struct class *class, dev_t devt)
{ {
struct device *dev; struct device *dev;
dev = find_device(class, devt); dev = class_find_device(class, &devt, __match_devt);
if (dev) if (dev) {
device_pm_schedule_removal(dev); device_pm_schedule_removal(dev);
put_device(dev);
}
} }
EXPORT_SYMBOL_GPL(destroy_suspended_device); EXPORT_SYMBOL_GPL(destroy_suspended_device);
#endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_SLEEP */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment