summaryrefslogtreecommitdiffstats
path: root/drivers/usb/dwc3/dwc3-of-simple.c
diff options
context:
space:
mode:
authorFelipe Balbi <felipe.balbi@linux.intel.com>2016-09-12 21:20:22 +0300
committerFelipe Balbi <felipe.balbi@linux.intel.com>2016-09-13 08:40:40 +0300
commit26c9cac402c491c552caf7483eda49aee095243a (patch)
tree860f7d27b14988019edcb022d4267321fba7e2ab /drivers/usb/dwc3/dwc3-of-simple.c
parent8d53e626759415700022d421e4e0eab245c2dc23 (diff)
downloadlinux-stable-26c9cac402c491c552caf7483eda49aee095243a.tar.gz
linux-stable-26c9cac402c491c552caf7483eda49aee095243a.tar.bz2
linux-stable-26c9cac402c491c552caf7483eda49aee095243a.zip
usb: dwc3: of-simple: allow glues without clocks
Instead of erroring out when we don't have clocks, let's just avoid any calls to the clk API. Tested-by: Steven J. Hill <Steven.Hill@cavium.com> Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Diffstat (limited to 'drivers/usb/dwc3/dwc3-of-simple.c')
-rw-r--r--drivers/usb/dwc3/dwc3-of-simple.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/drivers/usb/dwc3/dwc3-of-simple.c b/drivers/usb/dwc3/dwc3-of-simple.c
index ce9a070f4fe6..ed6bbb31ec90 100644
--- a/drivers/usb/dwc3/dwc3-of-simple.c
+++ b/drivers/usb/dwc3/dwc3-of-simple.c
@@ -36,36 +36,25 @@ struct dwc3_of_simple {
int num_clocks;
};
-static int dwc3_of_simple_probe(struct platform_device *pdev)
+static int dwc3_of_simple_clk_init(struct dwc3_of_simple *simple, int count)
{
- struct dwc3_of_simple *simple;
- struct device *dev = &pdev->dev;
+ struct device *dev = simple->dev;
struct device_node *np = dev->of_node;
-
- unsigned int count;
- int ret;
int i;
- simple = devm_kzalloc(dev, sizeof(*simple), GFP_KERNEL);
- if (!simple)
- return -ENOMEM;
+ simple->num_clocks = count;
- count = of_clk_get_parent_count(np);
if (!count)
- return -ENOENT;
-
- simple->num_clocks = count;
+ return 0;
simple->clks = devm_kcalloc(dev, simple->num_clocks,
sizeof(struct clk *), GFP_KERNEL);
if (!simple->clks)
return -ENOMEM;
- platform_set_drvdata(pdev, simple);
- simple->dev = dev;
-
for (i = 0; i < simple->num_clocks; i++) {
struct clk *clk;
+ int ret;
clk = of_clk_get(np, i);
if (IS_ERR(clk)) {
@@ -88,6 +77,29 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
simple->clks[i] = clk;
}
+ return 0;
+}
+
+static int dwc3_of_simple_probe(struct platform_device *pdev)
+{
+ struct dwc3_of_simple *simple;
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+
+ int ret;
+ int i;
+
+ simple = devm_kzalloc(dev, sizeof(*simple), GFP_KERNEL);
+ if (!simple)
+ return -ENOMEM;
+
+ platform_set_drvdata(pdev, simple);
+ simple->dev = dev;
+
+ ret = dwc3_of_simple_clk_init(simple, of_clk_get_parent_count(np));
+ if (ret)
+ return ret;
+
ret = of_platform_populate(np, NULL, NULL, dev);
if (ret) {
for (i = 0; i < simple->num_clocks; i++) {