From patchwork Tue Nov 14 09:54:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: BRUN Xavier X-Patchwork-Id: 837767 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:400c:c0c::23f; helo=mail-wr0-x23f.google.com; envelope-from=swupdate+bncbaabb4p2vliakgqexz4f57q@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="Yh5zgve8"; dkim-atps=neutral Received: from mail-wr0-x23f.google.com (mail-wr0-x23f.google.com [IPv6:2a00:1450:400c:c0c::23f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ybjY167b8z9s81 for ; Tue, 14 Nov 2017 20:55:00 +1100 (AEDT) Received: by mail-wr0-x23f.google.com with SMTP id u97sf10827819wrc.3 for ; Tue, 14 Nov 2017 01:55:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1510653298; cv=pass; d=google.com; s=arc-20160816; b=G06myHhfiFgrGBqxW0tI4HXnFWLx+mKt5bDJfTHvvKTTuaWC57zKuXwPcxw7tcDVY5 EOc6SZxjI7SbyNvVhbazEEyX/1BQazCw2mMfs6+b41vgJLApTp/Igt8VomxNPStOINlL Otg1Bm/t+1ImUy3lFCI9faQ/4Lc2/MwD3tfIEaVMgm3WXhR7oDllJhr5VtZIc2vaiB+V l0OYgT+hIvg6mVS0niiA7HlWc24pQZv3wXF1Qm5Gb8VoXVawcswrkTvLKO3PDDlhbr+1 hzJOZhYl6eB0ODMmQFu/APixf8abJF4RISK9odq/hBPrxPtaHWCtRvKxbl7rcf0ipPa0 H/kg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:to:from:arc-authentication-results :arc-message-signature:sender:dkim-signature :arc-authentication-results; bh=i0lDZUCK8cr5ZV5YaohFNmaJPnFrPYMVsi6Q+LjZP3s=; b=PoCsNrlOGdHbDg0+ahykb7LCUJCePQLQl1q0HfgfLMTueGPpuNNR6/cEmsFO7OG+mM kQlZ3+7NbjoeHWlGGrnIKuh7d+lvI+83+c5NbKHNaFpifPgiBQfmU3L5s3+UzpRMrA9m vY4IW7xnr4j90HZhXpJD1NZdiYNcMmTJk9Wo8qz5HPjQB9Jqa/eE4VE8+1Xn9MQoRQCS 9jz7Yo21MjHoInOlddxldDuQNT1JIJP7tWZjF4FXm1B9bbTNMLV+LpXp7OCWqxGVvJUa zFsJF6TwBCIbGJQiJyhdC2k1WaUJXBUeZhbm5eTu+GaSW2xWXsXxjIDIjI7Hnz9km75/ JK7A== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 213.62.121.101 is neither permitted nor denied by domain of xavier.brun@sercel.com) smtp.mailfrom=Xavier.BRUN@sercel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:subject:thread-topic:thread-index:date:message-id :references:in-reply-to:accept-language:content-language :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=i0lDZUCK8cr5ZV5YaohFNmaJPnFrPYMVsi6Q+LjZP3s=; b=Yh5zgve8eMV6Xi1By97Tw+OYcNrLXj1Jim5v30y9Oc7DcWXDA4sXi1LVFVkSFaOcUf jCm1XKuIX+VRyHCGTQ7SjDdzel3a+5OIFHaHzGzIf8so10nxNtrY9EqV8BEm1pAoMROm FgNkeekxdSuCMpPeKhrDgm49oYOzANoudo0mm89KtaZFe48JrTuiYW79riwB2EnFzD6o M0/+UdQuj8XDWUECbs9pBx8oGNUzSJc6HqCfaKfRZ02aVTalT9PTahpslzQbVZAa1qPh dLy7Fr6+FZsVIEiPmzZ7DaGfR0tQ78eDkU/4R0jy3agHYucCd4Psga7mRjKCI02m77f5 +tbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:subject:thread-topic:thread-index :date:message-id:references:in-reply-to:accept-language :content-language:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=i0lDZUCK8cr5ZV5YaohFNmaJPnFrPYMVsi6Q+LjZP3s=; b=Oj29uq0os3hIZkjbFS4eARIrRF5Xsmwc069DeMiCxTe7HM5ZlmLCVLy5lHK2VaSTwz cTTjBgxYTFLQsBDsRGYlQRIed22KTfMDAxta52s8m4yBt/vXhdCRPB/9wJ6XMiPaq8Zb e5FdEs58UFpbksgFrP7ncl0GtNibnU177JpwA/B+vEledv35wD4maiGOwGSsy/D/1Bfy rvbXFP2KPpb9ic7FeM2SusZwcOkXfAZBUOCLVS2u2/9GhfQaRqsS/nxFf07E5KnVBEPP W94A66aADeb5WiFLmTv65EDBfQRLGE8lSzMMcTYHNM4OvcNHtge1DA0TrQ2gEmQcFhKS 1N3w== Sender: swupdate@googlegroups.com X-Gm-Message-State: AJaThX7MWizTSs/UWxw/Ls1Q+hrTkWKdDZp6sGf1pHWSWd+FhU3U3t2f 26R38z4SP36omsfHK2vWDxM= X-Google-Smtp-Source: AGs4zMYrK3oQ8sU/q7zc2w+pm6IsEBu12iv1biQvXvm9UeShQSQP1a/8vhD1injxgY2r3jvO2I9lDA== X-Received: by 10.28.140.78 with SMTP id o75mr136531wmd.4.1510653298020; Tue, 14 Nov 2017 01:54:58 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 10.28.197.15 with SMTP id v15ls1342456wmf.2.canary-gmail; Tue, 14 Nov 2017 01:54:57 -0800 (PST) X-Received: by 10.28.122.16 with SMTP id v16mr1402925wmc.30.1510653297493; Tue, 14 Nov 2017 01:54:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510653297; cv=none; d=google.com; s=arc-20160816; b=DYpLhxLdHtZ0BRQ6XShvqlFqbC5HTwoQkOF36Z/cidGGOs9X42iEe/fbDRC/tHcZ21 Kia6WbOKNpXC/crZZ8BCjV+3qosuACjFhXpT2NuytQTs4hsiy3UaXUkz6Zv+dbrA71ET yUBwDL84Zp+gMFo57zw8o21hfxDkZ0FXRWYq2fbMj5OdPptHjhvqysZQYTNIUUJm2whS r/zZ4TL1oXPizvWFuT1snLWB6l3DzgBekU+2R292UZna+7NYz6buq+mLDTsysNXGatPE kkvmDgZ+aOO9b3hihOzlPEiDUtTAu61+1vewK7aVmlLP1x49B66FxVWiJEJML0bZdyjM gc3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:to:from:arc-authentication-results; bh=aFICLvmOeWdet24kVsreCo+zzkGdOkG9yT2YCZCHxV8=; b=BQWKloE0aoxLj0vus52g6Vpxe5fCkpWOooHxmZ9jC6TbLXEzhI83fR3PaUsXCyMDCp XSEZJWxV5ZYKVnL/R+3IaqtwMJG530kb4pdkDUunAeZODCK2wYi4JktI1n6zFAXE/Lg8 cxPFtcQBQZRaXhzRQLQnIuEugZUXIFZbmXzMYRqpsSnF/gozabI7MqQNY+c2YiArbQ6G UBLYMrHLHVUmWqyV1/gXEdmPkmhe2cCWBLowRjANAEhdSzqgfGILpe3nScoDXD5iHTCj gUE/tgNSFSgPM6nXdebXSGCf7zfmmtpC4fbDn1JZ+WLr/xzekDir21e85GYobZE92d3e UxzQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 213.62.121.101 is neither permitted nor denied by domain of xavier.brun@sercel.com) smtp.mailfrom=Xavier.BRUN@sercel.com Received: from emeasmtp02.sercel.com (emeasmtp02.sercel.com. [213.62.121.101]) by gmr-mx.google.com with ESMTPS id r6si471423wrg.2.2017.11.14.01.54.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Nov 2017 01:54:57 -0800 (PST) Received-SPF: neutral (google.com: 213.62.121.101 is neither permitted nor denied by domain of xavier.brun@sercel.com) client-ip=213.62.121.101; Received: from NANS01204.it.intra.sercel.com (10.80.51.94) by NANS01204.it.intra.sercel.com (10.80.51.94) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Tue, 14 Nov 2017 10:54:54 +0100 Received: from NANS01204.it.intra.sercel.com ([fe80::19fa:d13a:55fd:9c0e]) by NANS01204.it.intra.sercel.com ([fe80::19fa:d13a:55fd:9c0e%16]) with mapi id 15.00.1178.000; Tue, 14 Nov 2017 10:54:54 +0100 From: BRUN Xavier To: "swupdate@googlegroups.com" Subject: [swupdate] [PATCH] Unlock flash memory before checking if it is empty Thread-Topic: [PATCH] Unlock flash memory before checking if it is empty Thread-Index: AQHTXS2GbDE0A2TWpEK3GvsIdkoTqaMTolcA Date: Tue, 14 Nov 2017 09:54:54 +0000 Message-ID: <72cec4d48b43445d9cf038d6ef688830@NANS01204.it.intra.sercel.com> References: <20171114094628.12802-1-xavier.brun@sercel.com> In-Reply-To: <20171114094628.12802-1-xavier.brun@sercel.com> Accept-Language: fr-FR, en-US Content-Language: fr-FR X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [172.30.31.125] MIME-Version: 1.0 X-Original-Sender: xavier.brun@sercel.com X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 213.62.121.101 is neither permitted nor denied by domain of xavier.brun@sercel.com) smtp.mailfrom=Xavier.BRUN@sercel.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Xavier Brun --- corelib/mtd-interface.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -- 2.11.0 This e-mail and any accompanying attachments are confidential. If you are not the intended recipient, you must not review, disclose, copy, distribute or use this e-mail; please delete it from your system and notify the sender immediately. diff --git a/corelib/mtd-interface.c b/corelib/mtd-interface.c index 1f8d328..ee7d62a 100644 --- a/corelib/mtd-interface.c +++ b/corelib/mtd-interface.c @@ -47,7 +47,6 @@ int flash_erase(int mtdnum) char mtd_device[80]; struct mtd_dev_info *mtd; int noskipbad = 0; -int unlock = 0; int ret = 0; unsigned int eb, eb_start, eb_cnt, i; uint8_t *buf; @@ -96,6 +95,14 @@ int flash_erase(int mtdnum) } } +/* Unlock memory if required */ +if (mtd_is_locked(mtd, fd, eb)) { +if (mtd_unlock(mtd, fd, eb) != 0) { +TRACE("%s: MTD unlock failure", mtd_device); +continue; +} +} + /* * In case of NOR flash, check if the flash * is already empty. This can save @@ -123,13 +130,6 @@ int flash_erase(int mtdnum) } /* The sector contains data and it must be erased */ -if (unlock) { -if (mtd_unlock(mtd, fd, eb) != 0) { -TRACE("%s: MTD unlock failure", mtd_device); -continue; -} -} - if (mtd_erase(flash->libmtd, mtd, fd, eb) != 0) { ERROR("%s: MTD Erase failure", mtd_device); ret = -EIO;