Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1548097

[PATCH v6 01/25] of: device: Support loading a module with OF based modalias

From Stephen Boyd <stephen.boyd@linaro.org>
Newsgroups linux.kernel
Subject [PATCH v6 01/25] of: device: Support loading a module with OF based modalias
Date 2016-12-29 00:10 +0100
Message-ID <sTvw5-6Mq-3@gated-at.bofh.it> (permalink)
References <sTvmp-6sL-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 drivers/of/device.c       | 23 +++++++++++++++++++++++
 include/linux/of_device.h |  6 ++++++
 2 files changed, 29 insertions(+)

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
  */
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index cc7dd687a89d..e9afbcc8de12 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -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)
 {
-- 
2.10.0.297.gf6727b0

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v6 00/25] Support qcom's HSIC USB and rewrite USB2 HS support Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 01/25] of: device: Support loading a module with OF based modalias Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 03/25] usb: ulpi: Support device discovery via DT Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 07/25] usb: chipidea: Notify events when switching host mode Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 15/25] usb: chipidea: msm: Add proper clk and reset support Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 08/25] usb: chipidea: Remove locking in ci_udc_start() Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 14/25] usb: chipidea: msm: Use hw_write_id_reg() instead of writel Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 04/25] usb: chipidea: Only read/write OTGSC from one place Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 06/25] usb: chipidea: Add platform flag for wrapper phy management Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 13/25] usb: chipidea: msm: Rely on core to override AHBBURST Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 10/25] usb: chipidea: Consolidate extcon notifiers Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 05/25] usb: chipidea: Handle extcon events properly Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 11/25] usb: chipidea: vbus event may exist before starting gadget Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
    Re: [PATCH v6 11/25] usb: chipidea: vbus event may exist before  starting gadget Peter Chen <hzpeterchen@gmail.com> - 2017-01-03 09:10 +0100
  [PATCH v6 02/25] of: device: Export of_device_{get_modalias,uvent_modalias} to modules Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100
  [PATCH v6 16/25] usb: chipidea: msm: Mux over secondary phy at the right time Stephen Boyd <stephen.boyd@linaro.org> - 2016-12-29 00:10 +0100

csiph-web