[PATCH v8] mtd: spi-nor: add hisilicon spi-nor flash controller driver

Jiancheng Xue xuejiancheng at huawei.com
Thu Mar 17 23:37:44 PDT 2016


Hi Jagan,
	Thank you for comments. I'll modify in next version.

Regards,
Jiancheng

On 2016/3/11 16:04, Jagan Teki wrote:
> 
> 
> On Friday 11 March 2016 01:11 PM, Jiancheng Xue wrote:
>> Add hisilicon spi-nor flash controller driver
>>
>> Signed-off-by: Binquan Peng <pengbinquan at huawei.com>
>> Signed-off-by: Jiancheng Xue <xuejiancheng at huawei.com>
>> Acked-by: Rob Herring <robh at kernel.org>
>> Reviewed-by: Ezequiel Garcia <ezequiel at vanguardiasur.com.ar>
>> ---
[...]
>> +static void hisi_spi_nor_write(struct spi_nor *nor, loff_t to,
>> +            size_t len, size_t *retlen, const u_char *write_buf)
>> +{
>> +    struct hifmc_priv *priv = nor->priv;
>> +    struct hifmc_host *host = priv->host;
>> +    const unsigned char *ptr = write_buf;
>> +    size_t num;
>> +
>> +    while (len > 0) {
>> +        if (to & HIFMC_DMA_MASK)
>> +            num = (HIFMC_DMA_MAX_LEN - (to & HIFMC_DMA_MASK))
>> +                >= len    ? len
>> +                : (HIFMC_DMA_MAX_LEN - (to & HIFMC_DMA_MASK));
>> +        else
>> +            num = (len >= HIFMC_DMA_MAX_LEN)
>> +                ? HIFMC_DMA_MAX_LEN : len;
> 
> Since num is the actual length bytes to read Better to rename num to actual_len for proper meaning here.
> 
>> +        memcpy(host->buffer, ptr, num);
>> +        hisi_spi_nor_dma_transfer(nor, to, host->dma_buffer, num,
>> +                FMC_OP_WRITE);
>> +        to += num;
>> +        ptr += num;
>> +        len -= num;
>> +    }
>> +    *retlen += (size_t)(ptr - write_buf);
> 
> Please avoid this type casting and do *retlen += num inside while.
> 
> -- 
> Jagan
> 
> .
> 




More information about the linux-mtd mailing list