From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from zimbra2.kalray.eu ([92.103.151.219]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1irNXq-0007bl-Ju for barebox@lists.infradead.org; Tue, 14 Jan 2020 14:51:54 +0000 From: Clement Leger Date: Tue, 14 Jan 2020 15:51:40 +0100 Message-Id: <20200114145140.15766-1-cleger@kalray.eu> 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] pinctrl-single: Handle "pinctrl-single, function-mask" dt property To: Sascha Hauer , barebox@lists.infradead.org Cc: =?UTF-8?q?Sim=C3=A9on=20Marijon?= , Simeon Marijon RnJvbTogU2ltw6lvbiBNYXJpam9uIDxzaW1lb24ubWFyaWpvbkBrYWxyYXkuZXU+CgpJbXBsZW1l bnQgbGludXggYmVoYXZpb3IgcmVnYXJkaW5nICJwaW5jdHJsLXNpbmdsZSxmdW5jdGlvbi1tYXNr IiBhbmQKInBpbmN0cmwtc2luZ2xlLGJpdHMiLgpJdCBhbGxvd3MgbXVsdGlwbGUgcGlucyBjb250 cm9sIHBlciByZWdpc3Rlci4KCihsaW51eCBzaGExOiA0ZTdlODAxN2E4MGUxODEwMTAwYzliNDE2 Yjg2ZTNiYWVmOTAwMjg1KQoKU2lnbmVkLW9mZi1ieTogU2ltZW9uIE1hcmlqb24gPHNpbWVvbkBt YXJpam9uLmZyPgotLS0KIGRyaXZlcnMvcGluY3RybC9waW5jdHJsLXNpbmdsZS5jIHwgODEgKysr KysrKysrKysrKysrKysrKysrKysrKysrKysrLS0tLS0tLS0tLQogMSBmaWxlIGNoYW5nZWQsIDYy IGluc2VydGlvbnMoKyksIDE5IGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL2RyaXZlcnMvc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