Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+23 -13
+23 -13
drivers/bus/ti-sysc.c
··· 811 811 } 812 812 813 813 /* 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. 816 816 */ 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) 819 820 { 820 - struct clk *fck; 821 + struct clk *clk; 821 822 struct clk_lookup *l; 822 - const char *name = clock_names[SYSC_FCK]; 823 + int error = 0; 823 824 824 - if (IS_ERR_OR_NULL(ddata->clocks[SYSC_FCK])) 825 + if (!name) 825 826 return 0; 826 827 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); 830 831 831 832 return -EEXIST; 832 833 } 833 834 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; 835 838 836 - return l ? 0 : -ENODEV; 839 + l = clkdev_create(clk, name, dev_name(child)); 840 + if (!l) 841 + error = -ENOMEM; 842 + 843 + clk_put(clk); 844 + 845 + return error; 837 846 } 838 847 839 848 static struct device_type sysc_device_type = { ··· 992 983 993 984 switch (event) { 994 985 case BUS_NOTIFY_ADD_DEVICE: 995 - error = sysc_child_add_fck(ddata, dev); 986 + error = sysc_child_add_named_clock(ddata, dev, 987 + clock_names[SYSC_FCK]); 996 988 if (error && error != -EEXIST) 997 989 dev_warn(ddata->dev, "could not add %s fck: %i\n", 998 990 dev_name(dev), error);