All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: Neil Armstrong <narmstrong@baylibre.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Tony Lindgren <tony@atomide.com>,
	linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org,
	Grant Erickson <marathon96@gmail.com>, NeilBrown <neilb@suse.de>,
	Joachim Eastwood <manabian@gmail.com>
Subject: Re: [RFC PATCH 1/3] arm: plat-omap: dmtimer: Add clock source from DT
Date: Fri, 16 Oct 2015 10:40:43 -0500	[thread overview]
Message-ID: <87k2qmlt38.fsf@saruman.tx.rr.com> (raw)
In-Reply-To: <5620ED30.2050507@baylibre.com>

[-- Attachment #1: Type: text/plain, Size: 2563 bytes --]


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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: balbi@ti.com (Felipe Balbi)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/3] arm: plat-omap: dmtimer: Add clock source from DT
Date: Fri, 16 Oct 2015 10:40:43 -0500	[thread overview]
Message-ID: <87k2qmlt38.fsf@saruman.tx.rr.com> (raw)
In-Reply-To: <5620ED30.2050507@baylibre.com>


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 at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151016/019159f9/attachment.sig>

WARNING: multiple messages have this Message-ID (diff)
From: Felipe Balbi <balbi@ti.com>
To: Neil Armstrong <narmstrong@baylibre.com>,
	Thierry Reding <thierry.reding@gmail.com>,
	Tony Lindgren <tony@atomide.com>, <linux-pwm@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-omap@vger.kernel.org>,
	Grant Erickson <marathon96@gmail.com>, NeilBrown <neilb@suse.de>,
	Joachim Eastwood <manabian@gmail.com>
Subject: Re: [RFC PATCH 1/3] arm: plat-omap: dmtimer: Add clock source from DT
Date: Fri, 16 Oct 2015 10:40:43 -0500	[thread overview]
Message-ID: <87k2qmlt38.fsf@saruman.tx.rr.com> (raw)
In-Reply-To: <5620ED30.2050507@baylibre.com>

[-- Attachment #1: Type: text/plain, Size: 2563 bytes --]


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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 818 bytes --]

  reply	other threads:[~2015-10-16 15:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-16 12:27 [RFC PATCH 1/3] arm: plat-omap: dmtimer: Add clock source from DT Neil Armstrong
2015-10-16 12:27 ` Neil Armstrong
2015-10-16 15:40 ` Felipe Balbi [this message]
2015-10-16 15:40   ` Felipe Balbi
2015-10-16 15:40   ` Felipe Balbi
2015-10-19 12:41   ` Neil Armstrong
2015-10-19 12:41     ` Neil Armstrong

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=87k2qmlt38.fsf@saruman.tx.rr.com \
    --to=balbi@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=manabian@gmail.com \
    --cc=marathon96@gmail.com \
    --cc=narmstrong@baylibre.com \
    --cc=neilb@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.