summaryrefslogtreecommitdiff
path: root/drivers/clocksource/timer-ti-dm.c
diff options
context:
space:
mode:
authorLadislav Michl <ladis@linux-mips.org>2018-02-23 11:14:22 +0100
committerTony Lindgren <tony@atomide.com>2018-02-28 13:41:20 -0800
commitad6e4b6fdc99ebbd520d2faf3c6d48198c74a99b (patch)
tree08e634bd7d04bf5760bed4df12dc89c1db295968 /drivers/clocksource/timer-ti-dm.c
parent592ea6bd1fad6068fb7d813d36cfd832313f4421 (diff)
downloadlinux-ad6e4b6fdc99ebbd520d2faf3c6d48198c74a99b.tar.gz
clocksource: timer-ti-dm: Consolidate set source
Reorder omap_dm_timer_set_source internals to get source verification more straightforward. Signed-off-by: Ladislav Michl <ladis@linux-mips.org> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'drivers/clocksource/timer-ti-dm.c')
-rw-r--r--drivers/clocksource/timer-ti-dm.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c
index 935350176c01..6abe5ab553ce 100644
--- a/drivers/clocksource/timer-ti-dm.c
+++ b/drivers/clocksource/timer-ti-dm.c
@@ -166,17 +166,28 @@ static int omap_dm_timer_of_set_source(struct omap_dm_timer *timer)
static int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
{
int ret;
- char *parent_name = NULL;
+ const char *parent_name;
struct clk *parent;
struct dmtimer_platform_data *pdata;
- if (unlikely(!timer))
+ if (unlikely(!timer) || IS_ERR(timer->fclk))
return -EINVAL;
- pdata = timer->pdev->dev.platform_data;
-
- if (source < 0 || source >= 3)
+ switch (source) {
+ case OMAP_TIMER_SRC_SYS_CLK:
+ parent_name = "timer_sys_ck";
+ break;
+ case OMAP_TIMER_SRC_32_KHZ:
+ parent_name = "timer_32k_ck";
+ break;
+ case OMAP_TIMER_SRC_EXT_CLK:
+ parent_name = "timer_ext_ck";
+ break;
+ default:
return -EINVAL;
+ }
+
+ pdata = timer->pdev->dev.platform_data;
/*
* FIXME: Used for OMAP1 devices only because they do not currently
@@ -186,29 +197,12 @@ static int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
if (pdata && pdata->set_timer_src)
return pdata->set_timer_src(timer->pdev, source);
- if (IS_ERR(timer->fclk))
- return -EINVAL;
-
#if defined(CONFIG_COMMON_CLK)
/* Check if the clock has configurable parents */
if (clk_hw_get_num_parents(__clk_get_hw(timer->fclk)) < 2)
return 0;
#endif
- switch (source) {
- case OMAP_TIMER_SRC_SYS_CLK:
- parent_name = "timer_sys_ck";
- break;
-
- case OMAP_TIMER_SRC_32_KHZ:
- parent_name = "timer_32k_ck";
- break;
-
- case OMAP_TIMER_SRC_EXT_CLK:
- parent_name = "timer_ext_ck";
- break;
- }
-
parent = clk_get(&timer->pdev->dev, parent_name);
if (IS_ERR(parent)) {
pr_err("%s: %s not found\n", __func__, parent_name);