2024-06-11 09:31:59

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 0/4] pinctrl: nuvoton: A few cleanups

Convert Nuvoton drivers to use pin control provided data types
and more of device property APIs.

Not tested.

Andy Shevchenko (4):
pinctrl: nuvoton: Convert to use struct pingroup and
PINCTRL_PINGROUP()
pinctrl: nuvoton: Make use of struct pinfunction and
PINCTRL_PINFUNCTION()
pinctrl: nuvoton: Convert to use struct group_desc
pinctrl: nuvoton: Reduce use of OF-specific APIs

drivers/pinctrl/nuvoton/pinctrl-ma35.c | 116 ++++++++++------------
drivers/pinctrl/nuvoton/pinctrl-ma35d1.c | 1 -
drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c | 43 ++------
drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c | 29 ++----
drivers/pinctrl/nuvoton/pinctrl-wpcm450.c | 11 +-
5 files changed, 71 insertions(+), 129 deletions(-)

--
2.45.2



2024-06-11 09:32:13

by Andy Shevchenko

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

From: Andy Shevchenko <[email protected]>

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

Signed-off-by: Andy Shevchenko <[email protected]>
---
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/nuvoton/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[] = { 9 };

static const int nprd_smi_pins[] = { 190 };

-/*
- * 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
};

-static struct npcm7xx_group npcm7xx_groups[] = {
-#define NPCM7XX_GRP(x) { .name = #x, .pins = x ## _pins, \
- .npins = ARRAY_SIZE(x ## _pins) }
+static struct pingroup npcm7xx_groups[] = {
+#define NPCM7XX_GRP(x) PINCTRL_PINGROUP(#x, x ## _pins, ARRAY_SIZE(x ## _pins))
NPCM7XX_GRPS
#undef NPCM7XX_GRP
};
diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm8xx.c b/drivers/pinctrl/nuvoton/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[] = { 25 };
static const int hgpio6_pins[] = { 59 };
static const int hgpio7_pins[] = { 60 };

-/*
- * 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
};

-static struct npcm8xx_pingroup npcm8xx_pingroups[] = {
-#define NPCM8XX_GRP(x) { .name = #x, .pins = x ## _pins, \
- .npins = ARRAY_SIZE(x ## _pins) }
+static struct pingroup npcm8xx_pingroups[] = {
+#define NPCM8XX_GRP(x) PINCTRL_PINGROUP(#x, x ## _pins, ARRAY_SIZE(x ## _pins))
NPCM8XX_GRPS
#undef NPCM8XX_GRP
};
--
2.45.2


2024-06-11 09:34:48

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 4/4] pinctrl: nuvoton: Reduce use of OF-specific APIs

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 consistency
into the drivers.

Signed-off-by: Andy Shevchenko <[email protected]>
---
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/nuvoton/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 = 0;
bank->irqinten = 0;
bank->chip.label = bank->name;
- bank->chip.of_gpio_n_cells = 2;
bank->chip.parent = &pdev->dev;
bank->chip.request = ma35_gpio_core_to_request;
bank->chip.direction_input = ma35_gpio_core_direction_in;
@@ -976,9 +975,10 @@ static const struct pinconf_ops ma35_pinconf_ops = {
.is_generic = true,
};

-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 = 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;

- count = of_property_count_elems_of_size(np, "nuvoton,pins", sizeof(u32));
+ count = fwnode_property_count_u32(fwnode, "nuvoton,pins");
if (!count || count % 3)
return -EINVAL;

@@ -1000,7 +1000,7 @@ static int ma35_pinctrl_parse_groups(struct device_node *np, struct group_desc *

grp->grp.name = np->name;

- ret = of_property_read_u32_array(np, "nuvoton,pins", elems, count);
+ ret = fwnode_property_read_u32_array(fwnode, "nuvoton,pins", elems, count);
if (ret)
return -EINVAL;
grp->grp.npins = count / 3;
@@ -1027,10 +1027,11 @@ static int ma35_pinctrl_parse_groups(struct device_node *np, struct group_desc *
return 0;
}

-static int ma35_pinctrl_parse_functions(struct device_node *np, struct ma35_pinctrl *npctl,
+static int ma35_pinctrl_parse_functions(struct fwnode_handle *fwnode, struct ma35_pinctrl *npctl,
u32 index)
{
- struct device_node *child;
+ struct device_node *np = 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 device_node *np, struct ma35_pinc
if (!groups)
return -ENOMEM;

- for_each_child_of_node(np, child) {
- groups[i] = child->name;
+ fwnode_for_each_child_node(fwnode, child) {
+ struct device_node *node = to_of_node(child);
+
+ groups[i] = node->name;
grp = &npctl->groups[grp_index++];
ret = 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 device_node *np, struct ma35_pinc

static int ma35_pinctrl_probe_dt(struct platform_device *pdev, struct ma35_pinctrl *npctl)
{
+ struct device *dev = &pdev->dev;
struct fwnode_handle *child;
u32 idx = 0;
int ret;

- 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 += of_get_child_count(to_of_node(child));
}
@@ -1090,11 +1092,8 @@ static int ma35_pinctrl_probe_dt(struct platform_device *pdev, struct ma35_pinct
if (!npctl->groups)
return -ENOMEM;

- device_for_each_child_node(&pdev->dev, child) {
- if (fwnode_property_present(child, "gpio-controller"))
- continue;
-
- ret = ma35_pinctrl_parse_functions(to_of_node(child), npctl, idx++);
+ for_each_gpiochip_node(dev, child) {
+ ret = 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 = info;
npctl->dev = &pdev->dev;

- npctl->regmap = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "nuvoton,sys");
+ npctl->regmap = syscon_regmap_lookup_by_phandle(dev_of_node(dev), "nuvoton,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/nuvoton/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 <linux/io.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
-#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm.h>

diff --git a/drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c b/drivers/pinctrl/nuvoton/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 <linux/interrupt.h>
#include <linux/irq.h>
#include <linux/mfd/syscon.h>
+#include <linux/mod_devicetable.h>
#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_address.h>
-#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include <linux/property.h>
#include <linux/regmap.h>
@@ -1839,15 +1837,7 @@ static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl)
int id = 0;

for_each_gpiochip_node(dev, child) {
- struct device_node *np = to_of_node(child);
-
- ret = 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 = ioremap(res.start, resource_size(&res));
+ pctrl->gpio_bank[id].base = fwnode_iomap(child, 0);
if (!pctrl->gpio_bank[id].base)
return -EINVAL;

@@ -1869,7 +1859,7 @@ static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl)
return ret;
}

- ret = irq_of_parse_and_map(np, 0);
+ ret = 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/nuvoton/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_device *pdev)
platform_set_drvdata(pdev, pctrl);

pctrl->gcr_regmap =
- 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");
--
2.45.2


2024-06-11 09:39:13

by Andy Shevchenko

[permalink] [raw]
Subject: [PATCH v1 2/4] pinctrl: nuvoton: Make use of struct pinfunction and PINCTRL_PINFUNCTION()

From: Andy Shevchenko <[email protected]>

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 <[email protected]>
---
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 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[] = {
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 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[] = {

#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);
@@ -1060,7 +1053,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),
@@ -1282,6 +1276,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 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[] = {

#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.45.2


2024-06-12 04:13:40

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v1 4/4] pinctrl: nuvoton: Reduce use of OF-specific APIs

Hi Andy,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linusw-pinctrl/devel]
[also build test WARNING on linusw-pinctrl/for-next next-20240611]
[cannot apply to linus/master v6.10-rc3]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/pinctrl-nuvoton-Convert-to-use-struct-pingroup-and-PINCTRL_PINGROUP/20240611-173545
base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
patch link: https://lore.kernel.org/r/20240611093127.90210-5-andy.shevchenko%40gmail.com
patch subject: [PATCH v1 4/4] pinctrl: nuvoton: Reduce use of OF-specific APIs
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20240612/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240612/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c: In function 'npcm7xx_gpio_of':
>> drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c:1833:25: warning: unused variable 'res' [-Wunused-variable]
1833 | struct resource res;
| ^~~


vim +/res +1833 drivers/pinctrl/nuvoton/pinctrl-npcm7xx.c

3b588e43ee5c7a Tomer Maimon 2018-08-08 1829
3b588e43ee5c7a Tomer Maimon 2018-08-08 1830 static int npcm7xx_gpio_of(struct npcm7xx_pinctrl *pctrl)
3b588e43ee5c7a Tomer Maimon 2018-08-08 1831 {
3b588e43ee5c7a Tomer Maimon 2018-08-08 1832 int ret = -ENXIO;
3b588e43ee5c7a Tomer Maimon 2018-08-08 @1833 struct resource res;
0173ce55e50800 Andy Shevchenko 2022-04-01 1834 struct device *dev = pctrl->dev;
0173ce55e50800 Andy Shevchenko 2022-04-01 1835 struct fwnode_reference_args args;
0173ce55e50800 Andy Shevchenko 2022-04-01 1836 struct fwnode_handle *child;
0173ce55e50800 Andy Shevchenko 2022-04-01 1837 int id = 0;
0173ce55e50800 Andy Shevchenko 2022-04-01 1838
0173ce55e50800 Andy Shevchenko 2022-04-01 1839 for_each_gpiochip_node(dev, child) {
7123707f39ae24 Andy Shevchenko 2024-06-11 1840 pctrl->gpio_bank[id].base = fwnode_iomap(child, 0);
ad64639417161e Jiasheng Jiang 2023-06-07 1841 if (!pctrl->gpio_bank[id].base)
ad64639417161e Jiasheng Jiang 2023-06-07 1842 return -EINVAL;
3b588e43ee5c7a Tomer Maimon 2018-08-08 1843
0173ce55e50800 Andy Shevchenko 2022-04-01 1844 ret = bgpio_init(&pctrl->gpio_bank[id].gc, dev, 4,
0173ce55e50800 Andy Shevchenko 2022-04-01 1845 pctrl->gpio_bank[id].base + NPCM7XX_GP_N_DIN,
0173ce55e50800 Andy Shevchenko 2022-04-01 1846 pctrl->gpio_bank[id].base + NPCM7XX_GP_N_DOUT,
3b588e43ee5c7a Tomer Maimon 2018-08-08 1847 NULL,
3b588e43ee5c7a Tomer Maimon 2018-08-08 1848 NULL,
0173ce55e50800 Andy Shevchenko 2022-04-01 1849 pctrl->gpio_bank[id].base + NPCM7XX_GP_N_IEM,
3b588e43ee5c7a Tomer Maimon 2018-08-08 1850 BGPIOF_READ_OUTPUT_REG_SET);
3b588e43ee5c7a Tomer Maimon 2018-08-08 1851 if (ret) {
0173ce55e50800 Andy Shevchenko 2022-04-01 1852 dev_err(dev, "bgpio_init() failed\n");
3b588e43ee5c7a Tomer Maimon 2018-08-08 1853 return ret;
3b588e43ee5c7a Tomer Maimon 2018-08-08 1854 }
3b588e43ee5c7a Tomer Maimon 2018-08-08 1855
0173ce55e50800 Andy Shevchenko 2022-04-01 1856 ret = fwnode_property_get_reference_args(child, "gpio-ranges", NULL, 3, 0, &args);
3b588e43ee5c7a Tomer Maimon 2018-08-08 1857 if (ret < 0) {
0173ce55e50800 Andy Shevchenko 2022-04-01 1858 dev_err(dev, "gpio-ranges fail for GPIO bank %u\n", id);
3b588e43ee5c7a Tomer Maimon 2018-08-08 1859 return ret;
3b588e43ee5c7a Tomer Maimon 2018-08-08 1860 }
3b588e43ee5c7a Tomer Maimon 2018-08-08 1861
7123707f39ae24 Andy Shevchenko 2024-06-11 1862 ret = fwnode_irq_get(child, 0);
e804944dcc7799 Krzysztof Kozlowski 2022-04-23 1863 if (!ret) {
0173ce55e50800 Andy Shevchenko 2022-04-01 1864 dev_err(dev, "No IRQ for GPIO bank %u\n", id);
e804944dcc7799 Krzysztof Kozlowski 2022-04-23 1865 return -EINVAL;
0173ce55e50800 Andy Shevchenko 2022-04-01 1866 }
0173ce55e50800 Andy Shevchenko 2022-04-01 1867 pctrl->gpio_bank[id].irq = ret;
0173ce55e50800 Andy Shevchenko 2022-04-01 1868 pctrl->gpio_bank[id].irqbase = id * NPCM7XX_GPIO_PER_BANK;
0173ce55e50800 Andy Shevchenko 2022-04-01 1869 pctrl->gpio_bank[id].pinctrl_id = args.args[0];
0173ce55e50800 Andy Shevchenko 2022-04-01 1870 pctrl->gpio_bank[id].gc.base = args.args[1];
0173ce55e50800 Andy Shevchenko 2022-04-01 1871 pctrl->gpio_bank[id].gc.ngpio = args.args[2];
3b588e43ee5c7a Tomer Maimon 2018-08-08 1872 pctrl->gpio_bank[id].gc.owner = THIS_MODULE;
0173ce55e50800 Andy Shevchenko 2022-04-01 1873 pctrl->gpio_bank[id].gc.parent = dev;
0173ce55e50800 Andy Shevchenko 2022-04-01 1874 pctrl->gpio_bank[id].gc.fwnode = child;
0173ce55e50800 Andy Shevchenko 2022-04-01 1875 pctrl->gpio_bank[id].gc.label = devm_kasprintf(dev, GFP_KERNEL, "%pfw", child);
4be1eaf322f07b Nicholas Mc Guire 2018-11-23 1876 if (pctrl->gpio_bank[id].gc.label == NULL)
4be1eaf322f07b Nicholas Mc Guire 2018-11-23 1877 return -ENOMEM;
4be1eaf322f07b Nicholas Mc Guire 2018-11-23 1878
3b588e43ee5c7a Tomer Maimon 2018-08-08 1879 pctrl->gpio_bank[id].gc.dbg_show = npcmgpio_dbg_show;
0173ce55e50800 Andy Shevchenko 2022-04-01 1880 pctrl->gpio_bank[id].direction_input = pctrl->gpio_bank[id].gc.direction_input;
0173ce55e50800 Andy Shevchenko 2022-04-01 1881 pctrl->gpio_bank[id].gc.direction_input = npcmgpio_direction_input;
0173ce55e50800 Andy Shevchenko 2022-04-01 1882 pctrl->gpio_bank[id].direction_output = pctrl->gpio_bank[id].gc.direction_output;
0173ce55e50800 Andy Shevchenko 2022-04-01 1883 pctrl->gpio_bank[id].gc.direction_output = npcmgpio_direction_output;
0173ce55e50800 Andy Shevchenko 2022-04-01 1884 pctrl->gpio_bank[id].request = pctrl->gpio_bank[id].gc.request;
3b588e43ee5c7a Tomer Maimon 2018-08-08 1885 pctrl->gpio_bank[id].gc.request = npcmgpio_gpio_request;
de38bdbe011b31 Bartosz Golaszewski 2023-10-13 1886 pctrl->gpio_bank[id].gc.free = pinctrl_gpio_free;
3b588e43ee5c7a Tomer Maimon 2018-08-08 1887 id++;
3b588e43ee5c7a Tomer Maimon 2018-08-08 1888 }
3b588e43ee5c7a Tomer Maimon 2018-08-08 1889
3b588e43ee5c7a Tomer Maimon 2018-08-08 1890 pctrl->bank_num = id;
3b588e43ee5c7a Tomer Maimon 2018-08-08 1891 return ret;
3b588e43ee5c7a Tomer Maimon 2018-08-08 1892 }
3b588e43ee5c7a Tomer Maimon 2018-08-08 1893

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-06-14 14:06:11

by J. Neuschäfer

[permalink] [raw]
Subject: Re: [PATCH v1 2/4] pinctrl: nuvoton: Make use of struct pinfunction and PINCTRL_PINFUNCTION()

Hi,

On Tue, Jun 11, 2024 at 12:30:23PM +0300, Andy Shevchenko wrote:
> From: Andy Shevchenko <[email protected]>
>
> 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 <[email protected]>
> ---

Thanks for your patch, it's always good to see code simplifications like this!

Reviewed-by: Jonathan Neuschäfer <[email protected]>

> 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 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[] = {
> 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 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[] = {
>
> #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);
> @@ -1060,7 +1053,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),
> @@ -1282,6 +1276,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 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[] = {
>
> #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.45.2
>