Commit da0653fe authored by Rajendra Nayak's avatar Rajendra Nayak Committed by Paul Walmsley

OMAP2+: omap_device/clock: Do not expect an entry in clkdev for opt_clks

The _add_optional_clock_alias function expects an entry
already existing in the clkdev table in the form of
<dev-id=NULL, con-id=role> which might not be the case
always.

Instead, just check if an entry already exists in clkdev
in the <dev-id=dev_name, con-id=role> form, else go ahead
and add one.

Remove any assumption of an entry already existing in clkdev
table in any form.

Since this means, adding a new entry in clkdev if it does
not already exist, and not really adding an 'alias',
also rename the function name
(s/_add_optional_clock_alias/_add_optional_clock_clkdev)
to reflect this.
Signed-off-by: default avatarRajendra Nayak <rnayak@ti.com>
Reported-by: default avatarSumit Semwal <sumit.semwal@ti.com>
Cc: Sumit Semwal <sumit.semwal@ti.com>
Cc: Paul Walmsley <paul@pwsan.com>
Cc: Benoit Cousson <b-cousson@ti.com>
Cc: Kevin Hilman <khilman@ti.com>
Cc: Partha Basak <p-basak2@ti.com>
Signed-off-by: default avatarPaul Walmsley <paul@pwsan.com>
parent dd9c1549
...@@ -83,9 +83,11 @@ ...@@ -83,9 +83,11 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/clkdev.h>
#include <plat/omap_device.h> #include <plat/omap_device.h>
#include <plat/omap_hwmod.h> #include <plat/omap_hwmod.h>
#include <plat/clock.h>
/* These parameters are passed to _omap_device_{de,}activate() */ /* These parameters are passed to _omap_device_{de,}activate() */
#define USE_WAKEUP_LAT 0 #define USE_WAKEUP_LAT 0
...@@ -239,12 +241,12 @@ static inline struct omap_device *_find_by_pdev(struct platform_device *pdev) ...@@ -239,12 +241,12 @@ static inline struct omap_device *_find_by_pdev(struct platform_device *pdev)
} }
/** /**
* _add_optional_clock_alias - Add clock alias for hwmod optional clocks * _add_optional_clock_clkdev - Add clkdev entry for hwmod optional clocks
* @od: struct omap_device *od * @od: struct omap_device *od
* *
* For every optional clock present per hwmod per omap_device, this function * For every optional clock present per hwmod per omap_device, this function
* adds an entry in the clocks list of the form <dev-id=dev_name, con-id=role> * adds an entry in the clkdev table of the form <dev-id=dev_name, con-id=role>
* if an entry is already present in it with the form <dev-id=NULL, con-id=role> * if it does not exist already.
* *
* The function is called from inside omap_device_build_ss(), after * The function is called from inside omap_device_build_ss(), after
* omap_device_register. * omap_device_register.
...@@ -254,25 +256,39 @@ static inline struct omap_device *_find_by_pdev(struct platform_device *pdev) ...@@ -254,25 +256,39 @@ static inline struct omap_device *_find_by_pdev(struct platform_device *pdev)
* *
* No return value. * No return value.
*/ */
static void _add_optional_clock_alias(struct omap_device *od, static void _add_optional_clock_clkdev(struct omap_device *od,
struct omap_hwmod *oh) struct omap_hwmod *oh)
{ {
int i; int i;
for (i = 0; i < oh->opt_clks_cnt; i++) { for (i = 0; i < oh->opt_clks_cnt; i++) {
struct omap_hwmod_opt_clk *oc; struct omap_hwmod_opt_clk *oc;
int r; struct clk *r;
struct clk_lookup *l;
oc = &oh->opt_clks[i]; oc = &oh->opt_clks[i];
if (!oc->_clk) if (!oc->_clk)
continue; continue;
r = clk_add_alias(oc->role, dev_name(&od->pdev.dev), r = clk_get_sys(dev_name(&od->pdev.dev), oc->role);
(char *)oc->clk, &od->pdev.dev); if (!IS_ERR(r))
if (r) continue; /* clkdev entry exists */
pr_err("omap_device: %s: clk_add_alias for %s failed\n",
r = omap_clk_get_by_name((char *)oc->clk);
if (IS_ERR(r)) {
pr_err("omap_device: %s: omap_clk_get_by_name for %s failed\n",
dev_name(&od->pdev.dev), oc->clk);
continue;
}
l = clkdev_alloc(r, oc->role, dev_name(&od->pdev.dev));
if (!l) {
pr_err("omap_device: %s: clkdev_alloc for %s failed\n",
dev_name(&od->pdev.dev), oc->role); dev_name(&od->pdev.dev), oc->role);
return;
}
clkdev_add(l);
} }
} }
...@@ -480,7 +496,7 @@ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id, ...@@ -480,7 +496,7 @@ struct omap_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
for (i = 0; i < oh_cnt; i++) { for (i = 0; i < oh_cnt; i++) {
hwmods[i]->od = od; hwmods[i]->od = od;
_add_optional_clock_alias(od, hwmods[i]); _add_optional_clock_clkdev(od, hwmods[i]);
} }
if (ret) if (ret)
......
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