driver: implement device_detect_by_name function
It becomes a common pattern for boards to find a device and call device_detect on it. Add a convenience wrapper for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
b70bfc27e6
commit
8d2762ff56
|
@ -100,6 +100,16 @@ int device_detect(struct device_d *dev)
|
|||
return dev->detect(dev);
|
||||
}
|
||||
|
||||
int device_detect_by_name(const char *devname)
|
||||
{
|
||||
struct device_d *dev = get_device_by_name(devname);
|
||||
|
||||
if (!dev)
|
||||
return -ENODEV;
|
||||
|
||||
return device_detect(dev);
|
||||
}
|
||||
|
||||
static int match(struct driver_d *drv, struct device_d *dev)
|
||||
{
|
||||
int ret;
|
||||
|
|
|
@ -159,6 +159,7 @@ int device_probe(struct device_d *dev);
|
|||
|
||||
/* detect devices attached to this device (cards, disks,...) */
|
||||
int device_detect(struct device_d *dev);
|
||||
int device_detect_by_name(const char *devname);
|
||||
|
||||
/* Unregister a device. This function can fail, e.g. when the device
|
||||
* has children.
|
||||
|
|
Loading…
Reference in New Issue