Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1248919

Re: [RFC PATCH 1/3] arm: plat-omap: dmtimer: Add clock source from DT

From Felipe Balbi <balbi@ti.com>
Newsgroups linux.kernel
Subject Re: [RFC PATCH 1/3] arm: plat-omap: dmtimer: Add clock source from DT
Date 2015-10-16 17:50 +0200
Message-ID <qkfqy-2iA-23@gated-at.bofh.it> (permalink)
References <qkcj0-6d1-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Hi,

Neil Armstrong <narmstrong@baylibre.com> writes:
> Add a function which sets the timer source from the clocks
> binding on dm_timer_prepare call.
>
> In case the clocks property is not valid, it falls back to
> the set_source() with 32_KHZ clock as default.
>
> Suggested-by: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  arch/arm/plat-omap/dmtimer.c | 32 ++++++++++++++++++++++++++++++--
>  1 file changed, 30 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/plat-omap/dmtimer.c b/arch/arm/plat-omap/dmtimer.c
> index 8ca94d3..5e8aece 100644
> --- a/arch/arm/plat-omap/dmtimer.c
> +++ b/arch/arm/plat-omap/dmtimer.c
> @@ -137,9 +137,33 @@ static int omap_dm_timer_reset(struct omap_dm_timer *timer)
>  	return 0;
>  }
>
> +static int omap_dm_timer_of_set_source(struct omap_dm_timer *timer)
> +{
> +	int ret;
> +	struct clk *parent;
> +
> +	if (unlikely(!timer))
> +		return -EINVAL;

IMO, let this crash. If this happens we have bigger problems.

> +	if (IS_ERR(timer->fclk))
> +		return -EINVAL;

We bail out if we can't get fclk, this check is unnecessary.

> +	parent = clk_get(&timer->pdev->dev, NULL);

why NULL ? You could use something more descriptive, but no strong
feelings.

> +	if (IS_ERR(parent))
> +		return -ENODEV;
> +
> +	ret = clk_set_parent(timer->fclk, parent);
> +	if (ret < 0)
> +		pr_err("%s: failed to set parent\n", __func__);
> +
> +	clk_put(parent);
> +
> +	return ret;
> +}
> +
>  static int omap_dm_timer_prepare(struct omap_dm_timer *timer)
>  {
> -	int rc;
> +	int rc, ret;

doesn't seem like you need this extra 'ret' variable. Just use 'rc'.

> @@ -166,7 +190,11 @@ static int omap_dm_timer_prepare(struct omap_dm_timer *timer)
>  	__omap_dm_timer_enable_posted(timer);
>  	omap_dm_timer_disable(timer);
>
> -	return omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
> +	ret = omap_dm_timer_of_set_source(timer);
> +	if (ret < 0 && ret == -ENODEV)

this < 0 check is pointless if you're going to check for equality to -ENODEV

> +		return omap_dm_timer_set_source(timer, OMAP_TIMER_SRC_32_KHZ);
> +
> +	return ret;
>  }
>
>  static inline u32 omap_dm_timer_reserved_systimer(int id)
> -- 
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

-- 
balbi

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[RFC PATCH 1/3] arm: plat-omap: dmtimer: Add clock source from DT Neil Armstrong <narmstrong@baylibre.com> - 2015-10-16 14:30 +0200
  Re: [RFC PATCH 1/3] arm: plat-omap: dmtimer: Add clock source from DT Felipe Balbi <balbi@ti.com> - 2015-10-16 17:50 +0200

csiph-web