Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752740AbcCRGkz (ORCPT ); Fri, 18 Mar 2016 02:40:55 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:18643 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750903AbcCRGkx (ORCPT ); Fri, 18 Mar 2016 02:40:53 -0400 Subject: Re: [PATCH v8] mtd: spi-nor: add hisilicon spi-nor flash controller driver To: Jagan Teki , , , , , , , , , , , , , , , , , References: <1457682114-1667-1-git-send-email-xuejiancheng@huawei.com> <56E27C29.2040904@openedev.com> CC: , , , , , , , , , , , Binquan Peng From: Jiancheng Xue Message-ID: <56EBA238.9050902@huawei.com> Date: Fri, 18 Mar 2016 14:37:44 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <56E27C29.2040904@openedev.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.217.211] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020203.56EBA24C.0108,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 85d7f03b13db9516853634f5beea3d0b Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1609 Lines: 53 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 >> Signed-off-by: Jiancheng Xue >> Acked-by: Rob Herring >> Reviewed-by: Ezequiel Garcia >> --- [...] >> +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 > > . >