2023-12-04 16:01:39

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 0/5] pinctrl: Use struct pingroup and PINCTRL_PINGROUP()

This is an excerpt from v4 of the "pinctrl: Convert struct group_desc
to use struct pingroup" [1]. The series has been compiled with GCC 8
for ARM64 besides x86_64 GCC 13 and LLVM 16.

Changelog to the mother series [1]:
- added a new patch against Renesas code, so no warnings will be seen

Link: https://lore.kernel.org/r/[email protected] [1]

Andy Shevchenko (5):
pinctrl: renesas: Mark local variable with const in ->set_mux()
pinctrl: core: Make pins const unsigned int pointer in struct
group_desc
pinctrl: equilibrium: Convert to use struct pingroup
pinctrl: keembay: Convert to use struct pingroup
pinctrl: nuvoton: Convert to use struct pingroup and
PINCTRL_PINGROUP()

drivers/pinctrl/core.c | 2 +-
drivers/pinctrl/core.h | 4 ++--
drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 9 ++++----
drivers/pinctrl/pinctrl-equilibrium.c | 26 +++++++++++------------
drivers/pinctrl/pinctrl-keembay.c | 4 ++--
drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-
drivers/pinctrl/renesas/pinctrl-rzv2m.c | 2 +-
7 files changed, 24 insertions(+), 25 deletions(-)

--
2.43.0.rc1.1.gbec44491f096


2023-12-04 16:02:43

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 2/5] pinctrl: core: Make pins const unsigned int pointer in struct group_desc

It's unclear why it's not a const unsigned int pointer from day 1.
Make the pins member const unsigned int pointer in struct group_desc.
Update necessary APIs.

Reviewed-by: Geert Uytterhoeven <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/pinctrl/core.c | 2 +-
drivers/pinctrl/core.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 12daf0bb091e..6380e1fa6509 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -640,7 +640,7 @@ static int pinctrl_generic_group_name_to_selector(struct pinctrl_dev *pctldev,
* Note that the caller must take care of locking.
*/
int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
- int *pins, int num_pins, void *data)
+ const unsigned int *pins, int num_pins, void *data)
{
struct group_desc *group;
int selector, error;
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h
index 8b59dd72e4ff..8ef4b536bca5 100644
--- a/drivers/pinctrl/core.h
+++ b/drivers/pinctrl/core.h
@@ -203,7 +203,7 @@ struct pinctrl_maps {
*/
struct group_desc {
const char *name;
- int *pins;
+ const unsigned int *pins;
int num_pins;
void *data;
};
@@ -222,7 +222,7 @@ struct group_desc *pinctrl_generic_get_group(struct pinctrl_dev *pctldev,
unsigned int group_selector);

int pinctrl_generic_add_group(struct pinctrl_dev *pctldev, const char *name,
- int *gpins, int ngpins, void *data);
+ const unsigned int *pins, int num_pins, void *data);

int pinctrl_generic_remove_group(struct pinctrl_dev *pctldev,
unsigned int group_selector);
--
2.43.0.rc1.1.gbec44491f096

2023-12-04 16:02:52

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 3/5] pinctrl: equilibrium: Convert to use struct pingroup

The pin control header provides struct pingroup.
Utilize it instead of open coded variants in the driver.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/pinctrl/pinctrl-equilibrium.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-equilibrium.c b/drivers/pinctrl/pinctrl-equilibrium.c
index fd59cfdeefac..4ebae516d1b1 100644
--- a/drivers/pinctrl/pinctrl-equilibrium.c
+++ b/drivers/pinctrl/pinctrl-equilibrium.c
@@ -705,7 +705,7 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
struct device *dev = drvdata->dev;
struct device_node *node = dev->of_node;
unsigned int *pins, *pinmux, pin_id, pinmux_id;
- struct group_desc group;
+ struct pingroup group, *grp = &group;
struct device_node *np;
struct property *prop;
int j, err;
@@ -721,49 +721,49 @@ static int eqbr_build_groups(struct eqbr_pinctrl_drv_data *drvdata)
of_node_put(np);
return err;
}
- group.num_pins = err;
- group.name = prop->value;
- pins = devm_kcalloc(dev, group.num_pins, sizeof(*pins), GFP_KERNEL);
+ grp->npins = err;
+ grp->name = prop->value;
+ pins = devm_kcalloc(dev, grp->npins, sizeof(*pins), GFP_KERNEL);
if (!pins) {
of_node_put(np);
return -ENOMEM;
}
- group.pins = pins;
+ grp->pins = pins;

