/* The callback should return 0 if the device doesn't match and non-zero if it does. If the callback returns non-zero, this function will return to the caller and not iterate over any more devices.  */
struct device* bus_find_device(struct bus_type *bus, struct device *start, 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, this function will return to the caller and not iterate over any more devices.  */
struct device* bus_find_device(struct bus_type *bus, struct device *start, void *data, int(*match)(struct device *dev, void *data))
{
	struct klist_iter i;
	struct device *dev;
	if (!bus)
		return NULL;
	klist_iter_init_node(&bus->p->klist_devices, &i,
			     (start ? &start->p->knode_bus : NULL));
	while ((dev = next_device(&i)))
		if (match(dev, data) && get_device(dev))
			break;
	klist_iter_exit(&i);
	return dev;
}