From: "Jörn Engel" <joern@logfs.org>
To: Bryan Wu <bryan.wu@analog.com>
Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org,
will.newton@gmail.com, Mike Frysinger <vapier.adi@gmail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH try#2] [MTD/MAPS] Blackfin BF5xx Maps: Handle the case where flash memory and ethernet mac/phy are mapped onto the same async bank
Date: Mon, 12 May 2008 14:26:51 +0200 [thread overview]
Message-ID: <20080512122650.GA10014@logfs.org> (raw)
In-Reply-To: <1202020355.6671.23.camel@roc-laptop>
On Sun, 3 February 2008 14:32:35 +0800, Bryan Wu wrote:
> +
> +static void bf5xx_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
> +{
> + unsigned long i;
> + map_word test;
> +
> + if ((unsigned long)to & 0x1) {
> + for (i = 0; i < len / 2 * 2; i += 2) {
> + test = bf5xx_read(map, from + i);
> + put_unaligned(test.x[0], (__le16 *)(to + i));
> + }
> + } else {
> + for (i = 0; i < len / 2 * 2; i += 2) {
> + test = bf5xx_read(map, from + i);
> + *((u16*)(to + i)) = test.x[0];
^^^^^^^^^^^^^^^^^
I'm not particularly fond of such constructs, maybe because I have such
a hard time understanding what the code actually does.
How about:
u16 *foo = to;
for (i = 0; i < (len & ~1); i++) {
test = bf5xx_read(map, from + 2 * i);
foo[i] = test.x[0];
}
With perhaps a better name than "foo" and the same conversion in the
rest of the function as well?
> + }
> + }
> +
> + if (len & 0x1) {
> + test = bf5xx_read(map, from + i);
> + *((u8*)(to + i)) = (u8)test.x[0];
> + }
> +}
Jörn
--
There's nothing better for promoting creativity in a medium than
making an audience feel "Hmm I could do better than that!"
-- Douglas Adams in a slashdot interview
next prev parent reply other threads:[~2008-05-12 12:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-03 6:32 [PATCH try#2] [MTD/MAPS] Blackfin BF5xx Maps: Handle the case where flash memory and ethernet mac/phy are mapped onto the same async bank Bryan Wu
2008-05-12 7:24 ` Bryan Wu
2008-05-12 12:26 ` Jörn Engel [this message]
2008-05-12 12:48 ` Mike Frysinger
2008-05-12 14:37 ` Bryan Wu
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=20080512122650.GA10014@logfs.org \
--to=joern@logfs.org \
--cc=bryan.wu@analog.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=vapier.adi@gmail.com \
--cc=will.newton@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox