From: Ladislav Michl <ladis@linux-mips.org>
To: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-pwm@vger.kernel.org
Cc: t-kristo@ti.com, grygorii.strashko@ti.com, aaro.koskinen@iki.fi,
tony@atomide.com, Keerthy <j-keerthy@ti.com>,
daniel.lezcano@linaro.org, robh+dt@kernel.org,
narmstrong@baylibre.com, thierry.reding@gmail.com,
Brecht Neyrinck <brechtneyrinck@gmail.com>,
sebastian.reichel@collabora.co.uk,
Thomas Gleixner <tglx@linutronix.de>,
Claudiu.Beznea@microchip.com
Subject: [PATCH 2/6] clocksource: timer-ti-dm: Consolidate set source
Date: Fri, 23 Feb 2018 11:14:22 +0100 [thread overview]
Message-ID: <20180223101422.GC5746@lenoch> (raw)
In-Reply-To: <20180223101254.GA5746@lenoch>
Reorder omap_dm_timer_set_source internals to get
source verification more straightforward.
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
---
drivers/clocksource/timer-ti-dm.c | 38 ++++++++++++++++----------------------
1 file changed, 16 insertions(+), 22 deletions(-)
diff --git a/drivers/clocksource/timer-ti-dm.c b/drivers/clocksource/timer-ti-dm.c
index e4d75a8eaa91..4d645d6c6c31 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);
--
2.16.1
next prev parent reply other threads:[~2018-02-23 10:14 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-23 10:12 [PATCH 0/6] Implement event capture for OMAP (draft) Ladislav Michl
2018-02-23 10:13 ` [PATCH 1/6] clocksource: timer-ti-dm: Make unexported functions static Ladislav Michl
2018-02-27 18:06 ` Tony Lindgren
2018-02-27 19:07 ` Ladislav Michl
2018-02-27 19:23 ` Tony Lindgren
2018-02-28 22:11 ` Tony Lindgren
2018-02-23 10:14 ` Ladislav Michl [this message]
2018-02-23 10:15 ` [PATCH 3/6] clocksource: timer-ti-dm: Check prescaler value Ladislav Michl
2018-02-23 10:15 ` [PATCH 4/6] pwm: pwm-omap-dmtimer: Fix frequency when using prescaler Ladislav Michl
2018-03-27 21:53 ` Thierry Reding
2018-03-27 22:14 ` Thierry Reding
2018-03-27 22:23 ` Tony Lindgren
2018-03-28 0:34 ` Ladislav Michl
2018-02-23 10:16 ` [PATCH 5/6] clocksource: timer-ti-dm: Add event capture Ladislav Michl
2018-02-23 10:17 ` [PATCH 6/6] pwm: pwm-omap-dmtimer: Add capture functionality Ladislav Michl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180223101422.GC5746@lenoch \
--to=ladis@linux-mips.org \
--cc=Claudiu.Beznea@microchip.com \
--cc=aaro.koskinen@iki.fi \
--cc=brechtneyrinck@gmail.com \
--cc=daniel.lezcano@linaro.org \
--cc=grygorii.strashko@ti.com \
--cc=j-keerthy@ti.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=narmstrong@baylibre.com \
--cc=robh+dt@kernel.org \
--cc=sebastian.reichel@collabora.co.uk \
--cc=t-kristo@ti.com \
--cc=tglx@linutronix.de \
--cc=thierry.reding@gmail.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).