- pinmux = devm_kcalloc(dev, group.num_pins, sizeof(*pinmux), GFP_KERNEL);
+ pinmux = devm_kcalloc(dev, grp->npins, sizeof(*pinmux), GFP_KERNEL);
if (!pinmux) {
of_node_put(np);
return -ENOMEM;
}

- for (j = 0; j < group.num_pins; j++) {
+ for (j = 0; j < grp->npins; j++) {
if (of_property_read_u32_index(np, "pins", j, &pin_id)) {
dev_err(dev, "Group %s: Read intel pins id failed\n",
- group.name);
+ grp->name);
of_node_put(np);
return -EINVAL;
}
if (pin_id >= drvdata->pctl_desc.npins) {
dev_err(dev, "Group %s: Invalid pin ID, idx: %d, pin %u\n",
- group.name, j, pin_id);
+ grp->name, j, pin_id);
of_node_put(np);
return -EINVAL;
}
pins[j] = pin_id;
if (of_property_read_u32_index(np, "pinmux", j, &pinmux_id)) {
dev_err(dev, "Group %s: Read intel pinmux id failed\n",
- group.name);
+ grp->name);
of_node_put(np);
return -EINVAL;
}
pinmux[j] = pinmux_id;
}

- err = pinctrl_generic_add_group(drvdata->pctl_dev, group.name,
- group.pins, group.num_pins,
+ err = pinctrl_generic_add_group(drvdata->pctl_dev,
+ grp->name, grp->pins, grp->npins,
pinmux);
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);
of_node_put(np);
return err;
}
--
2.43.0.rc1.1.gbec44491f096

2023-12-04 16:02:59

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 4/5] pinctrl: keembay: Convert to use struct pingroup

