All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Xiubo Li <Li.Xiubo@freescale.com>, tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] clocksource: fix clocksource_mmio_readX_down
Date: Tue, 22 Apr 2014 12:27:06 +0200	[thread overview]
Message-ID: <535643FA.1080908@linaro.org> (raw)
In-Reply-To: <1397726874-6349-1-git-send-email-Li.Xiubo@freescale.com>

On 04/17/2014 11:27 AM, Xiubo Li wrote:
> For some clocksource devices, for example, the registers are 32-bit, while
> the lower 16-bit is used for timer counting(And reading the upper 16-bit
> will return 0).
>
> For example, when the counter value is 0x00001111, and then the
> ~readl_relaxed(to_mmio_clksrc(c)->reg) will return the value of 0xFFFFEEEE,
> but it should be 0x0000EEEE.
>
> So just using the c->mask to mask the unused bits.
>
> Signed-off-by: Xiubo Li <Li.Xiubo@freescale.com>
> ---
>   drivers/clocksource/mmio.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clocksource/mmio.c b/drivers/clocksource/mmio.c
> index c0e2512..f17a0d1 100644
> --- a/drivers/clocksource/mmio.c
> +++ b/drivers/clocksource/mmio.c
> @@ -27,7 +27,7 @@ cycle_t clocksource_mmio_readl_up(struct clocksource *c)
>
>   cycle_t clocksource_mmio_readl_down(struct clocksource *c)
>   {
> -	return ~readl_relaxed(to_mmio_clksrc(c)->reg);
> +	return ~readl_relaxed(to_mmio_clksrc(c)->reg) & c->mask;
>   }
>
>   cycle_t clocksource_mmio_readw_up(struct clocksource *c)
> @@ -37,7 +37,7 @@ cycle_t clocksource_mmio_readw_up(struct clocksource *c)
>
>   cycle_t clocksource_mmio_readw_down(struct clocksource *c)
>   {
> -	return ~(unsigned)readw_relaxed(to_mmio_clksrc(c)->reg);
> +	return ~(unsigned)readw_relaxed(to_mmio_clksrc(c)->reg) & c->mask;
>   }
>
>   /**


Hi,

I realize there is some type confusion here:

cycle_t -> u64
readl_relaxed -> u32
readw_relaxed -> u16

and clocksource_mmio_readw_down returns a cast to unsigned (u32)

This patch makes sense but it obfuscate more the types in these 
functions. Worth to clarify the functions first ?


-- 
  <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog


  reply	other threads:[~2014-04-22 10:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-17  9:27 [PATCH] clocksource: fix clocksource_mmio_readX_down Xiubo Li
2014-04-22 10:27 ` Daniel Lezcano [this message]
2014-04-23  2:27   ` Li.Xiubo

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=535643FA.1080908@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=Li.Xiubo@freescale.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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.