pinctrl: Convert struct group_desc to use struct pingroup
Subsystems (12)
v5 cover pinctrl: Convert struct group_desc to use struct pingroup
The struct group_desc has a lot of duplication with struct pingroup. Deduplicate that by embeddind the latter in the former and convert users.
NB. The function_desc is in plan to follow the similar deduplication.
This time test-compiled with old GCC 8 for arm64, besides GCC 13 and LLVM 16 for x86_64.
In v5:
- dropped applied patches
- elaborated the need of the conversion (Fabio)
- reworked to avoid build errors on old GCC (Marek, Krzysztof, Geert)
v4: https://lore.kernel.org/r/[email protected]
In v4:
- made pins also unsigned in struct group_desc (Geert)
- made local pins variable unsigned in renesas drivers (Geert)
- collected more tags (Paul, Geert)
v3: https://lore.kernel.org/r/[email protected]
In v3:
- fixed reported bug in equilibrium code (LKP) - collected tags (Emil, Florian, Paul)
v2: https://lore.kernel.org/r/[email protected]
In v2:
- added a few patches to fix multiple compile-time errors (LKP)
- added tag (Jonathan)
v1: https://lore.kernel.org/r/[email protected]
Andy Shevchenko (13):
pinctrl: core: Add a convenient define PINCTRL_GROUP_DESC()
pinctrl: mediatek: Use C99 initializers in PINCTRL_PIN_GROUP()
pinctrl: ingenic: Use C99 initializers in PINCTRL_PIN_GROUP()
pinctrl: core: Embed struct pingroup into struct group_desc
pinctrl: bcm: Convert to use grp member
pinctrl: equilibrium: Convert to use grp member
pinctrl: imx: Convert to use grp member
pinctrl: ingenic: Convert to use grp member
pinctrl: keembay: Convert to use grp member
pinctrl: mediatek: Convert to use grp member
pinctrl: renesas: Convert to use grp member
pinctrl: starfive: Convert to use grp member
pinctrl: core: Remove unused members from struct group_desc
drivers/pinctrl/bcm/pinctrl-ns.c | 4 +-- drivers/pinctrl/core.c | 11 +++--- drivers/pinctrl/core.h | 17 +++++---- drivers/pinctrl/freescale/pinctrl-imx.c | 31 ++++++++-------- drivers/pinctrl/mediatek/pinctrl-moore.c | 13 ++++--- drivers/pinctrl/mediatek/pinctrl-moore.h | 10 +++--- drivers/pinctrl/mediatek/pinctrl-paris.h | 10 +++--- drivers/pinctrl/pinctrl-equilibrium.c | 4 +-- drivers/pinctrl/pinctrl-ingenic.c | 35 ++++++++++--------- drivers/pinctrl/pinctrl-keembay.c | 2 +- drivers/pinctrl/renesas/pinctrl-rza1.c | 2 +- drivers/pinctrl/renesas/pinctrl-rza2.c | 10 +++--- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 4 +-- drivers/pinctrl/renesas/pinctrl-rzv2m.c | 4 +-- .../starfive/pinctrl-starfive-jh7100.c | 8 ++--- .../starfive/pinctrl-starfive-jh7110.c | 8 ++--- 16 files changed, 84 insertions(+), 89 deletions(-)
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 1/13 pinctrl: core: Add a convenient define PINCTRL_GROUP_DESC()
Add PINCTRL_GROUP_DESC() macro for inline use.
--- drivers/pinctrl/core.c | 5 +---- drivers/pinctrl/core.h | 9 +++++++++ 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/pinctrl/core.c +1 -4
@@ -658,10 +658,7 @@ int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,if (!group)return -ENOMEM ; - group->name = name; - group->pins = pins; - group->num_pins = num_pins; - group->data = data; + *group =PINCTRL_GROUP_DESC (name, pins, num_pins, data); error =radix_tree_insert (&pctldev->pin_group_tree, selector, group);if (error)
drivers/pinctrl/core.h +9 -0
@@ -208,6 +208,15 @@ struct group_desc {void *data; }; +/* Convenience macro to define a generic pin group descriptor */ +#define PINCTRL_GROUP_DESC (_name, _pins, _num_pins, _data) \ +(struct group_desc) { \ + .name = _name, \ + .pins = _pins, \ + .num_pins = _num_pins, \ + .data = _data, \ +} +int pinctrl_generic_get_group_count (struct pinctrl_dev *pctldev); const char *pinctrl_generic_get_group_name(struct pinctrl_dev *pctldev,
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 2/13 pinctrl: mediatek: Use C99 initializers in PINCTRL_PIN_GROUP()
In reply to Andy ShevchenkoFor the better flexibility use C99 initializers in PINCTRL_PIN_GROUP().
--- drivers/pinctrl/mediatek/pinctrl-moore.h | 12 ++++++------ drivers/pinctrl/mediatek/pinctrl-paris.h | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.h +6 -6
@@ -37,12 +37,12 @@ .funcs = NULL, \ } -#define PINCTRL_PIN_GROUP (name, id) \ - { \ - name, \ - id##_pins, \ - ARRAY_SIZE(id##_pins), \ - id##_funcs, \ +#define PINCTRL_PIN_GROUP (_name_, id) \ + { \ + .name = _name_, \ + .pins = id##_pins, \ + .num_pins = ARRAY_SIZE(id##_pins), \ + .data = id##_funcs, \ } int mtk_moore_pinctrl_probe(struct platform_device *pdev,
drivers/pinctrl/mediatek/pinctrl-paris.h +6 -6
@@ -49,12 +49,12 @@ __VA_ARGS__, { } }, \ } -#define PINCTRL_PIN_GROUP (name, id) \ - { \ - name, \ - id##_pins, \ - ARRAY_SIZE(id##_pins), \ - id##_funcs, \ +#define PINCTRL_PIN_GROUP (_name_, id) \ + { \ + .name = _name_, \ + .pins = id##_pins, \ + .num_pins = ARRAY_SIZE(id##_pins), \ + .data = id##_funcs, \ }int mtk_paris_pinctrl_probe (struct platform_device *pdev);
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 3/13 pinctrl: ingenic: Use C99 initializers in PINCTRL_PIN_GROUP()
In reply to Andy ShevchenkoFor the better flexibility use C99 initializers in PINCTRL_PIN_GROUP().
--- drivers/pinctrl/pinctrl-ingenic.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
drivers/pinctrl/pinctrl-ingenic.c +13 -8
@@ -82,16 +82,21 @@#define PINS_PER_GPIO_CHIP 32#define JZ4730_PINS_PER_PAIRED_REG 16 -#define INGENIC_PIN_GROUP_FUNCS (name, id, funcs) \ - { \ - name, \ - id##_pins, \ - ARRAY_SIZE(id##_pins), \ - funcs, \ +#define INGENIC_PIN_GROUP_FUNCS (_name_, id, funcs) \ + { \ + .name = _name_, \ + .pins = id##_pins, \ + .num_pins = ARRAY_SIZE(id##_pins), \ + .data = funcs, \ } -#define INGENIC_PIN_GROUP (name, id, func) \ - INGENIC_PIN_GROUP_FUNCS(name, id, (void *)(func)) +#define INGENIC_PIN_GROUP (_name_, id, func) \ + { \ + .name = _name_, \ + .pins = id##_pins, \ + .num_pins = ARRAY_SIZE(id##_pins), \ + .data = (void *)func, \ + }enum jz_version {ID_JZ4730 ,
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Paul Cercueil
maintainerRe: [PATCH v5 03/13] pinctrl: ingenic: Use C99 initializers in PINCTRL_PIN_GROUP()
Hi Andy,
Le lundi 11 décembre 2023 à 20:57 +0200, Andy Shevchenko a écrit :
Quoted 51 lines
For the better flexibility use C99 initializers in
PINCTRL_PIN_GROUP().Signed-off-by Andy Shevchenko <[email protected]>---
drivers/pinctrl/pinctrl-ingenic.c | 21 +++++++++++++--------1 file changed, 13 insertions(+), 8 deletions(-)drivers/pinctrl/pinctrl-ingenic.c +0
-0@@ -82,16 +82,21 @@ #define PINS_PER_GPIO_CHIP 32 #define JZ4730_PINS_PER_PAIRED_REG 16drivers/pinctrl/pinctrl-ingenic.c +1
-6-#define INGENIC_PIN_GROUP_FUNCS (name, id, funcs) \ - { \ - name, \ - id##_pins, \ - ARRAY_SIZE(id##_pins), \ - funcs, \ +#define INGENIC_PIN_GROUP_FUNCS(_name_, id,funcs) \
drivers/pinctrl/pinctrl-ingenic.c +1
-0+ {\drivers/pinctrl/pinctrl-ingenic.c +1
-0+ .name =_name_, \
drivers/pinctrl/pinctrl-ingenic.c +1
-0+ .pins =id##_pins, \
drivers/pinctrl/pinctrl-ingenic.c +1
-0+ .num_pins =
ARRAY_SIZE(id##_pins), \drivers/pinctrl/pinctrl-ingenic.c +1
-0+ .data =funcs, \
}drivers/pinctrl/pinctrl-ingenic.c +1
-2-#define INGENIC_PIN_GROUP (name, id, func) \ - INGENIC_PIN_GROUP_FUNCS(name, id, (void *)(func)) +#define INGENIC_PIN_GROUP(_name_, id,func) \
drivers/pinctrl/pinctrl-ingenic.c +1
-0+ {\drivers/pinctrl/pinctrl-ingenic.c +1
-0+ .name =_name_, \
drivers/pinctrl/pinctrl-ingenic.c +1
-0+ .pins =id##_pins, \
drivers/pinctrl/pinctrl-ingenic.c +1
-0+ .num_pins =
ARRAY_SIZE(id##_pins), \drivers/pinctrl/pinctrl-ingenic.c +1
-0+ .data = (void*)func, \
drivers/pinctrl/pinctrl-ingenic.c line 99
Quoted 1 line
drivers/pinctrl/pinctrl-ingenic.c +1
-0+ }
This INGENIC_PIN_GROUP() macro doesn't need to be modified, does it?
Cheers,
-Paul
Quoted 3 lines
enumjz_version{
ID_JZ4730,
Re: [PATCH v5 03/13] pinctrl: ingenic: Use C99 initializers in PINCTRL_PIN_GROUP()
Quoted 1 line · Paul Cercueil
Le lundi 11 décembre 2023 à 20:57 +0200, Andy Shevchenko a écrit :
...
Quoted 9 lines
Quoted 9 lines
drivers/pinctrl/pinctrl-ingenic.c +1
-2-#define INGENIC_PIN_GROUP (name, id, func) \ - INGENIC_PIN_GROUP_FUNCS(name, id, (void *)(func)) +#define INGENIC_PIN_GROUP(_name_, id,func) \
(quoted diff) +1
-0+ {\(quoted diff) +1
-0+ .name =_name_, \
(quoted diff) +1
-0+ .pins =
Quoted 8 lines
drivers/pinctrl/pinctrl-ingenic.c line 99
Quoted 6 lines
id##_pins, \
(quoted diff) +1
-0+ .num_pins =
ARRAY_SIZE(id##_pins), \(quoted diff) +1
-0+ .data = (void*)func, \
drivers/pinctrl/pinctrl-ingenic.c +1
-0+ }This
INGENIC_PIN_GROUP()macro doesn't need to be modified, does it?
We can go either way. I prefer to go this way as it reduces level of indirections in the macros. It makes code easier to read and understand. But if you insist, I can drop that change in next version.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v5 03/13] pinctrl: ingenic: Use C99 initializers in PINCTRL_PIN_GROUP()
Hi Andy,
Le mercredi 13 décembre 2023 à 15:21 +0200, Andy Shevchenko a écrit :
Quoted 24 lines · Paul Cercueil
Quoted 1 line
Le lundi 11 décembre 2023 à 20:57 +0200, Andy Shevchenko a écrit :
...
Quoted 10 lines
Quoted 10 lines
drivers/pinctrl/pinctrl-ingenic.c +1
-2-#define INGENIC_PIN_GROUP (name, id, func) \ - INGENIC_PIN_GROUP_FUNCS(name, id, (void *)(func)) +#define INGENIC_PIN_GROUP(_name_, id,func) \
(quoted diff) +1
-0+ {\(quoted diff) +1
-0+ .name =_name_, \
(quoted diff) +1
-0+ .pins =id##_pins, \
Quoted 8 lines
drivers/pinctrl/pinctrl-ingenic.c line 99
Quoted 5 lines
(quoted diff) +1
-0+ .num_pins =
ARRAY_SIZE(id##_pins), \(quoted diff) +1
-0+ .data = (void*)func, \
drivers/pinctrl/pinctrl-ingenic.c +1
-0+ }This
INGENIC_PIN_GROUP()macro doesn't need to be modified, does it?
Quoted 5 lines
We can go either way. I prefer to go this way as it reduces level of indirections in the macros. It makes code easier to read and understand.
But if you insist, I can drop that change in next version.
I like the patches to be minimal. But I understand your point of view as well.
If you have to issue a v6, maybe state the reason why you also modify INGENIC_PIN_GROUP() then. But I don't care enough to request a v6 just for that.
So:
Cheers,
-Paul
Re: [PATCH v5 03/13] pinctrl: ingenic: Use C99 initializers in PINCTRL_PIN_GROUP()
Quoted 3 lines · Paul Cercueil
Le mercredi 13 décembre 2023 à 15:21 +0200, Andy Shevchenko a écrit :
Quoted 2 lines · Paul Cercueil
Quoted 1 line
Le lundi 11 décembre 2023 à 20:57 +0200, Andy Shevchenko a écrit :
...
Quoted 27 lines
Quoted 19 lines
Quoted 10 lines
Quoted 10 lines
drivers/pinctrl/pinctrl-ingenic.c +1
-2-#define INGENIC_PIN_GROUP (name, id, func) \ - INGENIC_PIN_GROUP_FUNCS(name, id, (void *)(func)) +#define INGENIC_PIN_GROUP(_name_, id,func) \
(quoted diff) +1
-0+ {\(quoted diff) +1
-0+ .name =_name_, \
(quoted diff) +1
-0+ .pins =id##_pins, \
Quoted 8 lines
drivers/pinctrl/pinctrl-ingenic.c line 99
Quoted 5 lines
(quoted diff) +1
-0+ .num_pins =
ARRAY_SIZE(id##_pins), \(quoted diff) +1
-0+ .data = (void*)func, \
drivers/pinctrl/pinctrl-ingenic.c +1
-0+ }This
INGENIC_PIN_GROUP()macro doesn't need to be modified, does it?Quoted 4 lines
We can go either way. I prefer to go this way as it reduces level of indirections in the macros. It makes code easier to read and understand.
But if you insist, I can drop that change in next version.I like the patches to be minimal. But I understand your point of view as well.
Quoted 6 lines
If you have to issue a v6, maybe state the reason why you also modify
INGENIC_PIN_GROUP()then. But I don't care enough to request a v6 just for that.So:
Acked-by Paul Cercueil <[email protected]>
Thank you!
But as I already noted, the series had been applied (by Linus W.) and this does not seem to be a critical to fix, do you agree?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Paul Cercueil
maintainerRe: [PATCH v5 03/13] pinctrl: ingenic: Use C99 initializers in PINCTRL_PIN_GROUP()
Hi Andy,
Le lundi 18 décembre 2023 à 12:41 +0200, Andy Shevchenko a écrit :
Quoted 48 lines · Paul Cercueil
Quoted 5 lines
Le mercredi 13 décembre 2023 à 15:21 +0200, Andy Shevchenko a écrit :
Quoted 3 lines · Paul Cercueil
Quoted 2 lines
Le lundi 11 décembre 2023 à 20:57 +0200, Andy Shevchenko a écrit :
...
Quoted 39 lines
Quoted 23 lines
Quoted 6 lines
Quoted 6 lines
drivers/pinctrl/pinctrl-ingenic.c +1
-2-#define INGENIC_PIN_GROUP (name, id, func) \ - INGENIC_PIN_GROUP_FUNCS(name, id, (void *)(func)) +#define INGENIC_PIN_GROUP(_name_, id,func) \
(quoted diff) +1
-0+ {Quoted 16 lines
drivers/pinctrl/pinctrl-ingenic.c line 99
Quoted 12 lines
\(quoted diff) +1
-0+ .name =_name_,
\(quoted diff) +1
-0+ .pins =id##_pins,
\(quoted diff) +1
-0+ .num_pins =
ARRAY_SIZE(id##_pins), \(quoted diff) +1
-0+ .data = (void*)func, \
drivers/pinctrl/pinctrl-ingenic.c +1
-0+ }This
INGENIC_PIN_GROUP()macro doesn't need to be modified, does
it?Quoted 5 lines
We can go either way. I prefer to go this way as it reduces level of
indirections in the macros. It makes code easier to read and understand.
But if you insist, I can drop that change in next version.I like the patches to be minimal. But I understand your point of view
as well.If you have to issue a v6, maybe state the reason why you also modify
INGENIC_PIN_GROUP()then. But I don't care enough to request a v6 just
for that.
Quoted 8 lines
Quoted 2 lines
So:
Acked-by Paul Cercueil <[email protected]>Thank you!
But as I already noted, the series had been applied (by Linus W.) and this does not seem to be a critical to fix, do you agree?
Well I only suggested to change the commit message - so no, it is not critical to fix.
Cheers,
-Paul
PATCH v5 4/13 pinctrl: core: Embed struct pingroup into struct group_desc
In reply to Andy Shevchenkostruct group_desc is a particular version of the struct pingroup with associated opaque data. Start switching pin control core and drivers to use it explicitly.
--- drivers/pinctrl/core.c | 15 ++++++++++++--- drivers/pinctrl/core.h | 5 +++++ 2 files changed, 17 insertions(+), 3 deletions(-)
drivers/pinctrl/core.c +12 -3
@@ -557,7 +557,10 @@ const char *pinctrl_generic_get_group_name(struct pinctrl_dev *pctldev,if (!group)return NULL ; -return group->name; +if (group->name) +return group->name; + +return group->grp.name; }EXPORT_SYMBOL_GPL (pinctrl_generic_get_group_name);
@@ -583,8 +586,14 @@ int pinctrl_generic_get_group_pins(struct pinctrl_dev *pctldev,return -EINVAL ; } - *pins = group->pins; - *num_pins = group->num_pins; +if (group->pins) { + *pins = group->pins; + *num_pins = group->num_pins; +return 0 ; + } + + *pins = group->grp.pins; + *num_pins = group->grp.npins;return 0 ; }
drivers/pinctrl/core.h +5 -0
@@ -194,14 +194,18 @@ struct pinctrl_maps { #ifdef CONFIG_GENERIC_PINCTRL_GROUPS +#include <linux/pinctrl/pinctrl.h> + /** * struct group_desc - generic pin group descriptor + * @grp: generic data of the pin group (name and pins) * @name: name of the pin group * @pins: array of pins that belong to the group * @num_pins: number of pins in the group * @data: pin controller driver specific data */ struct group_desc { + struct pingroup grp; const char *name; const unsigned int *pins; int num_pins;
@@ -211,6 +215,7 @@ struct group_desc {/* Convenience macro to define a generic pin group descriptor */ #define PINCTRL_GROUP_DESC (_name, _pins, _num_pins, _data) \ (struct group_desc) { \ + .grp = PINCTRL_PINGROUP(_name, _pins, _num_pins), \ .name = _name, \ .pins = _pins, \ .num_pins = _num_pins, \
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 5/13 pinctrl: bcm: Convert to use grp member
In reply to Andy ShevchenkoConvert drivers to use grp member embedded in struct group_desc, because other members will be removed to avoid duplication and desynchronisation of the generic pin group description.
--- drivers/pinctrl/bcm/pinctrl-ns.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/bcm/pinctrl-ns.c +2 -2
@@ -171,8 +171,8 @@ static int ns_pinctrl_set_mux(struct pinctrl_dev *pctrl_dev,if (!group)return -EINVAL ; -for (i =0 ; i < group->num_pins; i++) - unset |=BIT (group->pins[i]); +for (i =0 ; i < group->grp.npins; i++) + unset |=BIT (group->grp.pins[i]); tmp =readl (ns_pinctrl->base); tmp &= ~unset;
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 6/13 pinctrl: equilibrium: Convert to use grp member
In reply to Andy ShevchenkoConvert drivers to use grp member embedded in struct group_desc, because other members will be removed to avoid duplication and desynchronisation of the generic pin group description.
--- drivers/pinctrl/pinctrl-equilibrium.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pinctrl/pinctrl-equilibrium.c +2 -2
@@ -331,8 +331,8 @@ static int eqbr_pinmux_set_mux(struct pinctrl_dev *pctldev,return -EINVAL ; pinmux = grp->data; -for (i =0 ; i < grp->num_pins; i++) -eqbr_set_pin_mux (pctl, pinmux[i], grp->pins[i]); +for (i =0 ; i < grp->grp.npins; i++) +eqbr_set_pin_mux (pctl, pinmux[i], grp->grp.pins[i]);return 0 ; }
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 7/13 pinctrl: imx: Convert to use grp member
In reply to Andy ShevchenkoConvert drivers to use grp member embedded in struct group_desc, because other members will be removed to avoid duplication and desynchronisation of the generic pin group description.
--- drivers/pinctrl/freescale/pinctrl-imx.c | 31 +++++++++++-------------- 1 file changed, 14 insertions(+), 17 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx.c +14 -17
@@ -42,7 +42,7 @@ static inline const struct group_desc *imx_pinctrl_find_group_by_name(for (i =0 ; i < pctldev->num_groups; i++) { grp =pinctrl_generic_get_group (pctldev, i); -if (grp && !strcmp (grp->name, name)) +if (grp && !strcmp (grp->grp.name, name))break ; }
@@ -79,9 +79,9 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev, }if (info->flags &IMX_USE_SCU ) { - map_num += grp->num_pins; + map_num += grp->grp.npins; }else { -for (i =0 ; i < grp->num_pins; i++) { +for (i =0 ; i < grp->grp.npins; i++) { pin = &((struct imx_pin *)(grp->data))[i];if (!(pin->conf.mmio.config &IMX_NO_PAD_CTL )) map_num++;
@@ -109,7 +109,7 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,/* create config map */ new_map++; -for (i = j =0 ; i < grp->num_pins; i++) { +for (i = j =0 ; i < grp->grp.npins; i++) { pin = &((struct imx_pin *)(grp->data))[i];/*
@@ -263,10 +263,10 @@ static int imx_pmx_set(struct pinctrl_dev *pctldev, unsigned selector,if (!func)return -EINVAL ; - npins = grp->num_pins; + npins = grp->grp.npins;dev_dbg (ipctl->dev,"enable function %s group %s\n" , - func->name, grp->name); + func->name, grp->grp.name);for (i =0 ; i < npins; i++) {/*
@@ -423,7 +423,7 @@ static void imx_pinconf_group_dbg_show(struct pinctrl_dev *pctldev,if (!grp)return ; -for (i =0 ; i < grp->num_pins; i++) { +for (i =0 ; i < grp->grp.npins; i++) {struct imx_pin *pin = &((struct imx_pin *)(grp->data))[i]; name =pin_get_name (pctldev, pin->pin);
@@ -526,7 +526,7 @@ static int imx_pinctrl_parse_groups(struct device_node *np, pin_size =FSL_PIN_SIZE ;/* Initialise group */ - grp->name = np->name; + grp->grp.name = np->name;/* * the binding format is fsl,pins = <PIN_FUNC_ID CONFIG ...>,
@@ -554,19 +554,17 @@ static int imx_pinctrl_parse_groups(struct device_node *np,return -EINVAL ; } - grp->num_pins = size / pin_size; - grp->data =devm_kcalloc (ipctl->dev, - grp->num_pins,sizeof (struct imx_pin ), -GFP_KERNEL ); + grp->grp.npins = size / pin_size; + grp->data =devm_kcalloc (ipctl->dev, grp->grp.npins,sizeof (*pin),GFP_KERNEL );if (!grp->data)return -ENOMEM ; - pins =devm_kcalloc (ipctl->dev, grp->num_pins,sizeof (*pins),GFP_KERNEL ); + pins =devm_kcalloc (ipctl->dev, grp->grp.npins,sizeof (*pins),GFP_KERNEL );if (!pins)return -ENOMEM ; - grp->pins = pins; + grp->grp.pins = pins; -for (i =0 ; i < grp->num_pins; i++) { +for (i =0 ; i < grp->grp.npins; i++) { pin = &((struct imx_pin *)(grp->data))[i];if (info->flags &IMX_USE_SCU ) info->imx_pinctrl_parse_pin (ipctl, &pins[i], pin, &list);
@@ -613,8 +611,7 @@ static int imx_pinctrl_parse_functions(struct device_node *np, i =0 ;for_each_child_of_node (np, child) { - grp =devm_kzalloc (ipctl->dev,sizeof (struct group_desc ), -GFP_KERNEL ); + grp =devm_kzalloc (ipctl->dev,sizeof (*grp),GFP_KERNEL );if (!grp) {of_node_put (child);return -ENOMEM ;
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 8/13 pinctrl: ingenic: Convert to use grp member
In reply to Andy ShevchenkoConvert drivers to use grp member embedded in struct group_desc, because other members will be removed to avoid duplication and desynchronisation of the generic pin group description.
--- drivers/pinctrl/pinctrl-ingenic.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
drivers/pinctrl/pinctrl-ingenic.c +11 -15
@@ -84,17 +84,13 @@#define INGENIC_PIN_GROUP_FUNCS (_name_, id, funcs) \ { \ - .name = _name_, \ - .pins = id##_pins, \ - .num_pins = ARRAY_SIZE(id##_pins), \ + .grp = PINCTRL_PINGROUP(_name_, id##_pins, ARRAY_SIZE(id##_pins)), \ .data = funcs, \ }#define INGENIC_PIN_GROUP (_name_, id, func) \ { \ - .name = _name_, \ - .pins = id##_pins, \ - .num_pins = ARRAY_SIZE(id##_pins), \ + .grp = PINCTRL_PINGROUP(_name_, id##_pins, ARRAY_SIZE(id##_pins)), \ .data = (void *)func, \ }
@@ -3766,17 +3762,17 @@ static int ingenic_pinmux_set_mux(struct pinctrl_dev *pctldev,return -EINVAL ;dev_dbg (pctldev->dev,"enable function %s group %s\n" , - func->name, grp->name); + func->name, grp->grp.name); mode = (uintptr_t )grp->data;if (mode <=3 ) { -for (i =0 ; i < grp->num_pins; i++) -ingenic_pinmux_set_pin_fn (jzpc, grp->pins[i], mode); +for (i =0 ; i < grp->grp.npins; i++) +ingenic_pinmux_set_pin_fn (jzpc, grp->grp.pins[i], mode); }else { pin_modes = grp->data; -for (i =0 ; i < grp->num_pins; i++) -ingenic_pinmux_set_pin_fn (jzpc, grp->pins[i], pin_modes[i]); +for (i =0 ; i < grp->grp.npins; i++) +ingenic_pinmux_set_pin_fn (jzpc, grp->grp.pins[i], pin_modes[i]); }return 0 ;
@@ -4303,12 +4299,12 @@ static int __init ingenic_pinctrl_probe(struct platform_device *pdev)for (i =0 ; i < chip_info->num_groups; i++) {const struct group_desc *group = &chip_info->groups[i]; +const struct pingroup *grp = &group->grp; - err =pinctrl_generic_add_group (jzpc->pctl, group->name, - group->pins, group->num_pins, group->data); + err =pinctrl_generic_add_group (jzpc->pctl, grp->name, grp->pins, grp->npins, + group->data);if (err <0 ) { -dev_err (dev,"Failed to register group %s\n" , - group->name); +dev_err (dev,"Failed to register group %s\n" , grp->name);return err; } }
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 9/13 pinctrl: keembay: Convert to use grp member
In reply to Andy ShevchenkoConvert drivers to use grp member embedded in struct group_desc, because other members will be removed to avoid duplication and desynchronisation of the generic pin group description.
--- drivers/pinctrl/pinctrl-keembay.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/pinctrl-keembay.c +1 -1
@@ -945,7 +945,7 @@ static int keembay_set_mux(struct pinctrl_dev *pctldev, unsigned int fun_sel,return -EINVAL ;/* Change modes for pins in the selected group */ - pin = *grp->pins; + pin = *grp->grp.pins; pin_mode = *(u8 *)(func->data); val =keembay_read_reg (kpc->base1 +KEEMBAY_GPIO_MODE , pin);
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 10/13 pinctrl: mediatek: Convert to use grp member
In reply to Andy ShevchenkoConvert drivers to use grp member embedded in struct group_desc, because other members will be removed to avoid duplication and desynchronisation of the generic pin group description.
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 13 ++++++------- drivers/pinctrl/mediatek/pinctrl-moore.h | 4 +--- drivers/pinctrl/mediatek/pinctrl-paris.h | 4 +--- 3 files changed, 8 insertions(+), 13 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.c +6 -7
@@ -56,12 +56,12 @@ static int mtk_pinmux_set_mux(struct pinctrl_dev *pctldev,return -EINVAL ;dev_dbg (pctldev->dev,"enable function %s group %s\n" , - func->name, grp->name); + func->name, grp->grp.name); -for (i =0 ; i < grp->num_pins; i++) { +for (i =0 ; i < grp->grp.npins; i++) {const struct mtk_pin_desc *desc;int *pin_modes = grp->data; -int pin = grp->pins[i]; +int pin = grp->grp.pins[i]; desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];if (!desc->name)
@@ -602,13 +602,12 @@ static int mtk_build_groups(struct mtk_pinctrl *hw)for (i =0 ; i < hw->soc->ngrps; i++) {const struct group_desc *group = hw->soc->grps + i; +const struct pingroup *grp = &group->grp; - err =pinctrl_generic_add_group (hw->pctrl, group->name, - group->pins, group->num_pins, + err =pinctrl_generic_add_group (hw->pctrl, grp->name, grp->pins, grp->npins, group->data);if (err <0 ) { -dev_err (hw->dev,"Failed to register group %s\n" , - group->name); +dev_err (hw->dev,"Failed to register group %s\n" , grp->name);return err; } }
drivers/pinctrl/mediatek/pinctrl-moore.h +1 -3
@@ -39,9 +39,7 @@#define PINCTRL_PIN_GROUP (_name_, id) \ { \ - .name = _name_, \ - .pins = id##_pins, \ - .num_pins = ARRAY_SIZE(id##_pins), \ + .grp = PINCTRL_PINGROUP(_name_, id##_pins, ARRAY_SIZE(id##_pins)), \ .data = id##_funcs, \ }
drivers/pinctrl/mediatek/pinctrl-paris.h +1 -3
@@ -51,9 +51,7 @@#define PINCTRL_PIN_GROUP (_name_, id) \ { \ - .name = _name_, \ - .pins = id##_pins, \ - .num_pins = ARRAY_SIZE(id##_pins), \ + .grp = PINCTRL_PINGROUP(_name_,id##_pins, ARRAY_SIZE(id##_pins)), \ .data = id##_funcs, \ }
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 11/13 pinctrl: renesas: Convert to use grp member
In reply to Andy ShevchenkoConvert drivers to use grp member embedded in struct group_desc, because other members will be removed to avoid duplication and desynchronisation of the generic pin group description.
--- drivers/pinctrl/renesas/pinctrl-rza1.c | 2 +- drivers/pinctrl/renesas/pinctrl-rza2.c | 10 +++++----- drivers/pinctrl/renesas/pinctrl-rzg2l.c | 4 ++-- drivers/pinctrl/renesas/pinctrl-rzv2m.c | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-)
drivers/pinctrl/renesas/pinctrl-rza1.c +1 -1
@@ -1131,7 +1131,7 @@ static int rza1_set_mux(struct pinctrl_dev *pctldev, unsigned int selector,return -EINVAL ; mux_confs = (struct rza1_mux_conf *)func->data; -for (i =0 ; i < grp->num_pins; ++i) { +for (i =0 ; i < grp->grp.npins; ++i) {int ret; ret =rza1_pin_mux_single (rza1_pctl, &mux_confs[i]);
drivers/pinctrl/renesas/pinctrl-rza2.c +5 -5
@@ -447,15 +447,15 @@ static int rza2_set_mux(struct pinctrl_dev *pctldev, unsigned int selector, psel_val = func->data; -for (i =0 ; i < grp->num_pins; ++i) { +for (i =0 ; i < grp->grp.npins; ++i) {dev_dbg (priv->dev,"Setting P%c_%d to PSEL=%d\n" , - port_names[RZA2_PIN_ID_TO_PORT (grp->pins[i])], -RZA2_PIN_ID_TO_PIN (grp->pins[i]), + port_names[RZA2_PIN_ID_TO_PORT (grp->grp.pins[i])], +RZA2_PIN_ID_TO_PIN (grp->grp.pins[i]), psel_val[i]);rza2_set_pin_function ( priv->base, -RZA2_PIN_ID_TO_PORT (grp->pins[i]), -RZA2_PIN_ID_TO_PIN (grp->pins[i]), +RZA2_PIN_ID_TO_PORT (grp->grp.pins[i]), +RZA2_PIN_ID_TO_PIN (grp->grp.pins[i]), psel_val[i]); }
drivers/pinctrl/renesas/pinctrl-rzg2l.c +2 -2
@@ -283,9 +283,9 @@ static int rzg2l_pinctrl_set_mux(struct pinctrl_dev *pctldev,return -EINVAL ; psel_val = func->data; - pins = group->pins; + pins = group->grp.pins; -for (i =0 ; i < group->num_pins; i++) { +for (i =0 ; i < group->grp.npins; i++) {unsigned int *pin_data = pctrl->desc.pins[pins[i]].drv_data;u32 off =RZG2L_PIN_CFG_TO_PORT_OFFSET (*pin_data);u32 pin =RZG2L_PIN_ID_TO_PIN (pins[i]);
drivers/pinctrl/renesas/pinctrl-rzv2m.c +2 -2
@@ -175,9 +175,9 @@ static int rzv2m_pinctrl_set_mux(struct pinctrl_dev *pctldev,return -EINVAL ; psel_val = func->data; - pins = group->pins; + pins = group->grp.pins; -for (i =0 ; i < group->num_pins; i++) { +for (i =0 ; i < group->grp.npins; i++) {dev_dbg (pctrl->dev,"port:%u pin: %u PSEL:%u\n" ,RZV2M_PIN_ID_TO_PORT (pins[i]),RZV2M_PIN_ID_TO_PIN (pins[i]), psel_val[i]);
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 12/13 pinctrl: starfive: Convert to use grp member
In reply to Andy ShevchenkoConvert drivers to use grp member embedded in struct group_desc, because other members will be removed to avoid duplication and desynchronisation of the generic pin group description.
--- drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 8 ++++---- drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c +4 -4
@@ -654,7 +654,7 @@ static int starfive_set_mux(struct pinctrl_dev *pctldev,return -EINVAL ; pinmux = group->data; -for (i =0 ; i < group->num_pins; i++) { +for (i =0 ; i < group->grp.npins; i++) {u32 v = pinmux[i];unsigned int gpio =starfive_pinmux_to_gpio (v);u32 dout =starfive_pinmux_to_dout (v);
@@ -797,7 +797,7 @@ static int starfive_pinconf_group_get(struct pinctrl_dev *pctldev,if (!group)return -EINVAL ; -return starfive_pinconf_get (pctldev, group->pins[0 ], config); +return starfive_pinconf_get (pctldev, group->grp.pins[0 ], config); } static int starfive_pinconf_group_set(struct pinctrl_dev *pctldev,
@@ -876,8 +876,8 @@ static int starfive_pinconf_group_set(struct pinctrl_dev *pctldev, } } -for (i =0 ; i < group->num_pins; i++) -starfive_padctl_rmw (sfp, group->pins[i], mask, value); +for (i =0 ; i < group->grp.npins; i++) +starfive_padctl_rmw (sfp, group->grp.pins[i], mask, value);return 0 ; }
drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c +4 -4
@@ -307,7 +307,7 @@ static int jh7110_set_mux(struct pinctrl_dev *pctldev,return -EINVAL ; pinmux = group->data; -for (i =0 ; i < group->num_pins; i++) { +for (i =0 ; i < group->grp.npins; i++) {u32 v = pinmux[i];if (info->jh7110_set_one_pin_mux)
@@ -437,7 +437,7 @@ static int jh7110_pinconf_group_get(struct pinctrl_dev *pctldev,if (!group)return -EINVAL ; -return jh7110_pinconf_get (pctldev, group->pins[0 ], config); +return jh7110_pinconf_get (pctldev, group->grp.pins[0 ], config); } static int jh7110_pinconf_group_set(struct pinctrl_dev *pctldev,
@@ -508,8 +508,8 @@ static int jh7110_pinconf_group_set(struct pinctrl_dev *pctldev, } } -for (i =0 ; i < group->num_pins; i++) -jh7110_padcfg_rmw (sfp, group->pins[i], mask, value); +for (i =0 ; i < group->grp.npins; i++) +jh7110_padcfg_rmw (sfp, group->grp.pins[i], mask, value);return 0 ; }
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
PATCH v5 13/13 pinctrl: core: Remove unused members from struct group_desc
In reply to Andy ShevchenkoAll drivers are converted to use embedded struct pingroup. Remove unused members from struct group_desc.
--- drivers/pinctrl/core.c | 9 --------- drivers/pinctrl/core.h | 9 --------- 2 files changed, 18 deletions(-)
drivers/pinctrl/core.c +0 -9
@@ -557,9 +557,6 @@ const char *pinctrl_generic_get_group_name(struct pinctrl_dev *pctldev,if (!group)return NULL ; -if (group->name) -return group->name; -return group->grp.name; }EXPORT_SYMBOL_GPL (pinctrl_generic_get_group_name);
@@ -586,12 +583,6 @@ int pinctrl_generic_get_group_pins(struct pinctrl_dev *pctldev,return -EINVAL ; } -if (group->pins) { - *pins = group->pins; - *num_pins = group->num_pins; -return 0 ; - } - *pins = group->grp.pins; *num_pins = group->grp.npins;
drivers/pinctrl/core.h +0 -9
@@ -199,16 +199,10 @@ struct pinctrl_maps {/** * struct group_desc - generic pin group descriptor * @grp: generic data of the pin group (name and pins) -* @name: name of the pin group -* @pins: array of pins that belong to the group -* @num_pins: number of pins in the group * @data: pin controller driver specific data */ struct group_desc {struct pingroup grp; -const char *name; -const unsigned int *pins; -int num_pins;void *data; };
@@ -216,9 +210,6 @@ struct group_desc {#define PINCTRL_GROUP_DESC (_name, _pins, _num_pins, _data) \ (struct group_desc) { \ .grp = PINCTRL_PINGROUP(_name, _pins, _num_pins), \ - .name = _name, \ - .pins = _pins, \ - .num_pins = _num_pins, \ .data = _data, \ }
Signature · 1 line
2.43.0.rc1.1.gbec44491f096
Linus Walleij
AppliedQuoted 8 lines · Andy Shevchenko
The struct
group_deschas a lot of duplication with struct pingroup. Deduplicate that by embeddind the latter in the former and convert users.NB. The
function_descis in plan to follow the similar deduplication.This time test-compiled with old GCC 8 for arm64, besides GCC 13 and LLVM 16 for
x86_64.
Applied to my pin control devel branch for v6.8.
Yours,
Linus Walleij