Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2010982imm; Tue, 10 Jul 2018 11:33:15 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcFJRCqmiVinNDv07I0ABv/lNVP3jCo+ZYo038BE0g+AFxUXLJeYSlzEh6aB5NxHKil7KOS X-Received: by 2002:a63:a919:: with SMTP id u25-v6mr24289445pge.211.1531247595599; Tue, 10 Jul 2018 11:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531247595; cv=none; d=google.com; s=arc-20160816; b=pc4X6LW69rlIs3uViwgUkJlCcRhWK3hhQTI4f6Gyv71Q8LctjDCtHzs3/OOOR8Njp6 OkjWDELZaH+KvRiFjuyVrRyfEc5n4Isp/nePo0tbNgvqNrJd9xpPe7X/HGXUtoen1/DM ARw0m1wxetoR39bTlYVIq+UXpLS4qPhwXHpVVr9zdBhtWVjJDdLBXpR2qrkLjOpzKbhu AAponFhTRalXh2Dz8SNent4Mi4lhuGyg2lU7tVmsu/MaSy11Sr48lRjFs7sa+XbhSX2w UrJzC5FWbL/tWCEbQysM5Jx7sna/Nn8ETYBOSdjhD80cu9B9FsEyEd4XXbUpcn+oq6Ac jrsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=s9cQ3DFQSftZmH6p81+6TvhUk7iWJW4zZUeodPUU9P0=; b=xj0exi5brQo9oC6h6ig7wEAx0SJHY0bAuxvs71a7djR133GF/E2F6kTAdOgbLObQPH k22Tw0h7wxhiHHfAPWlGtCZtWKhSycuGYtL2GEFMIXlr0BJ+Tsw3je7JtJZuJhoWCGkj IKFiI+tFDGwyZLvuCyEY4qyWDy0f/4nZrjH04bd0WbmFiCWIX5aJXICbi3jORC5O1y5P ln4zmMDEUrTlw0yqWWC8Q8TR5/qIr+HAz32ErjJ/pmmVQHnZgRzFpHq87MoMWOYUYEtx UDvCXtaKY1qwTSNepdfrF0D1Vmrv360OTFcqsoDwrz3dTYkygp91MzodgmcMDewsFvOU BQYg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f200-v6si19052061pfa.164.2018.07.10.11.33.00; Tue, 10 Jul 2018 11:33:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388352AbeGJSbY (ORCPT + 99 others); Tue, 10 Jul 2018 14:31:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45826 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387507AbeGJSbX (ORCPT ); Tue, 10 Jul 2018 14:31:23 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7AFDDEB4; Tue, 10 Jul 2018 18:31:11 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tokunori Ikegami , Joakim Tjernlund , Chris Packham , Brian Norris , David Woodhouse , Boris Brezillon , Marek Vasut , Richard Weinberger , Cyrille Pitchen , linux-mtd@lists.infradead.org, Boris Brezillon Subject: [PATCH 4.9 50/52] mtd: cfi_cmdset_0002: Change erase functions to check chip good only Date: Tue, 10 Jul 2018 20:25:18 +0200 Message-Id: <20180710182454.006808585@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710182449.285532226@linuxfoundation.org> References: <20180710182449.285532226@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tokunori Ikegami commit 79ca484b613041ca223f74b34608bb6f5221724b upstream. Currently the functions use to check both chip ready and good. But the chip ready is not enough to check the operation status. So change this to check the chip good instead of this. About the retry functions to make sure the error handling remain it. Signed-off-by: Tokunori Ikegami Reviewed-by: Joakim Tjernlund Cc: Chris Packham Cc: Brian Norris Cc: David Woodhouse Cc: Boris Brezillon Cc: Marek Vasut Cc: Richard Weinberger Cc: Cyrille Pitchen Cc: linux-mtd@lists.infradead.org Cc: stable@vger.kernel.org Signed-off-by: Boris Brezillon Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/chips/cfi_cmdset_0002.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -2292,12 +2292,13 @@ static int __xipram do_erase_chip(struct chip->erase_suspended = 0; } - if (chip_ready(map, adr)) + if (chip_good(map, adr, map_word_ff(map))) break; if (time_after(jiffies, timeo)) { printk(KERN_WARNING "MTD %s(): software timeout\n", __func__ ); + ret = -EIO; break; } @@ -2305,15 +2306,15 @@ static int __xipram do_erase_chip(struct UDELAY(map, chip, adr, 1000000/HZ); } /* Did we succeed? */ - if (!chip_good(map, adr, map_word_ff(map))) { + if (ret) { /* reset on all failures. */ map_write( map, CMD(0xF0), chip->start ); /* FIXME - should have reset delay before continuing */ - if (++retry_cnt <= MAX_RETRIES) + if (++retry_cnt <= MAX_RETRIES) { + ret = 0; goto retry; - - ret = -EIO; + } } chip->state = FL_READY; @@ -2387,7 +2388,7 @@ static int __xipram do_erase_oneblock(st chip->erase_suspended = 0; } - if (chip_ready(map, adr)) { + if (chip_good(map, adr, map_word_ff(map))) { xip_enable(map, chip, adr); break; } @@ -2396,6 +2397,7 @@ static int __xipram do_erase_oneblock(st xip_enable(map, chip, adr); printk(KERN_WARNING "MTD %s(): software timeout\n", __func__ ); + ret = -EIO; break; } @@ -2403,15 +2405,15 @@ static int __xipram do_erase_oneblock(st UDELAY(map, chip, adr, 1000000/HZ); } /* Did we succeed? */ - if (!chip_good(map, adr, map_word_ff(map))) { + if (ret) { /* reset on all failures. */ map_write( map, CMD(0xF0), chip->start ); /* FIXME - should have reset delay before continuing */ - if (++retry_cnt <= MAX_RETRIES) + if (++retry_cnt <= MAX_RETRIES) { + ret = 0; goto retry; - - ret = -EIO; + } } chip->state = FL_READY;