From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XS66u-0003XZ-NU for barebox@lists.infradead.org; Thu, 11 Sep 2014 15:16:40 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1XS66Y-00065t-HW for barebox@lists.infradead.org; Thu, 11 Sep 2014 17:16:14 +0200 Received: from sha by dude.hi.pengutronix.de with local (Exim 4.84) (envelope-from ) id 1XS66Y-0001Lg-G1 for barebox@lists.infradead.org; Thu, 11 Sep 2014 17:16:14 +0200 From: Sascha Hauer Date: Thu, 11 Sep 2014 17:16:02 +0200 Message-Id: <1410448570-2054-3-git-send-email-s.hauer@pengutronix.de> In-Reply-To: <1410448570-2054-1-git-send-email-s.hauer@pengutronix.de> References: <1410448570-2054-1-git-send-email-s.hauer@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH 02/10] UBI: avoid program operation on NOR flash after erasure interrupted To: barebox@lists.infradead.org RnJvbTogUWkgV2FuZyDnjovotbcgKHFpd2FuZykgPHFpd2FuZ0BtaWNyb24uY29tPgoKbm9yX2Vy YXNlX3ByZXBhcmUoKSB3aWxsIGJlIGNhbGxlZCBiZWZvcmUgZXJhc2UgYSBOT1IgZmxhc2gsIGl0 IHdpbGwgcHJvZ3JhbSAnMCcKaW50byBhIGJsb2NrIHRvIG1hcmsgdGhpcyBibG9jay4gQnV0IHBy b2dyYW0gZGF0YSBpbnRvIGEgZXJhc3VyZSBpbnRlcnJ1cHRlZCBibG9jawpjYW4gY2F1c2UgcHJv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