Skip to content

Commit 1bce744

Browse files
andy-shevlinusw
authored andcommitted
pinctrl: nuvoton: Make use of struct pinfunction and PINCTRL_PINFUNCTION()
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> Link: https://lore.kernel.org/20250318105932.2090926-4-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 1a65846 commit 1bce744

File tree

4 files changed

+17
-35
lines changed

4 files changed

+17
-35
lines changed

drivers/pinctrl/nuvoton/pinctrl-ma35.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,6 @@ static const u32 ds_3300mv_tbl[] = {
9898
17100, 25600, 34100, 42800, 48000, 56000, 77000, 82000,
9999
};
100100

101-
struct ma35_pin_func {
102-
const char *name;
103-
const char **groups;
104-
u32 ngroups;
105-
};
106-
107101
struct ma35_pin_setting {
108102
u32 offset;
109103
u32 shift;
@@ -149,7 +143,7 @@ struct ma35_pinctrl {
149143
struct regmap *regmap;
150144
struct ma35_pin_group *groups;
151145
unsigned int ngroups;
152-
struct ma35_pin_func *functions;
146+
struct pinfunction *functions;
153147
unsigned int nfunctions;
154148
};
155149

@@ -1041,9 +1035,10 @@ static int ma35_pinctrl_parse_functions(struct device_node *np, struct ma35_pinc
10411035
u32 index)
10421036
{
10431037
struct device_node *child;
1044-
struct ma35_pin_func *func;
1038+
struct pinfunction *func;
10451039
struct ma35_pin_group *grp;
10461040
static u32 grp_index;
1041+
const char **groups;
10471042
u32 ret, i = 0;
10481043

10491044
dev_dbg(npctl->dev, "parse function(%d): %s\n", index, np->name);
@@ -1055,19 +1050,21 @@ static int ma35_pinctrl_parse_functions(struct device_node *np, struct ma35_pinc
10551050
if (func->ngroups <= 0)
10561051
return 0;
10571052

1058-
func->groups = devm_kcalloc(npctl->dev, func->ngroups, sizeof(char *), GFP_KERNEL);
1059-
if (!func->groups)
1053+
groups = devm_kcalloc(npctl->dev, func->ngroups, sizeof(*groups), GFP_KERNEL);
1054+
if (!groups)
10601055
return -ENOMEM;
10611056

10621057
for_each_child_of_node(np, child) {
1063-
func->groups[i] = child->name;
1058+
groups[i] = child->name;
10641059
grp = &npctl->groups[grp_index++];
10651060
ret = ma35_pinctrl_parse_groups(child, grp, npctl, i++);
10661061
if (ret) {
10671062
of_node_put(child);
10681063
return ret;
10691064
}
10701065
}
1066+
1067+
func->groups = groups;
10711068
return 0;
10721069
}
10731070

drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -639,13 +639,6 @@ static struct pingroup npcm7xx_groups[] = {
639639

640640
#define NPCM7XX_SFUNC(a) NPCM7XX_FUNC(a, #a)
641641
#define NPCM7XX_FUNC(a, b...) static const char *a ## _grp[] = { b }
642-
#define NPCM7XX_MKFUNC(nm) { .name = #nm, .ngroups = ARRAY_SIZE(nm ## _grp), \
643-
.groups = nm ## _grp }
644-
struct npcm7xx_func {
645-
const char *name;
646-
const unsigned int ngroups;
647-
const char *const *groups;
648-
};
649642

650643
NPCM7XX_SFUNC(smb0);
651644
NPCM7XX_SFUNC(smb0b);
@@ -764,7 +757,8 @@ NPCM7XX_SFUNC(lkgpo2);
764757
NPCM7XX_SFUNC(nprd_smi);
765758

766759
/* Function names */
767-
static struct npcm7xx_func npcm7xx_funcs[] = {
760+
static struct pinfunction npcm7xx_funcs[] = {
761+
#define NPCM7XX_MKFUNC(nm) PINCTRL_PINFUNCTION(#nm, nm ## _grp, ARRAY_SIZE(nm ## _grp))
768762
NPCM7XX_MKFUNC(smb0),
769763
NPCM7XX_MKFUNC(smb0b),
770764
NPCM7XX_MKFUNC(smb0c),
@@ -880,6 +874,7 @@ static struct npcm7xx_func npcm7xx_funcs[] = {
880874
NPCM7XX_MKFUNC(lkgpo1),
881875
NPCM7XX_MKFUNC(lkgpo2),
882876
NPCM7XX_MKFUNC(nprd_smi),
877+
#undef NPCM7XX_MKFUNC
883878
};
884879

885880
#define NPCM7XX_PINCFG(a, b, c, d, e, f, g, h, i, j, k) \

drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -826,13 +826,6 @@ static struct pingroup npcm8xx_pingroups[] = {
826826

827827
#define NPCM8XX_SFUNC(a) NPCM8XX_FUNC(a, #a)
828828
#define NPCM8XX_FUNC(a, b...) static const char *a ## _grp[] = { b }
829-
#define NPCM8XX_MKFUNC(nm) { .name = #nm, .ngroups = ARRAY_SIZE(nm ## _grp), \
830-
.groups = nm ## _grp }
831-
struct npcm8xx_func {
832-
const char *name;
833-
const unsigned int ngroups;
834-
const char *const *groups;
835-
};
836829

837830
NPCM8XX_SFUNC(gpi36);
838831
NPCM8XX_SFUNC(gpi35);
@@ -1055,7 +1048,8 @@ NPCM8XX_SFUNC(hgpio6);
10551048
NPCM8XX_SFUNC(hgpio7);
10561049

10571050
/* Function names */
1058-
static struct npcm8xx_func npcm8xx_funcs[] = {
1051+
static struct pinfunction npcm8xx_funcs[] = {
1052+
#define NPCM8XX_MKFUNC(nm) PINCTRL_PINFUNCTION(#nm, nm ## _grp, ARRAY_SIZE(nm ## _grp))
10591053
NPCM8XX_MKFUNC(gpi36),
10601054
NPCM8XX_MKFUNC(gpi35),
10611055
NPCM8XX_MKFUNC(tp_jtag3),
@@ -1275,6 +1269,7 @@ static struct npcm8xx_func npcm8xx_funcs[] = {
12751269
NPCM8XX_MKFUNC(hgpio5),
12761270
NPCM8XX_MKFUNC(hgpio6),
12771271
NPCM8XX_MKFUNC(hgpio7),
1272+
#undef NPCM8XX_MKFUNC
12781273
};
12791274

12801275
#define NPCM8XX_PINCFG(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \

drivers/pinctrl/nuvoton/pinctrl-wpcm450.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,6 @@ static const struct pingroup wpcm450_groups[] = {
482482

483483
#define WPCM450_SFUNC(a) WPCM450_FUNC(a, #a)
484484
#define WPCM450_FUNC(a, b...) static const char *a ## _grp[] = { b }
485-
#define WPCM450_MKFUNC(nm) { .name = #nm, .ngroups = ARRAY_SIZE(nm ## _grp), \
486-
.groups = nm ## _grp }
487-
struct wpcm450_func {
488-
const char *name;
489-
const unsigned int ngroups;
490-
const char *const *groups;
491-
};
492485

493486
WPCM450_SFUNC(smb3);
494487
WPCM450_SFUNC(smb4);
@@ -555,7 +548,8 @@ WPCM450_FUNC(gpio, WPCM450_GRPS);
555548
#undef WPCM450_GRP
556549

557550
/* Function names */
558-
static struct wpcm450_func wpcm450_funcs[] = {
551+
static struct pinfunction wpcm450_funcs[] = {
552+
#define WPCM450_MKFUNC(nm) PINCTRL_PINFUNCTION(#nm, nm ## _grp, ARRAY_SIZE(nm ## _grp))
559553
WPCM450_MKFUNC(smb3),
560554
WPCM450_MKFUNC(smb4),
561555
WPCM450_MKFUNC(smb5),
@@ -616,6 +610,7 @@ static struct wpcm450_func wpcm450_funcs[] = {
616610
WPCM450_MKFUNC(hg6),
617611
WPCM450_MKFUNC(hg7),
618612
WPCM450_MKFUNC(gpio),
613+
#undef WPCM450_MKFUNC
619614
};
620615

621616
#define WPCM450_PINCFG(a, b, c, d, e, f, g) \

0 commit comments

Comments
 (0)