All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: Jonas Gorski <jonas.gorski@gmail.com>,
	linux-mtd@lists.infradead.org,
	Artem Bityutskiy <dedekind1@gmail.com>
Subject: Re: [PATCH RFC] bcm47xxsflash: just use memcpy for reading
Date: Wed, 19 Sep 2012 15:45:27 +0200	[thread overview]
Message-ID: <5059CC77.5060505@pengutronix.de> (raw)
In-Reply-To: <1348056494-30019-1-git-send-email-zajec5@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2036 bytes --]

On 09/19/2012 02:08 PM, Rafał Miłecki wrote:
> ---
> Still have to check it with aiaiai
> ---
>  drivers/mtd/devices/bcm47xxsflash.c |   31 ++-----------------------------
>  1 files changed, 2 insertions(+), 29 deletions(-)
> 
> diff --git a/drivers/mtd/devices/bcm47xxsflash.c b/drivers/mtd/devices/bcm47xxsflash.c
> index a328872..2f8dfd4 100644
> --- a/drivers/mtd/devices/bcm47xxsflash.c
> +++ b/drivers/mtd/devices/bcm47xxsflash.c
> @@ -14,41 +14,14 @@ static int bcm47xxsflash_read(struct mtd_info *mtd, loff_t from, size_t len,
>  			      size_t *retlen, u_char *buf)
>  {
>  	struct bcma_sflash *sflash = mtd->priv;
> -	size_t bytes_read = 0;
> -	__iomem u8 *src = (__iomem u8 *)KSEG0ADDR(sflash->window + from);
> -	int i;
> -	size_t unaligned_before, unaligned_after;
>  
>  	/* Check address range */
>  	if ((from + len) > mtd->size)
>  		return -EINVAL;
>  
> -	unaligned_before = from & 0x3;
> -	unaligned_after = (from + len) & 0x3;
> +	memcpy(buf, (void *)KSEG0ADDR(sflash->window + from), len);

You should not access iomem with memcpy, there is a memcpy_fromio(), but
it's an unoptimized readb loop on arm.

Marc
>  
> -	for (i = 0; i < unaligned_before; i++) {
> -		*buf = readb(src);
> -		buf++;
> -		src++;
> -		bytes_read++;
> -	}
> -	for (i = from - unaligned_before; i < from + len - unaligned_after;
> -	     i += 4) {
> -		*(u32 *)buf = readl(src);
> -		buf += 4;
> -		src += 4;
> -		bytes_read += 4;
> -	}
> -	for (i = 0; i < unaligned_after; i++) {
> -		*buf = readb(src);
> -		buf++;
> -		src++;
> -		bytes_read++;
> -	}
> -
> -	*retlen = bytes_read;
> -
> -	return 0;
> +	return len;
>  }
>  
>  static void bcm47xxsflash_fill_mtd(struct bcma_sflash *sflash,
> 


-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]

  reply	other threads:[~2012-09-19 13:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-19 12:08 [PATCH RFC] bcm47xxsflash: just use memcpy for reading Rafał Miłecki
2012-09-19 13:45 ` Marc Kleine-Budde [this message]
2012-09-19 14:07   ` Rafał Miłecki

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=5059CC77.5060505@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=dedekind1@gmail.com \
    --cc=jonas.gorski@gmail.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=zajec5@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 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.