]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
of: device: Support loading a module with OF based modalias
authorStephen Boyd <stephen.boyd@linaro.org>
Wed, 28 Dec 2016 22:56:47 +0000 (14:56 -0800)
committerPeter Chen <peter.chen@nxp.com>
Fri, 20 Jan 2017 03:23:51 +0000 (11:23 +0800)
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>
drivers/of/device.c
include/linux/of_device.h

index fd5cfad7c4030e58bb817c4b2a56c49b674a1eba..8a22a253a830aaa70caf38fd8758af2a330b7c31 100644 (file)
@@ -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
  */
index cc7dd687a89dd60699ebe28556138e293bcde9bc..e9afbcc8de120b2dadbbf193ab20095aef6043d3 100644 (file)
@@ -37,6 +37,7 @@ extern const void *of_device_get_match_data(const struct device *dev);
 
 extern ssize_t of_device_get_modalias(struct device *dev,
                                        char *str, ssize_t len);
+extern int of_device_request_module(struct device *dev);
 
 extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env);
 extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env);
@@ -78,6 +79,11 @@ static inline int of_device_get_modalias(struct device *dev,
        return -ENODEV;
 }
 
+static inline int of_device_request_module(struct device *dev)
+{
+       return -ENODEV;
+}
+
 static inline int of_device_uevent_modalias(struct device *dev,
                                   struct kobj_uevent_env *env)
 {