From nobody Thu Feb 12 15:46:04 2026 Received: from fgw21-7.mail.saunalahti.fi (fgw21-7.mail.saunalahti.fi [62.142.5.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBA43176AAE for ; Tue, 11 Jun 2024 09:31:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.82 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718098297; cv=none; b=EkQeokSNZw0nAfulic8+MW10tHxSa+IYGf+toWFAx0u6lHP9tcGNrij+dPKAiu/JAnzL69zv4LPpxq4zAA8OGRU/I445+y2UuU/psVDuDbFMJloptuSvne3era6lXnunGQltdDf3CLHQE0Il5VumdjzhzjaTN0iOzvSm6aH0nME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718098297; c=relaxed/simple; bh=//KiX0A3+2T6SNbx64RCCt5vplrvtiOsRUETqQE7Uw4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f8ZzihNeK6wVHE694wDDPphZCAeOMKw3VLqzJ9NnaTc0Y/pzUHhrRrp6uoEgmHkTbhARIlVg0DvCs5rKlAS2smHgslU80KcWam5a/3uU/erSiIAqxKmiexSBNlyKz4PPaCovwVAsPSBrtFYup0bdz8y5eBEswNgLsd39Z/lUPlM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=fail smtp.mailfrom=gmail.com; arc=none smtp.client-ip=62.142.5.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com Received: from localhost (88-113-25-87.elisa-laajakaista.fi [88.113.25.87]) by fgw20.mail.saunalahti.fi (Halon) with ESMTP id 63bf090d-27d5-11ef-8d69-005056bd6ce9; Tue, 11 Jun 2024 12:31:33 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Jacky Huang , Linus Walleij , Tomer Maimon , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org Cc: Shan-Chun Hung , Avi Fishman , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= , Andy Shevchenko Subject: [PATCH v1 1/4] pinctrl: nuvoton: Convert to use struct pingroup and PINCTRL_PINGROUP() Date: Tue, 11 Jun 2024 12:30:22 +0300 Message-ID: <20240611093127.90210-2-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240611093127.90210-1-andy.shevchenko@gmail.com> References: <20240611093127.90210-1-andy.shevchenko@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andy Shevchenko The pin control header provides struct pingroup and PINCTRL_PINGROUP() macr= o. Utilize them instead of open coded variants in the driver. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 16 ++-------------- drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 16 ++-------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nu= voton/pinctrl-npcm7xx.c index 62a46d824b46..2601aacfb976 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +++ b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c @@ -504,17 +504,6 @@ static const int lkgpo2_pins[] =3D { 9 }; =20 static const int nprd_smi_pins[] =3D { 190 }; =20 -/* - * pin: name, number - * group: name, npins, pins - * function: name, ngroups, groups - */ -struct npcm7xx_group { - const char *name; - const unsigned int *pins; - int npins; -}; - #define NPCM7XX_GRPS \ NPCM7XX_GRP(smb0), \ NPCM7XX_GRP(smb0b), \ @@ -642,9 +631,8 @@ enum { #undef NPCM7XX_GRP }; =20 -static struct npcm7xx_group npcm7xx_groups[] =3D { -#define NPCM7XX_GRP(x) { .name =3D #x, .pins =3D x ## _pins, \ - .npins =3D ARRAY_SIZE(x ## _pins) } +static struct pingroup npcm7xx_groups[] =3D { +#define NPCM7XX_GRP(x) PINCTRL_PINGROUP(#x, x ## _pins, ARRAY_SIZE(x ## _p= ins)) NPCM7XX_GRPS #undef NPCM7XX_GRP }; diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c b/drivers/pinctrl/nu= voton/pinctrl-npcm8xx.c index a377d36b0eb0..9834a13cf5c9 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c +++ b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c @@ -588,17 +588,6 @@ static const int hgpio5_pins[] =3D { 25 }; static const int hgpio6_pins[] =3D { 59 }; static const int hgpio7_pins[] =3D { 60 }; =20 -/* - * pin: name, number - * group: name, npins, pins - * function: name, ngroups, groups - */ -struct npcm8xx_pingroup { - const char *name; - const unsigned int *pins; - int npins; -}; - #define NPCM8XX_GRPS \ NPCM8XX_GRP(gpi36), \ NPCM8XX_GRP(gpi35), \ @@ -832,9 +821,8 @@ enum { #undef NPCM8XX_GRP }; =20 -static struct npcm8xx_pingroup npcm8xx_pingroups[] =3D { -#define NPCM8XX_GRP(x) { .name =3D #x, .pins =3D x ## _pins, \ - .npins =3D ARRAY_SIZE(x ## _pins) } +static struct pingroup npcm8xx_pingroups[] =3D { +#define NPCM8XX_GRP(x) PINCTRL_PINGROUP(#x, x ## _pins, ARRAY_SIZE(x ## _p= ins)) NPCM8XX_GRPS #undef NPCM8XX_GRP }; --=20 2.45.2 From nobody Thu Feb 12 15:46:04 2026 Received: from fgw23-7.mail.saunalahti.fi (fgw23-7.mail.saunalahti.fi [62.142.5.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A4D4176ADA for ; Tue, 11 Jun 2024 09:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.84 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718098298; cv=none; b=ixUuSC4ToCuU7SApkPQsthqgXGVLPUsidVa2nUuV9smZgARSRciAsdoI9akTnnl+rD8qHoXUGZn+CHWa6llUQzAtVKjEo+a/5ZgQUHiAAa5BCCl+uZWigWTkMkUxcgiWzCwH+tRHNcNxwtgia3na3Z4/SuGkCjR5kWQgDDERW3g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718098298; c=relaxed/simple; bh=r7doePq86EZ38NE3zkj+NQ9CQBRt4LK5Y61mChfV55o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dq+T3epWVgMCEgviQPQrRPbH9hL9edob6sXwIEtdzlEXhMWwYs0W2LxFMIdn2YV72mzQTGr2r56ZwlmT1UfCBgVaBTb9I8xYIKxIkMQkPiQonERSVhW0+B7kThPSldXpzuxuWsjB862AysUzwRxnnSlOPHzj6MWQTVWk4QL2Ruc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=fail smtp.mailfrom=gmail.com; arc=none smtp.client-ip=62.142.5.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com Received: from localhost (88-113-25-87.elisa-laajakaista.fi [88.113.25.87]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id 646b635b-27d5-11ef-ab0f-005056bdd08f; Tue, 11 Jun 2024 12:31:34 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Jacky Huang , Linus Walleij , Tomer Maimon , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org Cc: Shan-Chun Hung , Avi Fishman , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= , Andy Shevchenko Subject: [PATCH v1 2/4] pinctrl: nuvoton: Make use of struct pinfunction and PINCTRL_PINFUNCTION() Date: Tue, 11 Jun 2024 12:30:23 +0300 Message-ID: <20240611093127.90210-3-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240611093127.90210-1-andy.shevchenko@gmail.com> References: <20240611093127.90210-1-andy.shevchenko@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andy Shevchenko Since pin control provides a generic data type and a macro for the pin function definition, use them in the driver. Signed-off-by: Andy Shevchenko Reviewed-by: Jonathan Neusch=C3=A4fer --- drivers/pinctrl/nuvoton/pinctrl-ma35.c | 19 ++++++++----------- drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 11 +++-------- drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 11 +++-------- drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 11 +++-------- 4 files changed, 17 insertions(+), 35 deletions(-) diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvot= on/pinctrl-ma35.c index fb933cddde91..62e877b76a25 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c +++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c @@ -98,12 +98,6 @@ static const u32 ds_3300mv_tbl[] =3D { 17100, 25600, 34100, 42800, 48000, 56000, 77000, 82000, }; =20 -struct ma35_pin_func { - const char *name; - const char **groups; - u32 ngroups; -}; - struct ma35_pin_setting { u32 offset; u32 shift; @@ -149,7 +143,7 @@ struct ma35_pinctrl { struct regmap *regmap; struct ma35_pin_group *groups; unsigned int ngroups; - struct ma35_pin_func *functions; + struct pinfunction *functions; unsigned int nfunctions; }; =20 @@ -1041,9 +1035,10 @@ static int ma35_pinctrl_parse_functions(struct devic= e_node *np, struct ma35_pinc u32 index) { struct device_node *child; - struct ma35_pin_func *func; + struct pinfunction *func; struct ma35_pin_group *grp; static u32 grp_index; + const char **groups; u32 ret, i =3D 0; =20 dev_dbg(npctl->dev, "parse function(%d): %s\n", index, np->name); @@ -1055,12 +1050,12 @@ static int ma35_pinctrl_parse_functions(struct devi= ce_node *np, struct ma35_pinc if (func->ngroups <=3D 0) return 0; =20 - func->groups =3D devm_kcalloc(npctl->dev, func->ngroups, sizeof(char *), = GFP_KERNEL); - if (!func->groups) + groups =3D devm_kcalloc(npctl->dev, func->ngroups, sizeof(*groups), GFP_K= ERNEL); + if (!groups) return -ENOMEM; =20 for_each_child_of_node(np, child) { - func->groups[i] =3D child->name; + groups[i] =3D child->name; grp =3D &npctl->groups[grp_index++]; ret =3D ma35_pinctrl_parse_groups(child, grp, npctl, i++); if (ret) { @@ -1068,6 +1063,8 @@ static int ma35_pinctrl_parse_functions(struct device= _node *np, struct ma35_pinc return ret; } } + + func->groups =3D groups; return 0; } =20 diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nu= voton/pinctrl-npcm7xx.c index 2601aacfb976..c6b11a198c76 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +++ b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c @@ -639,13 +639,6 @@ static struct pingroup npcm7xx_groups[] =3D { =20 #define NPCM7XX_SFUNC(a) NPCM7XX_FUNC(a, #a) #define NPCM7XX_FUNC(a, b...) static const char *a ## _grp[] =3D { b } -#define NPCM7XX_MKFUNC(nm) { .name =3D #nm, .ngroups =3D ARRAY_SIZE(nm ## = _grp), \ - .groups =3D nm ## _grp } -struct npcm7xx_func { - const char *name; - const unsigned int ngroups; - const char *const *groups; -}; =20 NPCM7XX_SFUNC(smb0); NPCM7XX_SFUNC(smb0b); @@ -764,7 +757,8 @@ NPCM7XX_SFUNC(lkgpo2); NPCM7XX_SFUNC(nprd_smi); =20 /* Function names */ -static struct npcm7xx_func npcm7xx_funcs[] =3D { +static struct pinfunction npcm7xx_funcs[] =3D { +#define NPCM7XX_MKFUNC(nm) PINCTRL_PINFUNCTION(#nm, nm ## _grp, ARRAY_SIZE= (nm ## _grp)) NPCM7XX_MKFUNC(smb0), NPCM7XX_MKFUNC(smb0b), NPCM7XX_MKFUNC(smb0c), @@ -880,6 +874,7 @@ static struct npcm7xx_func npcm7xx_funcs[] =3D { NPCM7XX_MKFUNC(lkgpo1), NPCM7XX_MKFUNC(lkgpo2), NPCM7XX_MKFUNC(nprd_smi), +#undef NPCM7XX_MKFUNC }; =20 #define NPCM7XX_PINCFG(a, b, c, d, e, f, g, h, i, j, k) \ diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c b/drivers/pinctrl/nu= voton/pinctrl-npcm8xx.c index 9834a13cf5c9..7c37d2cda9f1 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c +++ b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c @@ -829,13 +829,6 @@ static struct pingroup npcm8xx_pingroups[] =3D { =20 #define NPCM8XX_SFUNC(a) NPCM8XX_FUNC(a, #a) #define NPCM8XX_FUNC(a, b...) static const char *a ## _grp[] =3D { b } -#define NPCM8XX_MKFUNC(nm) { .name =3D #nm, .ngroups =3D ARRAY_SIZE(nm ## = _grp), \ - .groups =3D nm ## _grp } -struct npcm8xx_func { - const char *name; - const unsigned int ngroups; - const char *const *groups; -}; =20 NPCM8XX_SFUNC(gpi36); NPCM8XX_SFUNC(gpi35); @@ -1060,7 +1053,8 @@ NPCM8XX_SFUNC(hgpio6); NPCM8XX_SFUNC(hgpio7); =20 /* Function names */ -static struct npcm8xx_func npcm8xx_funcs[] =3D { +static struct pinfunction npcm8xx_funcs[] =3D { +#define NPCM8XX_MKFUNC(nm) PINCTRL_PINFUNCTION(#nm, nm ## _grp, ARRAY_SIZE= (nm ## _grp)) NPCM8XX_MKFUNC(gpi36), NPCM8XX_MKFUNC(gpi35), NPCM8XX_MKFUNC(tp_jtag3), @@ -1282,6 +1276,7 @@ static struct npcm8xx_func npcm8xx_funcs[] =3D { NPCM8XX_MKFUNC(hgpio5), NPCM8XX_MKFUNC(hgpio6), NPCM8XX_MKFUNC(hgpio7), +#undef NPCM8XX_MKFUNC }; =20 #define NPCM8XX_PINCFG(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \ diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nu= voton/pinctrl-wpcm450.c index cdad4ef11a2f..5cf6d555c5a5 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c +++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c @@ -482,13 +482,6 @@ static const struct pingroup wpcm450_groups[] =3D { =20 #define WPCM450_SFUNC(a) WPCM450_FUNC(a, #a) #define WPCM450_FUNC(a, b...) static const char *a ## _grp[] =3D { b } -#define WPCM450_MKFUNC(nm) { .name =3D #nm, .ngroups =3D ARRAY_SIZE(nm ## = _grp), \ - .groups =3D nm ## _grp } -struct wpcm450_func { - const char *name; - const unsigned int ngroups; - const char *const *groups; -}; =20 WPCM450_SFUNC(smb3); WPCM450_SFUNC(smb4); @@ -555,7 +548,8 @@ WPCM450_FUNC(gpio, WPCM450_GRPS); #undef WPCM450_GRP =20 /* Function names */ -static struct wpcm450_func wpcm450_funcs[] =3D { +static struct pinfunction wpcm450_funcs[] =3D { +#define WPCM450_MKFUNC(nm) PINCTRL_PINFUNCTION(#nm, nm ## _grp, ARRAY_SIZE= (nm ## _grp)) WPCM450_MKFUNC(smb3), WPCM450_MKFUNC(smb4), WPCM450_MKFUNC(smb5), @@ -616,6 +610,7 @@ static struct wpcm450_func wpcm450_funcs[] =3D { WPCM450_MKFUNC(hg6), WPCM450_MKFUNC(hg7), WPCM450_MKFUNC(gpio), +#undef WPCM450_MKFUNC }; =20 #define WPCM450_PINCFG(a, b, c, d, e, f, g) \ --=20 2.45.2 From nobody Thu Feb 12 15:46:04 2026 Received: from fgw23-7.mail.saunalahti.fi (fgw23-7.mail.saunalahti.fi [62.142.5.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 15164176FB3 for ; Tue, 11 Jun 2024 09:31:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.84 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718098298; cv=none; b=VtVntZMYne8/IhEvjNO0wnUG6FwT7Zp6aq6hivFX1NXv/0eGOI/lRy7gkEXQ32MXp7GGWSqIp8v7knSsoPUx6mDbyIM1h1fm2TwJPysOA8WCoJwFfUeE8Fm4CkzVtYfDLnFtbZxLsn4I2x06f4yWnu6Thh0u7Ecf7exsB1q5Chk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718098298; c=relaxed/simple; bh=FC2Kl+hbpeiZTZFGRoCBKZ3Bw50AAGllg4iHaBq5Tm4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=s+yAM/u+6Z7QD/qI6m9v+u4vpYgd8Iq+h89V3JIxyu4CnmTjNSDHXGyzk+r/VoLyWQCrMOVUQ12K6cTZFHfat94kUfVj/WF6NFmoDZQdgQuslqO6Wngpt28SKkotJH+sPFa9HV9VKSu3hC90l8VfXefWWM08moamUyT9BuOYpNQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=fail smtp.mailfrom=gmail.com; arc=none smtp.client-ip=62.142.5.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com Received: from localhost (88-113-25-87.elisa-laajakaista.fi [88.113.25.87]) by fgw20.mail.saunalahti.fi (Halon) with ESMTP id 6519693c-27d5-11ef-8d69-005056bd6ce9; Tue, 11 Jun 2024 12:31:34 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Jacky Huang , Linus Walleij , Tomer Maimon , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org Cc: Shan-Chun Hung , Avi Fishman , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= , Andy Shevchenko Subject: [PATCH v1 3/4] pinctrl: nuvoton: Convert to use struct group_desc Date: Tue, 11 Jun 2024 12:30:24 +0300 Message-ID: <20240611093127.90210-4-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240611093127.90210-1-andy.shevchenko@gmail.com> References: <20240611093127.90210-1-andy.shevchenko@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Andy Shevchenko The pin control core header provides struct group_desc. Utilize it instead of open coded variants in the driver. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/nuvoton/pinctrl-ma35.c | 66 ++++++++++++-------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvot= on/pinctrl-ma35.c index 62e877b76a25..7c2b0039d1e4 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c +++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c @@ -106,13 +106,6 @@ struct ma35_pin_setting { unsigned int nconfigs; }; =20 -struct ma35_pin_group { - const char *name; - unsigned int npins; - unsigned int *pins; - struct ma35_pin_setting *settings; -}; - struct ma35_pin_bank { void __iomem *reg_base; struct clk *clk; @@ -141,7 +134,7 @@ struct ma35_pinctrl { struct pinctrl_dev *pctl; const struct ma35_pinctrl_soc_info *info; struct regmap *regmap; - struct ma35_pin_group *groups; + struct group_desc *groups; unsigned int ngroups; struct pinfunction *functions; unsigned int nfunctions; @@ -160,7 +153,7 @@ static const char *ma35_get_group_name(struct pinctrl_d= ev *pctldev, unsigned int { struct ma35_pinctrl *npctl =3D pinctrl_dev_get_drvdata(pctldev); =20 - return npctl->groups[selector].name; + return npctl->groups[selector].grp.name; } =20 static int ma35_get_group_pins(struct pinctrl_dev *pctldev, unsigned int s= elector, @@ -171,19 +164,19 @@ static int ma35_get_group_pins(struct pinctrl_dev *pc= tldev, unsigned int selecto if (selector >=3D npctl->ngroups) return -EINVAL; =20 - *pins =3D npctl->groups[selector].pins; - *npins =3D npctl->groups[selector].npins; + *pins =3D npctl->groups[selector].grp.pins; + *npins =3D npctl->groups[selector].grp.npins; =20 return 0; } =20 -static struct ma35_pin_group *ma35_pinctrl_find_group_by_name( - const struct ma35_pinctrl *npctl, const char *name) +static struct group_desc * +ma35_pinctrl_find_group_by_name(const struct ma35_pinctrl *npctl, const ch= ar *name) { int i; =20 for (i =3D 0; i < npctl->ngroups; i++) { - if (!strcmp(npctl->groups[i].name, name)) + if (!strcmp(npctl->groups[i].grp.name, name)) return &npctl->groups[i]; } return NULL; @@ -195,9 +188,10 @@ static int ma35_pinctrl_dt_node_to_map_func(struct pin= ctrl_dev *pctldev, unsigned int *num_maps) { struct ma35_pinctrl *npctl =3D pinctrl_dev_get_drvdata(pctldev); - struct ma35_pin_group *grp; + struct ma35_pin_setting *setting; struct pinctrl_map *new_map; struct device_node *parent; + struct group_desc *grp; int map_num =3D 1; int i; =20 @@ -211,7 +205,7 @@ static int ma35_pinctrl_dt_node_to_map_func(struct pinc= trl_dev *pctldev, return -EINVAL; } =20 - map_num +=3D grp->npins; + map_num +=3D grp->grp.npins; new_map =3D devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map), GFP_KER= NEL); if (!new_map) return -ENOMEM; @@ -223,6 +217,8 @@ static int ma35_pinctrl_dt_node_to_map_func(struct pinc= trl_dev *pctldev, if (!parent) return -EINVAL; =20 + setting =3D grp->data; + new_map[0].type =3D PIN_MAP_TYPE_MUX_GROUP; new_map[0].data.mux.function =3D parent->name; new_map[0].data.mux.group =3D np->name; @@ -231,9 +227,9 @@ static int ma35_pinctrl_dt_node_to_map_func(struct pinc= trl_dev *pctldev, new_map++; for (i =3D 0; i < grp->npins; i++) { new_map[i].type =3D PIN_MAP_TYPE_CONFIGS_PIN; - new_map[i].data.configs.group_or_pin =3D pin_get_name(pctldev, grp->pins= [i]); - new_map[i].data.configs.configs =3D grp->settings[i].configs; - new_map[i].data.configs.num_configs =3D grp->settings[i].nconfigs; + new_map[i].data.configs.group_or_pin =3D pin_get_name(pctldev, grp->grp.= pins[i]); + new_map[i].data.configs.configs =3D setting[i].configs; + new_map[i].data.configs.num_configs =3D setting[i].nconfigs; } dev_dbg(pctldev->dev, "maps: function %s group %s num %d\n", (*map)->data.mux.function, (*map)->data.mux.group, map_num); @@ -281,12 +277,12 @@ static int ma35_pinmux_set_mux(struct pinctrl_dev *pc= tldev, unsigned int selecto unsigned int group) { struct ma35_pinctrl *npctl =3D pinctrl_dev_get_drvdata(pctldev); - struct ma35_pin_group *grp =3D &npctl->groups[group]; - struct ma35_pin_setting *setting =3D grp->settings; + struct group_desc *grp =3D &npctl->groups[group]; + struct ma35_pin_setting *setting =3D grp->data; u32 i, regval; =20 dev_dbg(npctl->dev, "enable function %s group %s\n", - npctl->functions[selector].name, npctl->groups[group].name); + npctl->functions[selector].name, grp->grp.name); =20 for (i =3D 0; i < grp->npins; i++) { regmap_read(npctl->regmap, setting->offset, ®val); @@ -980,17 +976,16 @@ static const struct pinconf_ops ma35_pinconf_ops =3D { .is_generic =3D true, }; =20 -static int ma35_pinctrl_parse_groups(struct device_node *np, struct ma35_p= in_group *grp, +static int ma35_pinctrl_parse_groups(struct device_node *np, struct group_= desc *grp, struct ma35_pinctrl *npctl, u32 index) { struct ma35_pin_setting *pin; unsigned long *configs; unsigned int nconfigs; + unsigned int *pins; int i, j, count, ret; u32 *elems; =20 - grp->name =3D np->name; - ret =3D pinconf_generic_parse_dt_config(np, NULL, &configs, &nconfigs); if (ret) return ret; @@ -1003,21 +998,22 @@ static int ma35_pinctrl_parse_groups(struct device_n= ode *np, struct ma35_pin_gro if (!elems) return -ENOMEM; =20 + grp->grp.name =3D np->name; + ret =3D of_property_read_u32_array(np, "nuvoton,pins", elems, count); if (ret) return -EINVAL; + grp->grp.npins =3D count / 3; =20 - grp->npins =3D count / 3; - - grp->pins =3D devm_kcalloc(npctl->dev, grp->npins, sizeof(*grp->pins), GF= P_KERNEL); - if (!grp->pins) + pins =3D devm_kcalloc(npctl->dev, grp->grp.npins, sizeof(*pins), GFP_KERN= EL); + if (!pins) return -ENOMEM; + grp->grp.pins =3D pins; =20 - grp->settings =3D devm_kcalloc(npctl->dev, grp->npins, sizeof(*grp->setti= ngs), GFP_KERNEL); - if (!grp->settings) + pin =3D devm_kcalloc(npctl->dev, grp->grp.npins, sizeof(*pin), GFP_KERNEL= ); + if (!pin) return -ENOMEM; - - pin =3D grp->settings; + grp->data =3D pin; =20 for (i =3D 0, j =3D 0; i < count; i +=3D 3, j++) { pin->offset =3D elems[i] * MA35_MFP_REG_SZ_PER_BANK + MA35_MFP_REG_BASE; @@ -1025,7 +1021,7 @@ static int ma35_pinctrl_parse_groups(struct device_no= de *np, struct ma35_pin_gro pin->muxval =3D elems[i + 2]; pin->configs =3D configs; pin->nconfigs =3D nconfigs; - grp->pins[j] =3D npctl->info->get_pin_num(pin->offset, pin->shift); + pins[j] =3D npctl->info->get_pin_num(pin->offset, pin->shift); pin++; } return 0; @@ -1036,7 +1032,7 @@ static int ma35_pinctrl_parse_functions(struct device= _node *np, struct ma35_pinc { struct device_node *child; struct pinfunction *func; - struct ma35_pin_group *grp; + struct group_desc *grp; static u32 grp_index; const char **groups; u32 ret, i =3D 0; --=20 2.45.2 From nobody Thu Feb 12 15:46:04 2026 Received: from fgw21-7.mail.saunalahti.fi (fgw21-7.mail.saunalahti.fi [62.142.5.82]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2746178CE4 for ; Tue, 11 Jun 2024 09:31:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.142.5.82 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718098300; cv=none; b=QxZLFPZ9w0aQi8BhcYVbVcf1bKsPgjpmMTbsxZiPFop54uyxdV4ZWISV8fWPg/lgYGrEduasiQnJInpLJlzw/m6xiEDJsNEqagJ3wHSA6Y5HFcE2oPXgg638G+8267eUfNtQYgfKB2Wr8yBnwjl4JBo/Uc5m+kPvRDso1wFK58U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718098300; c=relaxed/simple; bh=mMVL8afWJZyH/lJQmN80I97zDhgRVPAlN2XpKsFbxs0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JeOfTtycC2m93fZk0ZfM5C45WvWxU82cd33pY4QRl4ZqRori/UMgJyZ680DrUhfou3JrCwD143WrjrqMyI242ofU2ez+RPs6oLR0DZ9ZazjIB7wZbM67rzFEpYZymuV3e+qK8HX96WX+dOlXSxmHc4ghp2170eBkZozo3DFd5Ik= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=fail smtp.mailfrom=gmail.com; arc=none smtp.client-ip=62.142.5.82 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=gmail.com Received: from localhost (88-113-25-87.elisa-laajakaista.fi [88.113.25.87]) by fgw21.mail.saunalahti.fi (Halon) with ESMTP id 657d3fe3-27d5-11ef-ab0f-005056bdd08f; Tue, 11 Jun 2024 12:31:35 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Jacky Huang , Linus Walleij , Tomer Maimon , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org Cc: Shan-Chun Hung , Avi Fishman , Tali Perry , Patrick Venture , Nancy Yuen , Benjamin Fair , =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= Subject: [PATCH v1 4/4] pinctrl: nuvoton: Reduce use of OF-specific APIs Date: Tue, 11 Jun 2024 12:30:25 +0300 Message-ID: <20240611093127.90210-5-andy.shevchenko@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240611093127.90210-1-andy.shevchenko@gmail.com> References: <20240611093127.90210-1-andy.shevchenko@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Some drivers are using device property APIs along with OF-specific ones. At the same time few of the latter can be converted to device property calls. Reduce use of OF-specific APIs in order to bring a bit more consiste= ncy into the drivers. Signed-off-by: Andy Shevchenko --- drivers/pinctrl/nuvoton/pinctrl-ma35.c | 35 +++++++++++------------ drivers/pinctrl/nuvoton/pinctrl-ma35d1.c | 1 - drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 16 ++--------- drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 2 +- 4 files changed, 21 insertions(+), 33 deletions(-) diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35.c b/drivers/pinctrl/nuvot= on/pinctrl-ma35.c index 7c2b0039d1e4..2bb0bdbc881a 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-ma35.c +++ b/drivers/pinctrl/nuvoton/pinctrl-ma35.c @@ -519,7 +519,6 @@ static int ma35_gpiolib_register(struct platform_device= *pdev, struct ma35_pinct bank->irqtype =3D 0; bank->irqinten =3D 0; bank->chip.label =3D bank->name; - bank->chip.of_gpio_n_cells =3D 2; bank->chip.parent =3D &pdev->dev; bank->chip.request =3D ma35_gpio_core_to_request; bank->chip.direction_input =3D ma35_gpio_core_direction_in; @@ -976,9 +975,10 @@ static const struct pinconf_ops ma35_pinconf_ops =3D { .is_generic =3D true, }; =20 -static int ma35_pinctrl_parse_groups(struct device_node *np, struct group_= desc *grp, +static int ma35_pinctrl_parse_groups(struct fwnode_handle *fwnode, struct = group_desc *grp, struct ma35_pinctrl *npctl, u32 index) { + struct device_node *np =3D to_of_node(fwnode); struct ma35_pin_setting *pin; unsigned long *configs; unsigned int nconfigs; @@ -990,7 +990,7 @@ static int ma35_pinctrl_parse_groups(struct device_node= *np, struct group_desc * if (ret) return ret; =20 - count =3D of_property_count_elems_of_size(np, "nuvoton,pins", sizeof(u32)= ); + count =3D fwnode_property_count_u32(fwnode, "nuvoton,pins"); if (!count || count % 3) return -EINVAL; =20 @@ -1000,7 +1000,7 @@ static int ma35_pinctrl_parse_groups(struct device_no= de *np, struct group_desc * =20 grp->grp.name =3D np->name; =20 - ret =3D of_property_read_u32_array(np, "nuvoton,pins", elems, count); + ret =3D fwnode_property_read_u32_array(fwnode, "nuvoton,pins", elems, cou= nt); if (ret) return -EINVAL; grp->grp.npins =3D count / 3; @@ -1027,10 +1027,11 @@ static int ma35_pinctrl_parse_groups(struct device_= node *np, struct group_desc * return 0; } =20 -static int ma35_pinctrl_parse_functions(struct device_node *np, struct ma3= 5_pinctrl *npctl, +static int ma35_pinctrl_parse_functions(struct fwnode_handle *fwnode, stru= ct ma35_pinctrl *npctl, u32 index) { - struct device_node *child; + struct device_node *np =3D to_of_node(fwnode); + struct fwnode_handle *child; struct pinfunction *func; struct group_desc *grp; static u32 grp_index; @@ -1050,12 +1051,14 @@ static int ma35_pinctrl_parse_functions(struct devi= ce_node *np, struct ma35_pinc if (!groups) return -ENOMEM; =20 - for_each_child_of_node(np, child) { - groups[i] =3D child->name; + fwnode_for_each_child_node(fwnode, child) { + struct device_node *node =3D to_of_node(child); + + groups[i] =3D node->name; grp =3D &npctl->groups[grp_index++]; ret =3D ma35_pinctrl_parse_groups(child, grp, npctl, i++); if (ret) { - of_node_put(child); + fwnode_handle_put(child); return ret; } } @@ -1066,13 +1069,12 @@ static int ma35_pinctrl_parse_functions(struct devi= ce_node *np, struct ma35_pinc =20 static int ma35_pinctrl_probe_dt(struct platform_device *pdev, struct ma35= _pinctrl *npctl) { + struct device *dev =3D &pdev->dev; struct fwnode_handle *child; u32 idx =3D 0; int ret; =20 - device_for_each_child_node(&pdev->dev, child) { - if (fwnode_property_present(child, "gpio-controller")) - continue; + for_each_gpiochip_node(dev, child) { npctl->nfunctions++; npctl->ngroups +=3D of_get_child_count(to_of_node(child)); } @@ -1090,11 +1092,8 @@ static int ma35_pinctrl_probe_dt(struct platform_dev= ice *pdev, struct ma35_pinct if (!npctl->groups) return -ENOMEM; =20 - device_for_each_child_node(&pdev->dev, child) { - if (fwnode_property_present(child, "gpio-controller")) - continue; - - ret =3D ma35_pinctrl_parse_functions(to_of_node(child), npctl, idx++); + for_each_gpiochip_node(dev, child) { + ret =3D ma35_pinctrl_parse_functions(child, npctl, idx++); if (ret) { fwnode_handle_put(child); dev_err(&pdev->dev, "failed to parse function\n"); @@ -1139,7 +1138,7 @@ int ma35_pinctrl_probe(struct platform_device *pdev, = const struct ma35_pinctrl_s npctl->info =3D info; npctl->dev =3D &pdev->dev; =20 - npctl->regmap =3D syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "nuv= oton,sys"); + npctl->regmap =3D syscon_regmap_lookup_by_phandle(dev_of_node(dev), "nuvo= ton,sys"); if (IS_ERR(npctl->regmap)) return dev_err_probe(&pdev->dev, PTR_ERR(npctl->regmap), "No syscfg phandle specified\n"); diff --git a/drivers/pinctrl/nuvoton/pinctrl-ma35d1.c b/drivers/pinctrl/nuv= oton/pinctrl-ma35d1.c index 8bb9a5a35954..eafa06ca0879 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-ma35d1.c +++ b/drivers/pinctrl/nuvoton/pinctrl-ma35d1.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include =20 diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nu= voton/pinctrl-npcm7xx.c index c6b11a198c76..d9245aa55d65 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c +++ b/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c @@ -7,10 +7,8 @@ #include #include #include +#include #include -#include -#include -#include #include #include #include @@ -1839,15 +1837,7 @@ static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *p= ctrl) int id =3D 0; =20 for_each_gpiochip_node(dev, child) { - struct device_node *np =3D to_of_node(child); - - ret =3D of_address_to_resource(np, 0, &res); - if (ret < 0) { - dev_err(dev, "Resource fail for GPIO bank %u\n", id); - return ret; - } - - pctrl->gpio_bank[id].base =3D ioremap(res.start, resource_size(&res)); + pctrl->gpio_bank[id].base =3D fwnode_iomap(child, 0); if (!pctrl->gpio_bank[id].base) return -EINVAL; =20 @@ -1869,7 +1859,7 @@ static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pc= trl) return ret; } =20 - ret =3D irq_of_parse_and_map(np, 0); + ret =3D fwnode_irq_get(child, 0); if (!ret) { dev_err(dev, "No IRQ for GPIO bank %u\n", id); return -EINVAL; diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c b/drivers/pinctrl/nu= voton/pinctrl-npcm8xx.c index 7c37d2cda9f1..4410077615df 100644 --- a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c +++ b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c @@ -2421,7 +2421,7 @@ static int npcm8xx_pinctrl_probe(struct platform_devi= ce *pdev) platform_set_drvdata(pdev, pctrl); =20 pctrl->gcr_regmap =3D - syscon_regmap_lookup_by_phandle(dev->of_node, "nuvoton,sysgcr"); + syscon_regmap_lookup_by_phandle(dev_of_node(dev), "nuvoton,sysgcr"); if (IS_ERR(pctrl->gcr_regmap)) return dev_err_probe(dev, PTR_ERR(pctrl->gcr_regmap), "Failed to find nuvoton,sysgcr property\n"); --=20 2.45.2