diff options
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r-- | drivers/base/class.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c index 2eb7048003a8..3918d0e432d4 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c | |||
@@ -302,6 +302,7 @@ EXPORT_SYMBOL_GPL(class_for_each_device); | |||
302 | /** | 302 | /** |
303 | * class_find_device - device iterator for locating a particular device | 303 | * class_find_device - device iterator for locating a particular device |
304 | * @class: the class we're iterating | 304 | * @class: the class we're iterating |
305 | * @start: Device to begin with | ||
305 | * @data: data for the match function | 306 | * @data: data for the match function |
306 | * @match: function to check device | 307 | * @match: function to check device |
307 | * | 308 | * |
@@ -319,8 +320,9 @@ EXPORT_SYMBOL_GPL(class_for_each_device); | |||
319 | * re-acquired in @match, otherwise it will self-deadlocking. For | 320 | * re-acquired in @match, otherwise it will self-deadlocking. For |
320 | * example, calls to add or remove class members would be verboten. | 321 | * example, calls to add or remove class members would be verboten. |
321 | */ | 322 | */ |
322 | struct device *class_find_device(struct class *class, void *data, | 323 | struct device *class_find_device(struct class *class, struct device *start, |
323 | int (*match)(struct device *, void *)) | 324 | void *data, |
325 | int (*match)(struct device *, void *)) | ||
324 | { | 326 | { |
325 | struct device *dev; | 327 | struct device *dev; |
326 | int found = 0; | 328 | int found = 0; |
@@ -330,15 +332,17 @@ struct device *class_find_device(struct class *class, void *data, | |||
330 | 332 | ||
331 | down(&class->sem); | 333 | down(&class->sem); |
332 | list_for_each_entry(dev, &class->devices, node) { | 334 | list_for_each_entry(dev, &class->devices, node) { |
335 | if (start) { | ||
336 | if (start == dev) | ||
337 | start = NULL; | ||
338 | continue; | ||
339 | } | ||
333 | dev = get_device(dev); | 340 | dev = get_device(dev); |
334 | if (dev) { | 341 | if (match(dev, data)) { |
335 | if (match(dev, data)) { | 342 | found = 1; |
336 | found = 1; | ||
337 | break; | ||
338 | } else | ||
339 | put_device(dev); | ||
340 | } else | ||
341 | break; | 343 | break; |
344 | } else | ||
345 | put_device(dev); | ||
342 | } | 346 | } |
343 | up(&class->sem); | 347 | up(&class->sem); |
344 | 348 | ||