From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dwxNo-0006s5-3U for barebox@lists.infradead.org; Tue, 26 Sep 2017 21:27:13 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Tue, 26 Sep 2017 23:26:46 +0200 Message-Id: <20170926212646.2968-4-u.kleine-koenig@pengutronix.de> In-Reply-To: <20170926212646.2968-1-u.kleine-koenig@pengutronix.de> References: <20170926212646.2968-1-u.kleine-koenig@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 3/3] gpiolib: introduce gpio initializer To: barebox@lists.infradead.org VG8gZGVmaW5lIHRoZSBpbml0aWFsIHN0YXRlIG9mIGEgZ2l2ZW4gZ3BpbyB5b3UgY2FuIGFkZCBh IGdwaW8taW5pdCBub2RlCnRvIGEgZ3BpbyBjb250cm9sbGVyLiBUaGlzIGRvZXNuJ3QgcHJldmVu dCBhIGxhdGVyIGNvbnN1bWVyIHRvIHJlcXVlc3QKdGhhdCBwaW4gYW5kIG9ubHkgZGVmaW5lcyBh IHNhdmUgaW5pdGlhbCBzdGF0ZS4KClNpZ25lZC1vZmYtYnk6IFV3ZSBLbGVpbmUtS8O2bmlnIDx1 LmtsZWluZS1rb2VuaWdAcGVuZ3V0cm9uaXguZGU+Ci0tLQogZHJpdmVycy9ncGlvL2dwaW9saWIu YyB8IDQzICsrKysrKysrKysrKysrKysrKysrKysrKysrKysrKy0tLS0tLS0tLS0tLS0KIDEgZmls ZSBjaGFuZ2VkLCAzMCBpbnNlcnRpb25zKCspLCAxMyBkZWxldGlvbnMoLSkKCmRpZm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