From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jacky Huang <ychuang3@nuvoton.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Tomer Maimon <tmaimon77@gmail.com>,
linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org
Cc: "Shan-Chun Hung" <schung@nuvoton.com>,
"Linus Walleij" <linus.walleij@linaro.org>,
"Avi Fishman" <avifishman70@gmail.com>,
"Tali Perry" <tali.perry1@gmail.com>,
"Patrick Venture" <venture@google.com>,
"Nancy Yuen" <yuenn@google.com>,
"Benjamin Fair" <benjaminfair@google.com>,
"Jonathan Neuschäfer" <j.neuschaefer@gmx.net>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>
Subject: [PATCH v2 3/5] pinctrl: nuvoton: Make use of struct pinfunction and PINCTRL_PINFUNCTION()
Date: Tue, 18 Mar 2025 12:57:16 +0200 [thread overview]
Message-ID: <20250318105932.2090926-4-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20250318105932.2090926-1-andriy.shevchenko@linux.intel.com>
Since pin control provides a generic data type and a macro for
the pin function definition, use them in the driver.
Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
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/nuvoton/pinctrl-ma35.c
index 59c4e7c6cdde..ad4f9ca414c8 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[] = {
17100, 25600, 34100, 42800, 48000, 56000, 77000, 82000,
};
-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;
};
@@ -1041,9 +1035,10 @@ static int ma35_pinctrl_parse_functions(struct device_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 = 0;
dev_dbg(npctl->dev, "parse function(%d): %s\n", index, np->name);
@@ -1055,12 +1050,12 @@ static int ma35_pinctrl_parse_functions(struct device_node *np, struct ma35_pinc
if (func->ngroups <= 0)
return 0;
- func->groups = devm_kcalloc(npctl->dev, func->ngroups, sizeof(char *), GFP_KERNEL);
- if (!func->groups)
+ groups = devm_kcalloc(npctl->dev, func->ngroups, sizeof(*groups), GFP_KERNEL);
+ if (!groups)
return -ENOMEM;
for_each_child_of_node(np, child) {
- func->groups[i] = child->name;
+ groups[i] = child->name;
grp = &npctl->groups[grp_index++];
ret = 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 = groups;
return 0;
}
diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nuvoton/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[] = {
#define NPCM7XX_SFUNC(a) NPCM7XX_FUNC(a, #a)
#define NPCM7XX_FUNC(a, b...) static const char *a ## _grp[] = { b }
-#define NPCM7XX_MKFUNC(nm) { .name = #nm, .ngroups = ARRAY_SIZE(nm ## _grp), \
- .groups = nm ## _grp }
-struct npcm7xx_func {
- const char *name;
- const unsigned int ngroups;
- const char *const *groups;
-};
NPCM7XX_SFUNC(smb0);
NPCM7XX_SFUNC(smb0b);
@@ -764,7 +757,8 @@ NPCM7XX_SFUNC(lkgpo2);
NPCM7XX_SFUNC(nprd_smi);
/* Function names */
-static struct npcm7xx_func npcm7xx_funcs[] = {
+static struct pinfunction npcm7xx_funcs[] = {
+#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[] = {
NPCM7XX_MKFUNC(lkgpo1),
NPCM7XX_MKFUNC(lkgpo2),
NPCM7XX_MKFUNC(nprd_smi),
+#undef NPCM7XX_MKFUNC
};
#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/nuvoton/pinctrl-npcm8xx.c
index eac43315a360..62347a82282d 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c
@@ -826,13 +826,6 @@ static struct pingroup npcm8xx_pingroups[] = {
#define NPCM8XX_SFUNC(a) NPCM8XX_FUNC(a, #a)
#define NPCM8XX_FUNC(a, b...) static const char *a ## _grp[] = { b }
-#define NPCM8XX_MKFUNC(nm) { .name = #nm, .ngroups = ARRAY_SIZE(nm ## _grp), \
- .groups = nm ## _grp }
-struct npcm8xx_func {
- const char *name;
- const unsigned int ngroups;
- const char *const *groups;
-};
NPCM8XX_SFUNC(gpi36);
NPCM8XX_SFUNC(gpi35);
@@ -1055,7 +1048,8 @@ NPCM8XX_SFUNC(hgpio6);
NPCM8XX_SFUNC(hgpio7);
/* Function names */
-static struct npcm8xx_func npcm8xx_funcs[] = {
+static struct pinfunction npcm8xx_funcs[] = {
+#define NPCM8XX_MKFUNC(nm) PINCTRL_PINFUNCTION(#nm, nm ## _grp, ARRAY_SIZE(nm ## _grp))
NPCM8XX_MKFUNC(gpi36),
NPCM8XX_MKFUNC(gpi35),
NPCM8XX_MKFUNC(tp_jtag3),
@@ -1275,6 +1269,7 @@ static struct npcm8xx_func npcm8xx_funcs[] = {
NPCM8XX_MKFUNC(hgpio5),
NPCM8XX_MKFUNC(hgpio6),
NPCM8XX_MKFUNC(hgpio7),
+#undef NPCM8XX_MKFUNC
};
#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/nuvoton/pinctrl-wpcm450.c
index 2f97accef837..4264ca749175 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[] = {
#define WPCM450_SFUNC(a) WPCM450_FUNC(a, #a)
#define WPCM450_FUNC(a, b...) static const char *a ## _grp[] = { b }
-#define WPCM450_MKFUNC(nm) { .name = #nm, .ngroups = ARRAY_SIZE(nm ## _grp), \
- .groups = nm ## _grp }
-struct wpcm450_func {
- const char *name;
- const unsigned int ngroups;
- const char *const *groups;
-};
WPCM450_SFUNC(smb3);
WPCM450_SFUNC(smb4);
@@ -555,7 +548,8 @@ WPCM450_FUNC(gpio, WPCM450_GRPS);
#undef WPCM450_GRP
/* Function names */
-static struct wpcm450_func wpcm450_funcs[] = {
+static struct pinfunction wpcm450_funcs[] = {
+#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[] = {
WPCM450_MKFUNC(hg6),
WPCM450_MKFUNC(hg7),
WPCM450_MKFUNC(gpio),
+#undef WPCM450_MKFUNC
};
#define WPCM450_PINCFG(a, b, c, d, e, f, g) \
--
2.47.2
next prev parent reply other threads:[~2025-03-18 10:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 10:57 [PATCH v2 0/5] pinctrl: nuvoton: A few cleanups and a fix Andy Shevchenko
2025-03-18 10:57 ` [PATCH v2 1/5] pinctrl: npcm8xx: Fix incorrect struct npcm8xx_pincfg assignment Andy Shevchenko
2025-03-18 10:57 ` [PATCH v2 2/5] pinctrl: nuvoton: Convert to use struct pingroup and PINCTRL_PINGROUP() Andy Shevchenko
2025-03-18 10:57 ` Andy Shevchenko [this message]
2025-03-18 10:57 ` [PATCH v2 4/5] pinctrl: nuvoton: Convert to use struct group_desc Andy Shevchenko
2025-03-18 10:57 ` [PATCH v2 5/5] pinctrl: nuvoton: Reduce use of OF-specific APIs Andy Shevchenko
2025-03-20 8:15 ` [PATCH v2 0/5] pinctrl: nuvoton: A few cleanups and a fix Linus Walleij
2025-03-20 9:45 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250318105932.2090926-4-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=avifishman70@gmail.com \
--cc=benjaminfair@google.com \
--cc=j.neuschaefer@gmx.net \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=openbmc@lists.ozlabs.org \
--cc=schung@nuvoton.com \
--cc=tali.perry1@gmail.com \
--cc=tmaimon77@gmail.com \
--cc=venture@google.com \
--cc=ychuang3@nuvoton.com \
--cc=yuenn@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).