From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Teresa Gámez" <t.gamez@phytec.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 08/12] cfi flash: fix flash_make_cmd for big endian access
Date: Fri, 23 Sep 2011 11:26:06 +0200 [thread overview]
Message-ID: <20110923092606.GK31404@pengutronix.de> (raw)
In-Reply-To: <1316769860-24549-9-git-send-email-s.hauer@pengutronix.de>
Hi Teresa,
On Fri, Sep 23, 2011 at 11:24:16AM +0200, Sascha Hauer wrote:
> This is broken on big endian systems since:
>
> 943b271 cfi_flash: support of u32 cmd
>
> I looked over it and I *think* that the function was correct
> for both big and little endian systems before this patch.
> To support u32 cmd we only have to change the data type of
> the command from u8 to u32.
Can you please test if this patch works on your u8-is-not-enough
flash?
Sascha
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> Cc: Teresa Gámez <t.gamez@phytec.de>
> ---
> drivers/nor/cfi_flash.c | 24 +++++-------------------
> 1 files changed, 5 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c
> index f9b96c5..654e647 100644
> --- a/drivers/nor/cfi_flash.c
> +++ b/drivers/nor/cfi_flash.c
> @@ -822,26 +822,12 @@ int flash_generic_status_check (struct flash_info *info, flash_sect_t sector,
> */
> void flash_make_cmd(struct flash_info *info, u32 cmd, cfiword_t *cmdbuf)
> {
> - int i;
> - int cp_offset;
> - int cword_offset;
> - uchar val;
> - uchar *cp;
> -
> - *cmdbuf = 0;
> - cp = (uchar *)cmdbuf;
> + cfiword_t result = 0;
> + int i = info->portwidth / info->chipwidth;
>
> - for (i = info->portwidth; i > 0; i--) {
> - cword_offset = (info->portwidth-i) % info->chipwidth;
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> - cp_offset = info->portwidth - i;
> - val = *((uchar *)&cmd + cword_offset);
> -#else
> - cp_offset = i - 1;
> - val = *((uchar *)&cmd + sizeof(u32) - cword_offset - 1);
> -#endif
> - cp[cp_offset] = (cword_offset >= sizeof(u32)) ? 0x00 : val;
> - }
> + while (i--)
> + result = (result << (8 * info->chipwidth)) | cmd;
> + *cmdbuf = result;
> }
>
> /*
> --
> 1.7.6.3
>
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-09-23 9:26 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-23 9:24 patches for next Sascha Hauer
2011-09-23 9:24 ` [PATCH 01/12] introduce io.h Sascha Hauer
2011-09-23 9:24 ` [PATCH 02/12] introduce asm-generic/io.h Sascha Hauer
2011-09-23 9:24 ` [PATCH 03/12] arm: use asm-generic/io.h Sascha Hauer
2011-09-23 9:24 ` [PATCH 04/12] Jean-christophe, more careful please Sascha Hauer
2011-09-23 12:43 ` Jean-Christophe PLAGNIOL-VILLARD
2011-09-23 14:29 ` Sascha Hauer
2011-09-23 14:33 ` Sascha Hauer
2011-09-23 9:24 ` [PATCH 05/12] add cpu native ordered io accessors Sascha Hauer
2011-09-23 9:24 ` [PATCH 06/12] cfi flash: use cpu native accessors Sascha Hauer
2011-09-23 9:24 ` [PATCH 07/12] ppc pcm030: remove puts in early init Sascha Hauer
2011-09-23 9:24 ` [PATCH 08/12] cfi flash: fix flash_make_cmd for big endian access Sascha Hauer
2011-09-23 9:26 ` Sascha Hauer [this message]
2011-09-23 14:05 ` Teresa Gamez
2011-09-23 14:27 ` Sascha Hauer
2011-09-23 9:24 ` [PATCH 09/12] rename include/mem_malloc.h to include/memory.h Sascha Hauer
2011-09-23 9:24 ` [PATCH 10/12] ARM mmu: find second level descriptors by walking the page table Sascha Hauer
2011-09-23 9:24 ` [PATCH 11/12] introduce generic memory bank handling Sascha Hauer
2011-09-23 9:24 ` [PATCH 12/12] ARM: switch to generic memory banks Sascha Hauer
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=20110923092606.GK31404@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=t.gamez@phytec.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox