From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from mail-pd0-x22f.google.com ([2607:f8b0:400e:c02::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y6KvM-0001xX-OM for barebox@lists.infradead.org; Wed, 31 Dec 2014 15:11:01 +0000 Received: by mail-pd0-f175.google.com with SMTP id g10so20953022pdj.6 for ; Wed, 31 Dec 2014 07:10:39 -0800 (PST) From: Andrey Smirnov Date: Wed, 31 Dec 2014 07:10:31 -0800 Message-Id: <1420038631-8795-1-git-send-email-andrew.smirnov@gmail.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] firmware: altera: Make nSTAT GPIO optional To: barebox@lists.infradead.org Cc: Andrey Smirnov , kernel@pengutronix.de QnkgdGFraW5nIHBhcnRzIG9mIHRoZSBwcm9ncmFtbWluZyBoYW5kc2hha2luZyBwcm90b2NvbCBv biBmYWl0aCBpdCBpcwpwb3NzaWJsZSB0byBtYWtlIGR1ZSB3aXRoIG9ubHkgdHdvIEdQSU8gZm9y IHByb2dyYW1taW5nIEFsdGVyYQpGUEdBcy4gVGhpcyBpcyBub3QgYSB2ZXJ5IGFkdmlzYWJsZSBw cmFjdGljZSwgYnV0IHNvbWV0aW1lIHVuYXZvaWRhYmxlCmluIEdQSU8gY29uc3RyYWluZWQgZGVz aWducy4KClNpZ25lZC1vZmYtYnk6IEFuZHJleSBTbWlybm92IDxhbmRyZXcuc21pcm5vdkBnbWFp bC5jb20+Ci0tLQogZHJpdmVycy9maXJtd2FyZS9hbHRlcmFfc2VyaWFsLmMgfCA1OSArKysrKysr KysrKysrKysrKysrKysrKysrKysrKystLS0tLS0tLS0tCiAxIGZpbGUgY2hhbmdlZCwgNDQgaW5z ZXJ0aW9ucyg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