/* 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 *dev, void *data))
/* 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 *dev, void *data))
{
	struct klist_iter i;
	struct device *child;
	if (!parent)
		return NULL;
	klist_iter_init(&parent->p->klist_children, &i);
	while ((child = next_device(&i)))
		if (match(child, data) && get_device(child))
			break;
	klist_iter_exit(&i);
	return child;
}