aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorDave Young <hidave.darkstar@gmail.com>2008-01-28 03:56:11 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-02-02 18:14:49 -0500
commitcd35449b93ac128282c1f1f720e84c5935f9018e (patch)
tree51a32f111615f165adf7c09f336072331a80b5a9 /drivers/base
parent9617c3e460bbccb6d9496a1f1e6903eb81f336e9 (diff)
driver core: convert to use class_find_device api
Convert to use class_find_device api in drivers/base/core.c Signed-off-by: Dave Young <hidave.darkstar@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/core.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/drivers/base/core.c b/drivers/base/core.c
index b1727876182c..a0cfda553c9d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1144,25 +1144,11 @@ error:
1144} 1144}
1145EXPORT_SYMBOL_GPL(device_create); 1145EXPORT_SYMBOL_GPL(device_create);
1146 1146
1147/** 1147static int __match_devt(struct device *dev, void *data)
1148 * find_device - finds a device that was created with device_create()
1149 * @class: pointer to the struct class that this device was registered with
1150 * @devt: the dev_t of the device that was previously registered
1151 */
1152static struct device *find_device(struct class *class, dev_t devt)
1153{ 1148{
1154 struct device *dev = NULL; 1149 dev_t *devt = data;
1155 struct device *dev_tmp;
1156 1150
1157 down(&class->sem); 1151 return dev->devt == *devt;
1158 list_for_each_entry(dev_tmp, &class->devices, node) {
1159 if (dev_tmp->devt == devt) {
1160 dev = dev_tmp;
1161 break;
1162 }
1163 }
1164 up(&class->sem);
1165 return dev;
1166} 1152}
1167 1153
1168/** 1154/**
@@ -1177,9 +1163,11 @@ void device_destroy(struct class *class, dev_t devt)
1177{ 1163{
1178 struct device *dev; 1164 struct device *dev;
1179 1165
1180 dev = find_device(class, devt); 1166 dev = class_find_device(class, &devt, __match_devt);
1181 if (dev) 1167 if (dev) {
1168 put_device(dev);
1182 device_unregister(dev); 1169 device_unregister(dev);
1170 }
1183} 1171}
1184EXPORT_SYMBOL_GPL(device_destroy); 1172EXPORT_SYMBOL_GPL(device_destroy);
1185 1173
@@ -1203,9 +1191,11 @@ void destroy_suspended_device(struct class *class, dev_t devt)
1203{ 1191{
1204 struct device *dev; 1192 struct device *dev;
1205 1193
1206 dev = find_device(class, devt); 1194 dev = class_find_device(class, &devt, __match_devt);
1207 if (dev) 1195 if (dev) {
1208 device_pm_schedule_removal(dev); 1196 device_pm_schedule_removal(dev);
1197 put_device(dev);
1198 }
1209} 1199}
1210EXPORT_SYMBOL_GPL(destroy_suspended_device); 1200EXPORT_SYMBOL_GPL(destroy_suspended_device);
1211#endif /* CONFIG_PM_SLEEP */ 1201#endif /* CONFIG_PM_SLEEP */