lkml.org 
[lkml]   [2016]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v8] mtd: spi-nor: add hisilicon spi-nor flash controller driver
From
Date
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@huawei.com>
>> Signed-off-by: Jiancheng Xue <xuejiancheng@huawei.com>
>> Acked-by: Rob Herring <robh@kernel.org>
>> Reviewed-by: Ezequiel Garcia <ezequiel@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
>
> .
>

\
 
 \ /
  Last update: 2016-03-18 08:21    [W:1.003 / U:1.952 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site