From patchwork Wed Apr 19 04:11:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cyril Bur X-Patchwork-Id: 752081 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w77tJ2X0Rz9s3w for ; Wed, 19 Apr 2017 14:14:16 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3w77tJ1H9TzDqLK for ; Wed, 19 Apr 2017 14:14:16 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3w77sg6zrDzDqBH for ; Wed, 19 Apr 2017 14:13:43 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3J48cGW118282 for ; Wed, 19 Apr 2017 00:13:42 -0400 Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141]) by mx0b-001b2d01.pphosted.com with ESMTP id 29wqpu2pxq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 19 Apr 2017 00:13:41 -0400 Received: from localhost by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 19 Apr 2017 14:13:39 +1000 Received: from d23relay06.au.ibm.com (202.81.31.225) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 19 Apr 2017 14:13:37 +1000 Received: from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3J4DTpM7340044 for ; Wed, 19 Apr 2017 14:13:37 +1000 Received: from d23av05.au.ibm.com (localhost [127.0.0.1]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id v3J4D5Sk008629 for ; Wed, 19 Apr 2017 14:13:05 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id v3J4D5wN008177; Wed, 19 Apr 2017 14:13:05 +1000 Received: from camb691.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id EBF24A0321; Wed, 19 Apr 2017 14:12:19 +1000 (AEST) From: Cyril Bur To: skiboot@lists.ozlabs.org Date: Wed, 19 Apr 2017 14:11:43 +1000 X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170419041143.12042-1-cyril.bur@au1.ibm.com> References: <20170419041143.12042-1-cyril.bur@au1.ibm.com> X-TM-AS-MML: disable x-cbid: 17041904-0048-0000-0000-0000021E05FC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041904-0049-0000-0000-000047CB3E70 Message-Id: <20170419041143.12042-6-cyril.bur@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-19_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704190039 Subject: [Skiboot] [PATCH v2 5/5] external/pflash: Use blocklevel_smart_erase() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair@popple.id.au, sam@mendozajonas.com MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Signed-off-by: Cyril Bur --- external/pflash/pflash.c | 31 ++++--------------------------- 1 file changed, 4 insertions(+), 27 deletions(-) diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c index 2f9cc71d..a344987e 100644 --- a/external/pflash/pflash.c +++ b/external/pflash/pflash.c @@ -235,7 +235,6 @@ static void erase_chip(void) static void erase_range(uint32_t start, uint32_t size, bool will_program) { - uint32_t done = 0; int rc; printf("About to erase 0x%08x..0x%08x !\n", start, start + size); @@ -247,33 +246,11 @@ static void erase_range(uint32_t start, uint32_t size, bool will_program) } printf("Erasing...\n"); - progress_init(size >> 8); - while(size) { - /* If aligned to 64k and at least 64k, use 64k erase */ - if ((start & 0xffff) == 0 && size >= 0x10000) { - rc = blocklevel_erase(bl, start, 0x10000); - if (rc) { - fprintf(stderr, "Error %d erasing 0x%08x\n", - rc, start); - exit(1); - } - start += 0x10000; - size -= 0x10000; - done += 0x10000; - } else { - rc = blocklevel_erase(bl, start, 0x1000); - if (rc) { - fprintf(stderr, "Error %d erasing 0x%08x\n", - rc, start); - exit(1); - } - start += 0x1000; - size -= 0x1000; - done += 0x1000; - } - progress_tick(done >> 8); + rc = blocklevel_smart_erase(bl, start, size); + if (rc) { + fprintf(stderr, "Failed to blocklevel_smart_erase(): %d\n", rc); + return; } - progress_end(); /* If this is a flash partition, mark it empty if we aren't * going to program over it as well