Skip to content

Commit 8b2830b

Browse files
committed
bus: ti-sysc: Make child clock alias handling more generic
In order to prepare supporting clkctrl optional clocks, we need to make the current child clock handling more generic so we can use the clock role names for the optional clocks in the following patch. Cc: Tero Kristo <t-kristo@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com>
1 parent c4bebea commit 8b2830b

1 file changed

Lines changed: 23 additions & 13 deletions

File tree

‎drivers/bus/ti-sysc.c‎

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -811,29 +811,38 @@ static int sysc_init_syss_mask(struct sysc *ddata)
811811
}
812812

813813
/*
814-
* Many child device drivers need to have fck available to get the clock
815-
* rate for device internal configuration.
814+
* Many child device drivers need to have fck and opt clocks available
815+
* to get the clock rate for device internal configuration etc.
816816
*/
817-
static int sysc_child_add_fck(struct sysc *ddata,
818-
struct device *child)
817+
static int sysc_child_add_named_clock(struct sysc *ddata,
818+
struct device *child,
819+
const char *name)
819820
{
820-
struct clk *fck;
821+
struct clk *clk;
821822
struct clk_lookup *l;
822-
const char *name = clock_names[SYSC_FCK];
823+
int error = 0;
823824

824-
if (IS_ERR_OR_NULL(ddata->clocks[SYSC_FCK]))
825+
if (!name)
825826
return 0;
826827

827-
fck = clk_get(child, name);
828-
if (!IS_ERR(fck)) {
829-
clk_put(fck);
828+
clk = clk_get(child, name);
829+
if (!IS_ERR(clk)) {
830+
clk_put(clk);
830831

831832
return -EEXIST;
832833
}
833834

834-
l = clkdev_create(ddata->clocks[SYSC_FCK], name, dev_name(child));
835+
clk = clk_get(ddata->dev, name);
836+
if (IS_ERR(clk))
837+
return -ENODEV;
838+
839+
l = clkdev_create(clk, name, dev_name(child));
840+
if (!l)
841+
error = -ENOMEM;
835842

836-
return l ? 0 : -ENODEV;
843+
clk_put(clk);
844+
845+
return error;
837846
}
838847

839848
static struct device_type sysc_device_type = {
@@ -983,7 +992,8 @@ static int sysc_notifier_call(struct notifier_block *nb,
983992

984993
switch (event) {
985994
case BUS_NOTIFY_ADD_DEVICE:
986-
error = sysc_child_add_fck(ddata, dev);
995+
error = sysc_child_add_named_clock(ddata, dev,
996+
clock_names[SYSC_FCK]);
987997
if (error && error != -EEXIST)
988998
dev_warn(ddata->dev, "could not add %s fck: %i\n",
989999
dev_name(dev), error);

0 commit comments

Comments
 (0)