linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ladis@linux-mips.org (Ladislav Michl)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] clocksource: timer-dm: Make unexported functions static
Date: Mon, 22 Jan 2018 11:39:37 +0100	[thread overview]
Message-ID: <20180122103936.GB19401@lenoch> (raw)
In-Reply-To: <755fca20-7544-1655-47c7-83b1a2669adc@microchip.com>

On Mon, Jan 22, 2018 at 11:26:44AM +0200, Claudiu Beznea wrote:
> On 17.01.2018 23:48, Ladislav Michl wrote:
> > As dmtimer no longer exports functions, make those previously
> > exported static.
> > 
> > Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> > ---
> >  Note: only those functions assigned to timer ops are made static
> >        as some others will be needed later for event capture.
> > 
> >  drivers/clocksource/timer-dm.c |  218 ++++++++++++++++++++---------------------
> >  include/clocksource/dmtimer.h  |   24 ----
> >  2 files changed, 109 insertions(+), 133 deletions(-)
> > 
> > diff --git a/drivers/clocksource/timer-dm.c b/drivers/clocksource/timer-dm.c
> > index 324ec93d3dd2..8de9e543d129 100644
> > --- a/drivers/clocksource/timer-dm.c
> > +++ b/drivers/clocksource/timer-dm.c
> > @@ -163,6 +163,92 @@ static int omap_dm_timer_of_set_source(struct omap_dm_timer *timer)
> >  	return ret;
> >  }
> >  
> > +static int omap_dm_timer_set_source(struct omap_dm_timer *timer, int source)
> > +{
> > +	int ret;
> > +	char *parent_name = NULL;
> Could be declared as const: const char *parent_name = NULL;
> 
> > +	struct clk *parent;
> > +	struct dmtimer_platform_data *pdata;
> > +
> > +	if (unlikely(!timer))
> > +		return -EINVAL;
> > +
> > +	pdata = timer->pdev->dev.platform_data;
> > +
> > +	if (source < 0 || source >= 3)
> > +		return -EINVAL;
> > +
> > +	/*
> > +	 * FIXME: Used for OMAP1 devices only because they do not currently
> > +	 * use the clock framework to set the parent clock. To be removed
> > +	 * once OMAP1 migrated to using clock framework for dmtimers
> > +	 */
> > +	if (pdata && pdata->set_timer_src)
> > +		return pdata->set_timer_src(timer->pdev, source);
> > +
> > +	if (IS_ERR(timer->fclk))
> > +		return -EINVAL;
> Souldn't this check be done at the beginning of the function?

Well, this patch only moves existing functions around, just to make it
compile after declarations are removed from header file.

Fixes should be sent separately as this is not the only problem with
clocksource code :)

Anyway, thank you for review, this one could be addressed by a following
patch:

diff --git a/drivers/clocksource/timer-dm.c b/drivers/clocksource/timer-dm.c
index dbf2b1f6a941..02b3436db70e 100644
--- a/drivers/clocksource/timer-dm.c
+++ b/drivers/clocksource/timer-dm.c
@@ -166,17 +166,30 @@ 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;
+	switch (source) {
+	case OMAP_TIMER_SRC_SYS_CLK:
+		parent_name = "timer_sys_ck";
+		break;
 
-	if (source < 0 || source >= 3)
+	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 +199,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);

      reply	other threads:[~2018-01-22 10:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-17 21:46 [PATCH 0/3] omap: dmtimer: Fix and cleanup moved driver Ladislav Michl
2018-01-17 21:47 ` [PATCH 1/3] clocksource: timer-dm: Check prescaler value Ladislav Michl
2018-01-22  9:00   ` Claudiu Beznea
2018-01-22  9:59     ` Ladislav Michl
2018-01-22 10:04       ` Claudiu Beznea
2018-01-17 21:47 ` [PATCH 2/3] pwm: pwm-omap-dmtimer: Fix frequency when using prescaler Ladislav Michl
2018-01-22  9:17   ` Claudiu Beznea
2018-01-22 10:53     ` Ladislav Michl
2018-01-24  5:26       ` Keerthy
2018-01-24  5:49         ` Keerthy
2018-01-17 21:48 ` [PATCH 3/3] clocksource: timer-dm: Make unexported functions static Ladislav Michl
2018-01-22  9:26   ` Claudiu Beznea
2018-01-22 10:39     ` Ladislav Michl [this message]

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=20180122103936.GB19401@lenoch \
    --to=ladis@linux-mips.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).