Commit 26c9cac4 authored by Felipe Balbi's avatar Felipe Balbi

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: default avatarSteven J. Hill <Steven.Hill@cavium.com>
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 8d53e626
...@@ -36,36 +36,25 @@ struct dwc3_of_simple { ...@@ -36,36 +36,25 @@ struct dwc3_of_simple {
int num_clocks; 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 = simple->dev;
struct device *dev = &pdev->dev;
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
unsigned int count;
int ret;
int i; int i;
simple = devm_kzalloc(dev, sizeof(*simple), GFP_KERNEL); simple->num_clocks = count;
if (!simple)
return -ENOMEM;
count = of_clk_get_parent_count(np);
if (!count) if (!count)
return -ENOENT; return 0;
simple->num_clocks = count;
simple->clks = devm_kcalloc(dev, simple->num_clocks, simple->clks = devm_kcalloc(dev, simple->num_clocks,
sizeof(struct clk *), GFP_KERNEL); sizeof(struct clk *), GFP_KERNEL);
if (!simple->clks) if (!simple->clks)
return -ENOMEM; return -ENOMEM;
platform_set_drvdata(pdev, simple);
simple->dev = dev;
for (i = 0; i < simple->num_clocks; i++) { for (i = 0; i < simple->num_clocks; i++) {
struct clk *clk; struct clk *clk;
int ret;
clk = of_clk_get(np, i); clk = of_clk_get(np, i);
if (IS_ERR(clk)) { if (IS_ERR(clk)) {
...@@ -88,6 +77,29 @@ static int dwc3_of_simple_probe(struct platform_device *pdev) ...@@ -88,6 +77,29 @@ static int dwc3_of_simple_probe(struct platform_device *pdev)
simple->clks[i] = clk; 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); ret = of_platform_populate(np, NULL, NULL, dev);
if (ret) { if (ret) {
for (i = 0; i < simple->num_clocks; i++) { for (i = 0; i < simple->num_clocks; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment