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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxx>
>> Signed-off-by: Jiancheng Xue <xuejiancheng@xxxxxxxxxx>
>> Acked-by: Rob Herring <robh@xxxxxxxxxx>
>> Reviewed-by: Ezequiel Garcia <ezequiel@xxxxxxxxxxxxxxxxxxxx>
>> ---
[...]
>> +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
> 
> .
> 

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux