aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/class.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-05-22 17:21:08 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-22 00:54:47 -0400
commit695794ae0c5bdd9bd06e35b118801e2e9be04f9e (patch)
tree71011d17230e67798c6e474ffac10cb93d72919e /drivers/base/class.c
parent93562b537659fc0f63920fd4d9d24f54e434f4c4 (diff)
Driver Core: add ability for class_find_device to start in middle of list
This mirrors the functionality that driver_find_device has as well. We add a start variable, and all callers of the function are fixed up at the same time. The block layer will be using this new functionality in a follow-on patch. Cc: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r--drivers/base/class.c22
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 */
322struct device *class_find_device(struct class *class, void *data, 323struct 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