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 1dwxNs-0006xj-RH for barebox@lists.infradead.org; Tue, 26 Sep 2017 21:27:20 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Tue, 26 Sep 2017 23:26:44 +0200 Message-Id: <20170926212646.2968-2-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 1/3] gpiolib: reorder functions To: barebox@lists.infradead.org Z3Bpb19yZXF1ZXN0X29uZSgpIGFuZCBncGlvX3JlcXVlc3RfYXJyYXkoKSBtYWtlIHVzZSBvZgpn cGlvX2RpcmVjdGlvbl8qLCBzbyBpdCBpcyBuYXR1cmFsIHRvIGRlZmluZSB0aGUgZm9ybWVyIHRo ZW0gZnVydGhlciBsb3cKaW4gdGhlIGZpbGUuIEl0IGRvZXNuJ3QgbWF0dGVyIGZvciB0aGUgY29t cGlsZXIgaGVyZSBhcyBhbGwgZnVuY3Rpb25zCmFyZSBkZWNsYXJlZCBpbiBhIGhlYWRlciwgYnV0 IHRoZSBuZXh0IGNvbW1pdCBhZGRzIGEgZmV3IG1vcmUgZnVuY3Rpb25zCnRoYXQgbmVlZCB0aGlz IHJlb3JkZXJpbmcgdG8gbm8gbmVlZCBhZGRpdGlvbmFsIGZvcndhcmQgZGVjbGFyYXRpb25zLgoK U2lnbmVkLW9mZi1ieTogVXdlIEtsZWluZS1Lw7ZuaWcgPHUua2xlaW5lLWtvZW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