Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 41198
b: refs/heads/master
c: 5ab6998
h: refs/heads/master
v: v3
  • Loading branch information
Cornelia Huck authored and Greg Kroah-Hartman committed Dec 1, 2006
1 parent 8f27ca7 commit 0865678
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 035ed7a49447bc8e15d4d9316fc6a359b2d94333
refs/heads/master: 5ab699810d46011ad2195c5916f3cbc684bfe3ee
33 changes: 33 additions & 0 deletions trunk/drivers/base/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,45 @@ int device_for_each_child(struct device * parent, void * data,
return error;
}

/**
* device_find_child - device iterator for locating a particular device.
* @parent: parent struct device
* @data: Data to pass to match function
* @match: Callback function to check device
*
* This is similar to the device_for_each_child() function above, but it
* returns a reference to a device that is 'found' for later use, as
* determined by the @match callback.
*
* The callback should return 0 if the device doesn't match and non-zero
* if it does. If the callback returns non-zero and a reference to the
* current device can be obtained, this function will return to the caller
* and not iterate over any more devices.
*/
struct device * device_find_child(struct device *parent, void *data,
int (*match)(struct device *, void *))
{
struct klist_iter i;
struct device *child;

if (!parent)
return NULL;

klist_iter_init(&parent->klist_children, &i);
while ((child = next_device(&i)))
if (match(child, data) && get_device(child))
break;
klist_iter_exit(&i);
return child;
}

int __init devices_init(void)
{
return subsystem_register(&devices_subsys);
}

EXPORT_SYMBOL_GPL(device_for_each_child);
EXPORT_SYMBOL_GPL(device_find_child);

EXPORT_SYMBOL_GPL(device_initialize);
EXPORT_SYMBOL_GPL(device_add);
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,8 @@ extern int __must_check device_add(struct device * dev);
extern void device_del(struct device * dev);
extern int device_for_each_child(struct device *, void *,
int (*fn)(struct device *, void *));
extern struct device *device_find_child(struct device *, void *data,
int (*match)(struct device *, void *));
extern int device_rename(struct device *dev, char *new_name);

/*
Expand Down

0 comments on commit 0865678

Please sign in to comment.