diff options
author | Stephen Boyd <stephen.boyd@linaro.org> | 2016-12-28 14:56:47 -0800 |
---|---|---|
committer | Peter Chen <peter.chen@nxp.com> | 2017-01-20 11:23:51 +0800 |
commit | 9c829c097f2f1cbebcfff69a7254b1df9852fe4e (patch) | |
tree | 0c2329e62da791c3488f07b42df3f4a41f24a984 /drivers/of/device.c | |
parent | 3f991aa0b665c8e9bb702421a4e5005c3588fb62 (diff) | |
download | linux-9c829c097f2f1cbebcfff69a7254b1df9852fe4e.tar.bz2 |
of: device: Support loading a module with OF based modalias
In the case of ULPI devices, we want to be able to load the
driver before registering the device so that we don't get stuck
in a loop waiting for the phy module to appear and failing usb
controller probe. Currently we request the ulpi module via the
ulpi ids, but in the DT case we might need to request it with the
OF based modalias instead. Add a common function that allows
anyone to request a module with the OF based modalias.
Acked-by: Rob Herring <robh@kernel.org>
Cc: <devicetree@vger.kernel.org>
Signed-off-by: Stephen Boyd <stephen.boyd@linaro.org>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
Diffstat (limited to 'drivers/of/device.c')
-rw-r--r-- | drivers/of/device.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/drivers/of/device.c b/drivers/of/device.c index fd5cfad7c403..8a22a253a830 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -226,6 +226,29 @@ ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len) return tsize; } +int of_device_request_module(struct device *dev) +{ + char *str; + ssize_t size; + int ret; + + size = of_device_get_modalias(dev, NULL, 0); + if (size < 0) + return size; + + str = kmalloc(size + 1, GFP_KERNEL); + if (!str) + return -ENOMEM; + + of_device_get_modalias(dev, str, size); + str[size] = '\0'; + ret = request_module(str); + kfree(str); + + return ret; +} +EXPORT_SYMBOL_GPL(of_device_request_module); + /** * of_device_uevent - Display OF related uevent information */ |