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.92.3 #3 (Red Hat Linux)) id 1iw2pI-0004Ta-Lm for barebox@lists.infradead.org; Mon, 27 Jan 2020 11:45:12 +0000 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Mon, 27 Jan 2020 12:44:52 +0100 Message-Id: <20200127114453.366-2-uwe@kleine-koenig.org> In-Reply-To: <20200127114453.366-1-uwe@kleine-koenig.org> References: <20200127114453.366-1-uwe@kleine-koenig.org> 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] gpiolib: reorder functions To: barebox@lists.infradead.org Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= RnJvbTogVXdlIEtsZWluZS1Lw7ZuaWcgPHUua2xlaW5lLWtvZW5pZ0BwZW5ndXRyb25peC5kZT4K CmdwaW9fcmVxdWVzdF9vbmUoKSBhbmQgZ3Bpb19yZXF1ZXN0X2FycmF5KCkgbWFrZSB1c2Ugb2YK Z3Bpb19kaXJlY3Rpb25fKiwgc28gaXQgaXMgbmF0dXJhbCB0byBkZWZpbmUgdGhlIGZvcm1lciB0 aGVtIGZ1cnRoZXIgbG93CmluIHRoZSBmaWxlLiBJdCBkb2Vzbid0IG1hdHRlciBmb3IgdGhlIGNv bXBpbGVyIGhlcmUgYXMgYWxsIGZ1bmN0aW9ucwphcmUgZGVjbGFyZWQgaW4gYSBoZWFkZXIsIGJ1 dCB0aGUgbmV4dCBjb21taXQgYWRkcyBhIGZldyBtb3JlIGZ1bmN0aW9ucwphbmQgaXQgYmVuZWZp dHMgZnJvbSB0aGlzIHJlb3JkZXJpbmcgYnk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