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 1Z6xpw-0001Rr-N4 for barebox@lists.infradead.org; Mon, 22 Jun 2015 09:16:19 +0000 From: Sascha Hauer Date: Mon, 22 Jun 2015 11:15:51 +0200 Message-Id: <1434964552-13915-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 1/2] mtd: Add mtd concat support To: Barebox List VGhlIG10ZCBjb25jYXQgbGF5ZXIgc3VwcG9ydHMgY29uY2F0ZW5hdGluZyBzZXZlcmFsIE1URCBk ZXZpY2VzCmludG8gYSBzaW5nbGUgb25lLiBUaGlzIGlzIG5lYXJseSBhcy1pcyBmcm9tIHRoZSBj b3JyZXNwb25kaW5nCktlcm5lbCBjb2RlLgoKU2lnbmVkLW9mZi1ieTogU2FzY2hhIEhhdWVyIDxz LmhhdWVyQHBlbmd1dHJvbml4LmRlPgotLS0KIGRyaXZlcnMvbXRkL0tjb25maWcgICAgICAgIHwg IDEwICsKIGRyaXZlcnMvbXRkL01ha2VmaWxlICAgICAgIHwgICAxICsKIGRyaXZlcnMvbXRkL210 ZGNvbmNhdC5jICAgIHwgNzY1ICsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrKwogaW5jbHVkZS9saW51eC9tdGQvY29uY2F0LmggfCAgMzQgKysKIDQgZmlsZXMgY2hh bmdlZCwgODEwIGluc2VydGlvbnMoKykKIGNyZWF0ZSBtb2RlIDEwMDY0NCBkcml2ZXJzL210ZC9t dGRjb25jYXQuYwogY3JlYXRlIG1vZGUgMTAwNjQ0IG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