diff mbox

[RFC,1/3] OMAP: clocks: Use clk names instead of clk pointers

Message ID 504b9356bcc91cc2316b1623095e4f64@mail.gmail.com (mailing list archive)
State New, archived
Delegated to: Paul Walmsley
Headers show

Commit Message

Rajendra Nayak Jan. 20, 2011, 5:33 a.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c
index fc62fb5..9bfd193 100644
--- a/arch/arm/plat-omap/clock.c
+++ b/arch/arm/plat-omap/clock.c
@@ -308,6 +308,16 @@  void clk_enable_init_clocks(void)
 	}
 }

+static struct clk *_omap_clk_get_by_name(const char *name)
+{
+	struct clk *c;
+
+	list_for_each_entry(c, &clocks, node)
+		if (!strcmp(c->name, name))
+			return c;
+	return NULL;
+}
+
 /**
  * omap_clk_get_by_name - locate OMAP struct clk by its name
  * @name: name of the struct clk to locate
@@ -318,21 +328,45 @@  void clk_enable_init_clocks(void)
  */
 struct clk *omap_clk_get_by_name(const char *name)
 {
-	struct clk *c;
 	struct clk *ret = NULL;

 	mutex_lock(&clocks_mutex);
+	ret = _omap_clk_get_by_name(name);
+	mutex_unlock(&clocks_mutex);
+
+	return ret;
+}
+
+static inline void omap_init_dpll_data_clk_pts(struct dpll_data *dd)
+{
+	if (!dd->clk_ref && dd->clk_ref_name)
+		dd->clk_ref = _omap_clk_get_by_name(dd->clk_ref_name);
+	if (!dd->clk_bypass && dd->clk_bypass_name)
+		dd->clk_bypass =
_omap_clk_get_by_name(dd->clk_bypass_name);
+}
+
+static inline void omap_init_clksel_clk_pts(struct clksel *clks)
+{
+	if (!clks->parent && clks->parent_name)
+		clks->parent = _omap_clk_get_by_name(clks->parent_name);
+}
+
+void omap_init_clk_pts(void)
+{
+	struct clk *c;
+
+	mutex_lock(&clocks_mutex);

 	list_for_each_entry(c, &clocks, node) {
-		if (!strcmp(c->name, name)) {
-			ret = c;
-			break;
-		}
+		if (!c->parent && c->parent_name)
+			c->parent = _omap_clk_get_by_name(c->parent_name);
+		if (c->dpll_data)
+			omap_init_dpll_data_clk_pts(c->dpll_data);
+		if (c->clksel)
+			omap_init_clksel_clk_pts(c->clksel);
 	}

 	mutex_unlock(&clocks_mutex);
-
-	return ret;
 }

 /*
diff --git a/arch/arm/plat-omap/include/plat/clock.h
b/arch/arm/plat-omap/include/plat/clock.h
index 8eb0ada..dc0d9fd 100644
--- a/arch/arm/plat-omap/include/plat/clock.h
+++ b/arch/arm/plat-omap/include/plat/clock.h
@@ -85,6 +85,7 @@  struct clksel_rate {
 /**
  * struct clksel - available parent clocks, and a pointer to their
divisors
  * @parent: struct clk * to a possible parent clock
+ * @parent_name: Name of the possible parent clock
  * @rates: available divisors for this parent clock
  *