diff options
author | Simon Glass <sjg@chromium.org> | 2014-11-11 10:46:21 -0700 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2014-11-22 10:16:47 +0100 |
commit | e33dc221f45ca501319f5aebd1c88574238261be (patch) | |
tree | 1be16d0d508c305b89757063d0c2e939ea226714 /drivers/core | |
parent | a88340dfcf8a34cf7fe000c619d01e1d0f0a442a (diff) | |
download | u-boot-e33dc221f45ca501319f5aebd1c88574238261be.zip u-boot-e33dc221f45ca501319f5aebd1c88574238261be.tar.gz u-boot-e33dc221f45ca501319f5aebd1c88574238261be.tar.bz2 |
dm: Add a function to bind a device by driver name
In some cases we need to manually bind a device to a particular driver.
Add a function to do this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jagannadha Sutradharudu Teki <jagannadh.teki@gmail.com>
Acked-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/core')
-rw-r--r-- | drivers/core/lists.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/core/lists.c b/drivers/core/lists.c index 24d2864..7a1d660 100644 --- a/drivers/core/lists.c +++ b/drivers/core/lists.c @@ -77,6 +77,27 @@ int lists_bind_drivers(struct udevice *parent, bool pre_reloc_only) return result; } +int device_bind_driver(struct udevice *parent, const char *drv_name, + const char *dev_name, struct udevice **devp) +{ + struct driver *drv; + int ret; + + drv = lists_driver_lookup_name(drv_name); + if (!drv) { + printf("Cannot find driver '%s'\n", drv_name); + return -ENOENT; + } + ret = device_bind(parent, drv, dev_name, NULL, -1, devp); + if (ret) { + printf("Cannot create device named '%s' (err=%d)\n", + dev_name, ret); + return ret; + } + + return 0; +} + #ifdef CONFIG_OF_CONTROL /** * driver_check_compatible() - Check if a driver is compatible with this node |