[PATCH RFC] bcm47xxsflash: just use memcpy for reading

Rafał Miłecki zajec5 at gmail.com
Wed Sep 19 10:07:47 EDT 2012


2012/9/19 Marc Kleine-Budde <mkl at pengutronix.de>:
> 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.

Sure, I can replace that with _fromio, which AFAIK is the same for mips.

I'm afraid access to the serial flash can't be really optimal. Saving
is actually even worse, it requires some operations on BCMA core,
polling for ready, etc.

-- 
Rafał



More information about the linux-mtd mailing list