diff mbox series

[5/8] clk: ti: Use clock-output-names for clkctrl

Message ID 20220204071449.16762-6-tony@atomide.com (mailing list archive)
State Accepted, archived
Headers show
Series Clock changes for TI dts reg and node name issues | expand

Commit Message

Tony Lindgren Feb. 4, 2022, 7:14 a.m. UTC
Use clock-output-names devicetree property for clkctrl clocks if
available.

Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/clk/ti/clkctrl.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

Comments

Stephen Boyd March 11, 2022, 3:31 a.m. UTC | #1
Quoting Tony Lindgren (2022-02-03 23:14:46)
> Use clock-output-names devicetree property for clkctrl clocks if
> available.
> 
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---

Applied to clk-next
diff mbox series

Patch

diff --git a/drivers/clk/ti/clkctrl.c b/drivers/clk/ti/clkctrl.c
--- a/drivers/clk/ti/clkctrl.c
+++ b/drivers/clk/ti/clkctrl.c
@@ -469,14 +469,32 @@  static void __init _clkctrl_add_provider(void *data,
 	of_clk_add_hw_provider(np, _ti_omap4_clkctrl_xlate, data);
 }
 
-/* Get clock name based on compatible string for clkctrl */
-static char * __init clkctrl_get_name(struct device_node *np)
+/*
+ * Get clock name based on "clock-output-names" property or the
+ * compatible property for clkctrl.
+ */
+static const char * __init clkctrl_get_name(struct device_node *np)
 {
 	struct property *prop;
 	const int prefix_len = 11;
 	const char *compat;
+	const char *output;
 	char *name;
 
+	if (!of_property_read_string_index(np, "clock-output-names", 0,
+					   &output)) {
+		const char *end;
+		int len;
+
+		len = strlen(output);
+		end = strstr(output, "_clkctrl");
+		if (end)
+			len -= strlen(end);
+		name = kstrndup(output, len, GFP_KERNEL);
+
+		return name;
+	}
+
 	of_property_for_each_string(np, "compatible", prop, compat) {
 		if (!strncmp("ti,clkctrl-", compat, prefix_len)) {
 			/* Two letter minimum name length for l3, l4 etc */