public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: tomasz.figa@gmail.com (Tomasz Figa)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCHv7 1/4] pwm: Add Freescale FTM PWM driver support
Date: Tue, 17 Dec 2013 13:54:35 +0100	[thread overview]
Message-ID: <1500339.E8bGm7xZUi@flatron> (raw)
In-Reply-To: <20131217124505.GB17210@ulmo.nvidia.com>

On Tuesday 17 of December 2013 13:45:06 Thierry Reding wrote:
> On Tue, Dec 17, 2013 at 01:00:10PM +0100, Tomasz Figa wrote:
> > On Tuesday 17 of December 2013 11:51:36 Russell King - ARM Linux wrote:
> > > On Tue, Dec 17, 2013 at 12:10:22PM +0100, Thierry Reding wrote:
> > > > On Fri, Dec 13, 2013 at 04:57:04PM +0800, Xiubo Li wrote:
> > > > > +static inline u32 fsl_pwm_readl(struct fsl_pwm_chip *fpc,
> > > > > +		const void __iomem *addr)
> > > > > +{
> > > > > +	u32 val;
> > > > > +
> > > > > +	val = __raw_readl(addr);
> > > > > +
> > > > > +	if (likely(fpc->big_endian))
> > > > 
> > > > The likely() probably isn't very useful in this case. But if you want to
> > > > keep it, it should at least be reversed, since little-endian is actually
> > > > the default (you have to specify the big-endian property to activate the
> > > > big endian mode).
> > > > 
> > > > > +		val = be32_to_cpu(val);
> > > > > +	else
> > > > > +		val = le32_to_cpu(val);
> > > 
> > > This will also cause sparse errors, because when sparse is enabled, these
> > > expect __le32 or __be32 arguments, not u32.
> > 
> > My question is why can't you just create two sets of accessors, one big
> > endian and one little endian, add two function pointers to your
> > fsl_pwm_chip struct and let the driver set the to correct accessors in
> > probe?
> 
> I guess that would be one possibility.
> 
> > This would eliminate the problem with types Russell mentioned and IMHO
> > make the code cleaner.
> 
> I fail to see how that would eliminate the problem with the types. That
> said I don't actually see sparse complaining about any type mismatches.
> That's probably because the various macros implicitly cast to u32.

Well, in BE variant you would read the register using __raw_readl() into
a __be32 and then get an u32 from be32_to_cpu() and return it. Similarly
for writes

In LE variant, readl()/writel() could be used directly.

> 
> > > > > +	rmb();
> > > > 
> > > > I'd prefer the rmb() to follow the __raw_readl() immediately to make the
> > > > relationship more explicit.
> > > 
> > > A better question to ask is: why is this barrier here?  What memory
> > > ordering operations is it trying to serialise?
> > 
> > I'd also add a question why __raw accessors are used here.
> 
> Because both readl() and writel() explicitly perform little endian
> accesses.

Right. Thanks for pointing this out.

Best regards,
Tomasz

  reply	other threads:[~2013-12-17 12:54 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-13  8:57 [PATCHv7 0/4] Add Freescale FTM PWM driver Xiubo Li
2013-12-13  8:57 ` [PATCHv7 1/4] pwm: Add Freescale FTM PWM driver support Xiubo Li
2013-12-17 11:10   ` Thierry Reding
2013-12-17 11:51     ` Russell King - ARM Linux
2013-12-17 12:00       ` Tomasz Figa
2013-12-17 12:45         ` Thierry Reding
2013-12-17 12:54           ` Tomasz Figa [this message]
2013-12-17 13:04             ` Russell King - ARM Linux
2013-12-17 13:08               ` Tomasz Figa
2013-12-17 13:22               ` Thierry Reding
2013-12-18  9:43               ` Li.Xiubo at freescale.com
2013-12-18  6:28           ` Li.Xiubo at freescale.com
2013-12-17 12:24       ` Thierry Reding
2013-12-17 12:58         ` Russell King - ARM Linux
2013-12-17 13:19           ` Thierry Reding
2013-12-18  3:34     ` Li.Xiubo at freescale.com
2013-12-13  8:57 ` [PATCHv7 2/4] ARM: dts: Add Freescale FTM PWM node for VF610 Xiubo Li
2013-12-13  8:57 ` [PATCHv7 3/4] ARM: dts: Enables FTM PWM device for Vybrid VF610 TOWER board Xiubo Li
2013-12-13  8:57 ` [PATCHv7 4/4] Documentation: Add device tree bindings for Freescale FTM PWM Xiubo Li

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=1500339.E8bGm7xZUi@flatron \
    --to=tomasz.figa@gmail.com \
    --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