The pin control header provides struct pingroup.
Utilize it instead of open coded variants in the driver.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/pinctrl/pinctrl-keembay.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-keembay.c b/drivers/pinctrl/pinctrl-keembay.c
index 152c35bce8ec..87d328853ae4 100644
--- a/drivers/pinctrl/pinctrl-keembay.c
+++ b/drivers/pinctrl/pinctrl-keembay.c
@@ -1517,7 +1517,7 @@ static int keembay_gpiochip_probe(struct keembay_pinctrl *kpc,

static int keembay_build_groups(struct keembay_pinctrl *kpc)
{
- struct group_desc *grp;
+ struct pingroup *grp;
unsigned int i;

kpc->ngroups = kpc->npins;
@@ -1528,7 +1528,7 @@ static int keembay_build_groups(struct keembay_pinctrl *kpc)
/* Each pin is categorised as one group */
for (i = 0; i < kpc->ngroups; i++) {
const struct pinctrl_pin_desc *pdesc = keembay_pins + i;
- struct group_desc *kmb_grp = grp + i;
+ struct pingroup *kmb_grp = grp + i;

kmb_grp->name = pdesc->name;
kmb_grp->pins = (int *)&pdesc->number;
--
2.43.0.rc1.1.gbec44491f096

2023-12-04 16:03:01

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 1/5] pinctrl: renesas: Mark local variable with const in ->set_mux()

We are not going to change pins in the ->set_mux() callback. Mark
the local variable with a const qualifier. While at it, make it
also unsigned.

Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/pinctrl/renesas/pinctrl-rzg2l.c | 2 +-
drivers/pinctrl/renesas/pinctrl-rzv2m.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pinctrl/renesas/pinctrl-rzg2l.c b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
index aed59c53207c..68fcc2a4efbc 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzg2l.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzg2l.c
@@ -273,7 +273,7 @@ static int rzg2l_pinctrl_set_mux(struct pinctrl_dev *pctldev,
struct function_desc *func;
unsigned int i, *psel_val;
struct group_desc *group;
- int *pins;
+ const unsigned int *pins;

func = pinmux_generic_get_function(pctldev, func_selector);
if (!func)
diff --git a/drivers/pinctrl/renesas/pinctrl-rzv2m.c b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
index 21d7d5ac8c4a..eb304fab1796 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzv2m.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzv2m.c
@@ -165,7 +165,7 @@ static int rzv2m_pinctrl_set_mux(struct pinctrl_dev *pctldev,
struct function_desc *func;
unsigned int i, *psel_val;
struct group_desc *group;
- int *pins;
+ const unsigned int *pins;

func = pinmux_generic_get_function(pctldev, func_selector);
if (!func)
--
2.43.0.rc1.1.gbec44491f096

2023-12-04 16:08:15

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 5/5] pinctrl: nuvoton: Convert to use struct pingroup and PINCTRL_PINGROUP()

The pin control header provides struct pingroup and PINCTRL_PINGROUP() macro.
Utilize them instead of open coded variants in the driver.

Reviewed-by: Jonathan Neuschäfer <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
---
drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
index 0cff44b07b29..4589900244c7 100644
--- a/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
+++ b/drivers/pinctrl/nuvoton/pinctrl-wpcm450.c
@@ -474,9 +474,8 @@ enum {
#undef WPCM450_GRP
};

-static struct group_desc wpcm450_groups[] = {
-#define WPCM450_GRP(x) { .name = #x, .pins = x ## _pins, \
- .num_pins = ARRAY_SIZE(x ## _pins) }
+static struct pingroup wpcm450_groups[] = {
+#define WPCM450_GRP(x) PINCTRL_PINGROUP(#x, x ## _pins, ARRAY_SIZE(x ## _pins))
WPCM450_GRPS
#undef WPCM450_GRP
};
@@ -852,7 +851,7 @@ static int wpcm450_get_group_pins(struct pinctrl_dev *pctldev,
const unsigned int **pins,
unsigned int *npins)
{
- *npins = wpcm450_groups[selector].num_pins;
+ *npins = wpcm450_groups[selector].npins;
*pins = wpcm450_groups[selector].pins;

return 0;
@@ -901,7 +900,7 @@ static int wpcm450_pinmux_set_mux(struct pinctrl_dev *pctldev,
struct wpcm450_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev);

wpcm450_setfunc(pctrl->gcr_regmap, wpcm450_groups[group].pins,
- wpcm450_groups[group].num_pins, function);
+ wpcm450_groups[group].npins, function);

return 0;
}
--
2.43.0.rc1.1.gbec44491f096

2023-12-04 16:19:21

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH v1 1/5] pinctrl: renesas: Mark local variable with const in ->set_mux()

On Mon, Dec 4, 2023 at 5:02 PM Andy Shevchenko
<[email protected]> wrote:
> We are not going to change pins in the ->set_mux() callback. Mark
> the local variable with a const qualifier. While at it, make it
> also unsigned.
>
> Signed-off-by: Andy Shevchenko <[email protected]>

Reviewed-by: Geert Uytterhoeven <[email protected]>
Acked-by: Geert Uytterhoeven <[email protected]>

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

2023-12-07 09:55:09

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v1 0/5] pinctrl: Use struct pingroup and PINCTRL_PINGROUP()

On Mon, Dec 4, 2023 at 5:00 PM Andy Shevchenko
<[email protected]> wrote:

> This is an excerpt from v4 of the "pinctrl: Convert struct group_desc
> to use struct pingroup" [1]. The series has been compiled with GCC 8
> for ARM64 besides x86_64 GCC 13 and LLVM 16.
>
> Changelog to the mother series [1]:
> - added a new patch against Renesas code, so no warnings will be seen

Patches applied!

Yours,
Linus Walleij

2023-12-07 12:37:46

by Andy Shevchenko

[permalink] [raw]
Subject: Re: [PATCH v1 0/5] pinctrl: Use struct pingroup and PINCTRL_PINGROUP()

On Thu, Dec 07, 2023 at 10:54:58AM +0100, Linus Walleij wrote:
> On Mon, Dec 4, 2023 at 5:00 PM Andy Shevchenko
> <[email protected]> wrote:
>
> > This is an excerpt from v4 of the "pinctrl: Convert struct group_desc
> > to use struct pingroup" [1]. The series has been compiled with GCC 8
> > for ARM64 besides x86_64 GCC 13 and LLVM 16.
> >
> > Changelog to the mother series [1]:
> > - added a new patch against Renesas code, so no warnings will be seen
>
> Patches applied!

Thank you!
I will send the rest after this part appears in Linux Next.

--
With Best Regards,
Andy Shevchenko