All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] mmc: add bcm2835 driver
Date: Sat, 27 Oct 2012 21:28:12 -0600	[thread overview]
Message-ID: <508CA64C.8090601@wwwdotorg.org> (raw)
In-Reply-To: <508A7510.4040106@gmail.com>

On 10/26/2012 05:33 AM, Vikram Narayanan wrote:
> Some nitpicks.
> 
> On 10/24/2012 10:20 AM, Stephen Warren wrote:
>> This adds a simple driver for the BCM2835's SD controller.
>>
>> Workarounds are implemented for:
>> * Register writes can't be too close to each-other in time, or they will
>>    be lost.
>> * Register accesses must all be 32-bit, so implement custom accessors.
...

>> +static u8 bcm2835_sdhci_readb(struct sdhci_host *host, int reg)
>> +{
>> +    u32 val = bcm2835_sdhci_raw_readl(host, (reg&  ~3));
>> +    val = val>>  (reg<<  3&  0x18)&  0xff;
>> +
>> +    return (u8)val;
>> +}
> 
> Can the above used magics be made as macros?

This code was taken directly from the downstream Linux kernel, so I
changed it as little as possible, to make comparisons easier. Still, if
people want I can certainly make it easier to understand the expression
a bit.

I don't think the issue is the magic numbers so much as understanding
what the expression does; the magic are obvious then. It's simply
extracting byte n from from a u32. Would the following be more obvious:

byte_num = reg & 3;
byte_shift = bytenum * 8;
byte = (val >> byte_shift) & 0xff;

... and similar for the other functions?

  reply	other threads:[~2012-10-28  3:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24  4:50 [U-Boot] [PATCH 1/2] mmc: add bcm2835 driver Stephen Warren
2012-10-24  4:50 ` [U-Boot] [PATCH 2/2] ARM: rpi_b: enable SD controller, add related env/cmds Stephen Warren
2012-10-26 11:33 ` [U-Boot] [PATCH 1/2] mmc: add bcm2835 driver Vikram Narayanan
2012-10-28  3:28   ` Stephen Warren [this message]
2012-10-28 17:06     ` Vikram Narayanan
2012-11-04 15:32       ` Albert ARIBAUD
2012-11-04 17:15         ` Stephen Warren
2012-10-26 17:32 ` Tom Rini
2012-10-26 17:48   ` Oleksandr Tymoshenko
2012-10-26 18:05     ` Tom Rini
2012-10-26 18:21       ` Stephen Warren
2012-10-26 18:10     ` Greg KH

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=508CA64C.8090601@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=u-boot@lists.denx.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.