[PATCH 4/4] mtd: spi-nor: aspeed: use command mode for reads

Richard Weinberger richard at nod.at
Thu Apr 20 06:33:42 PDT 2017


Am 20.04.2017 um 15:31 schrieb Marek Vasut:
> On 04/20/2017 01:56 PM, Cédric Le Goater wrote:
>> When reading flash contents, try to use the "command mode" if the AHB
>> window configured for the flash module is big enough. Else, just fall
>> back to the "user mode" to perform the read.
>>
>> Signed-off-by: Cédric Le Goater <clg at kaod.org>
>> ---
>>
>>  Changes since initial version :
>>
>>  - rebased on current patchset which removed DMA support
>>
>>  drivers/mtd/spi-nor/aspeed-smc.c | 27 ++++++++++++++++++++++++++-
>>  1 file changed, 26 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mtd/spi-nor/aspeed-smc.c b/drivers/mtd/spi-nor/aspeed-smc.c
>> index 60c020482946..43015aec4557 100644
>> --- a/drivers/mtd/spi-nor/aspeed-smc.c
>> +++ b/drivers/mtd/spi-nor/aspeed-smc.c
>> @@ -394,6 +394,31 @@ static ssize_t aspeed_smc_read_user(struct spi_nor *nor, loff_t from,
>>  
>>  	aspeed_smc_read_from_ahb(read_buf, chip->ahb_base, len);
>>  	aspeed_smc_stop_user(nor);
>> +	return 0;
>> +}
>> +
>> +static ssize_t aspeed_smc_read(struct spi_nor *nor, loff_t from, size_t len,
>> +			       u_char *read_buf)
>> +{
>> +	struct aspeed_smc_chip *chip = nor->priv;
>> +
>> +	/*
>> +	 * The AHB window configured for the chip is too small for the
>> +	 * read offset. Use the "User mode" of the controller to
>> +	 * perform the read.
>> +	 */
>> +	if (from >= chip->ahb_window_size) {
>> +		aspeed_smc_read_user(nor, from, len, read_buf);
>> +		goto out;
> 
> What about turning this into dumb if () {} else {} and dropping the goto ?

This is a matter of taste...

Thanks,
//richard



More information about the linux-mtd mailing list