From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756307AbbKEDzX (ORCPT ); Wed, 4 Nov 2015 22:55:23 -0500 Received: from mail-bn1on0138.outbound.protection.outlook.com ([157.56.110.138]:12848 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755188AbbKEDzW (ORCPT ); Wed, 4 Nov 2015 22:55:22 -0500 From: Hou Zhiqiang To: Michal Suchanek , Andrew Murray CC: Huang Shijie , David Woodhouse , Brian Norris , Xu Han , Rafa? Mi?ecki , Huang Shijie , Ben Hutchings , Marek Vasut , Gabor Juhos , =?utf-8?B?QmVhbiBIdW8g6ZyN5paM5paMLA==?= , "MTD Maling List" , LKML Subject: RE: [PATCH v4 7/7] mtd: spi-nor: add read loop Thread-Topic: [PATCH v4 7/7] mtd: spi-nor: add read loop Thread-Index: AQHQ1nLdr2NUoKiTE0+wZTfSphlfX54LQ6iAgAABpQCAggRd0A== Date: Thu, 5 Nov 2015 03:39:18 +0000 Message-ID: References: <1592668a061137b33c9a6392dfccc67c69fc1fe6.1439543572.git.hramrach@gmail.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=B48286@freescale.com; x-originating-ip: [199.59.226.141] x-microsoft-exchange-diagnostics: 1;BY2PR03MB556;5:m38SDPVS/npGlxwSLPs6BmOjuULggorlKi6/c65UPZYMTj+gWSNBnvEXJANfP6Sjb1h8ywxonZg56jXzY9j59s3OycfrYaYqZa/byW6XdfrezIH9w4/qyXG9Lel+TV5WHKp/YJ3jl+KmFJFp/xYQNA==;24:faPMiZFmkrWBokHRLOVUrYpRCKXOD93pRWB2lqKVxDQgHfrjfjwRDAaotbnTk73bmkyBhW9PBqa0nXSzR83bpl0l2kU1CvuX2NViXikM6e8=;20:QF85Q/1isdXWZcFOz83kyHPPpTuTSTZTDPALZ52+2fUpX7nSEgRQO2l7tPoFNKEZGKXYFFbm9RBtZ9y8OQbQ9Q== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB556; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(10201501046)(3002001);SRVR:BY2PR03MB556;BCL:0;PCL:0;RULEID:;SRVR:BY2PR03MB556; x-forefront-prvs: 0751474A44 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(13464003)(24454002)(164054003)(199003)(77096005)(106356001)(5007970100001)(189998001)(74316001)(575784001)(2900100001)(87936001)(5002640100001)(86362001)(2950100001)(102836002)(5003600100002)(5004730100002)(76576001)(5008740100001)(93886004)(10400500002)(97736004)(50986999)(76176999)(81156007)(101416001)(99286002)(54356999)(19580405001)(5001960100002)(19580395003)(105586002)(106116001)(5001770100001)(92566002)(66066001)(40100003)(122556002)(33656002);DIR:OUT;SFP:1102;SCL:1;SRVR:BY2PR03MB556;H:CY1PR0301MB0780.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Nov 2015 03:39:18.5619 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR03MB556 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id tA53tcXM018078 Hi Michal, Does this have any updates? Thanks, Zhiqiang > -----Original Message----- > From: Michal Suchanek [mailto:hramrach@gmail.com] > Sent: 2015年8月14日 18:08 > To: Andrew Murray > Cc: Hou Zhiqiang-B48286; Huang Shijie; David Woodhouse; Brian Norris; Xu > Han-B45815; Rafał Miłecki; Huang Shijie; Ben Hutchings; Marek Vasut; > Gabor Juhos; Bean Huo 霍斌斌,; MTD Maling List; LKML > Subject: Re: [PATCH v4 7/7] mtd: spi-nor: add read loop > > On 14 August 2015 at 12:02, Andrew Murray > wrote: > > On 14 August 2015 at 10:23, Michal Suchanek wrote: > >> mtdblock and ubi do not handle the situation when read returns less > >> data than requested. Loop in spi-nor until buffer is filled or an > >> error is returned. > >> > >> Signed-off-by: Michal Suchanek > >> --- > >> drivers/mtd/spi-nor/spi-nor.c | 20 ++++++++++++++------ > >> 1 file changed, 14 insertions(+), 6 deletions(-) > >> > >> diff --git a/drivers/mtd/spi-nor/spi-nor.c > >> b/drivers/mtd/spi-nor/spi-nor.c index e0ae9cf..246fac7 100644 > >> --- a/drivers/mtd/spi-nor/spi-nor.c > >> +++ b/drivers/mtd/spi-nor/spi-nor.c > >> @@ -738,14 +738,22 @@ static int spi_nor_read(struct mtd_info *mtd, > loff_t from, size_t len, > >> if (ret) > >> return ret; > >> > >> - ret = nor->read(nor, from, len, buf); > >> + while (len) { > >> + ret = nor->read(nor, from, len, buf); > >> + if (ret <= 0) > >> + goto read_err; > >> + > >> + BUG_ON(ret > len); > >> + *retlen += ret; > > > > Is *retlen initialized to 0 anywhere? > > It's initialized in mtdcore and passed into mtd->_read. > > Yes, the interface is really awkward. > > int mtd_read(struct mtd_info *mtd, loff_t from, size_t len, size_t > *retlen, > u_char *buf) > { > int ret_code; > *retlen = 0; > > > Thanks > > Michal {.n++%ݶw{.n+{G{ayʇڙ,jfhz_(階ݢj"mG?&~iOzv^m ?I