From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from smtp2-g21.free.fr ([2a01:e0c:1:1599::11]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UcWNS-00014K-VV for barebox@lists.infradead.org; Wed, 15 May 2013 07:44:01 +0000 From: =?UTF-8?q?Eric=20B=C3=A9nard?= Date: Wed, 15 May 2013 09:43:29 +0200 Message-Id: <1368603809-5476-1-git-send-email-eric@eukrea.com> 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 v2] nand_base: sync flash detection functions with linux 3.9's code To: barebox@lists.infradead.org dGhpcyBmaXggdGhlIHByb2JsZW1zIGludHJvZHVjZWQgd2hlbiBkZXRlY3Rpbmcgbm9uIE9ORkkg Zmxhc2hlcyBpbgpjb21taXQgNGMyYmRjODcyODAxNmIzNDEyNTIzZTMyNjQ2NTE2NTFmZTc1Mjg2 MAoibmFuZF9iYXNlOiBkZXRlY3QgbW9yZSBPTkZJIGZsYXNoIgoKU2lnbmVkLW9mZi1ieTogRXJp YyBCw6luYXJkIDxlcmljQGV1a3JlYS5jb20+Ci0tLQp2MjogY29zbWV0aWMgZml4IChkb24ndCBw cmludCBPTkZJIGZsYXNoIGRldGVjdGVkIGlmIHRoZSBmbGFzaCBhbnN3ZXJzIE9ORkkgYnV0CmRv ZXNuJ3QgaGF2ZSBhIHJlYWwgT05GSSBoZWFkZXIgKGxpa2Ugc29tZSBIeW5peCBmbGFzaGVzKQoK IGRyaXZlcnMvbXRkL25hbmQvbmFuZF9iYXNlLmMgfCAzODYgKysrKysrKysrKysrKysrKysrKysr KysrKysrKystLS0tLS0tLS0tLS0tLQogaW5jbHVkZS9saW51eC9tdGQvYmJtLmggICAgICB8ICAg MiArCiAyIGZpbGVzIGNoYW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