* [PATCH v1 1/1] pinctrl: pinconf-generic: Use only fwnode API in parse_dt_cfg()
@ 2026-03-05 9:50 Andy Shevchenko
2026-03-10 9:19 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2026-03-05 9:50 UTC (permalink / raw)
To: Linus Walleij, linux-gpio, linux-kernel; +Cc: Andy Shevchenko
The parse_dt_cfg() uses OF and fwnode APIs. Fix this inconsistency by
fully switching it to use fwnode API and rename the function accordingly.
While at it, add missing linux/property.h inclusion.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/pinctrl/pinconf-generic.c | 34 ++++++++++++++++---------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index 7929127c8839..61b5b3fb94ce 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -16,6 +16,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/property.h>
#include <linux/slab.h>
#include <linux/seq_file.h>
@@ -205,19 +206,19 @@ static const struct pinconf_generic_params dt_params[] = {
};
/**
- * parse_dt_cfg() - Parse DT pinconf parameters
- * @np: DT node
+ * parse_fw_cfg() - Parse firmware pinconf parameters
+ * @fwnode: firmware node
* @params: Array of describing generic parameters
* @count: Number of entries in @params
* @cfg: Array of parsed config options
* @ncfg: Number of entries in @cfg
*
- * Parse the config options described in @params from @np and puts the result
+ * Parse the config options described in @params from @fwnode and puts the result
* in @cfg. @cfg does not need to be empty, entries are added beginning at
* @ncfg. @ncfg is updated to reflect the number of entries after parsing. @cfg
* needs to have enough memory allocated to hold all possible entries.
*/
-static int parse_dt_cfg(struct device_node *np,
+static int parse_fw_cfg(struct fwnode_handle *fwnode,
const struct pinconf_generic_params *params,
unsigned int count, unsigned long *cfg,
unsigned int *ncfg)
@@ -233,7 +234,7 @@ static int parse_dt_cfg(struct device_node *np,
const struct pinconf_generic_params *par = ¶ms[i];
if (par->values && par->num_values) {
- ret = fwnode_property_match_property_string(of_fwnode_handle(np),
+ ret = fwnode_property_match_property_string(fwnode,
par->property,
par->values, par->num_values);
if (ret == -ENOENT)
@@ -243,7 +244,7 @@ static int parse_dt_cfg(struct device_node *np,
ret = 0;
}
} else {
- ret = of_property_read_u32(np, par->property, &val);
+ ret = fwnode_property_read_u32(fwnode, par->property, &val);
}
/* property not found */
@@ -258,8 +259,8 @@ static int parse_dt_cfg(struct device_node *np,
if (par->param <= count) {
ret = test_and_set_bit(par->param, properties);
if (ret) {
- pr_err("%s: conflicting setting detected for %s\n",
- np->name, par->property);
+ pr_err("%pfw: conflicting setting detected for %s\n",
+ fwnode, par->property);
bitmap_free(properties);
return -EINVAL;
}
@@ -272,8 +273,8 @@ static int parse_dt_cfg(struct device_node *np,
if (test_bit(PIN_CONFIG_DRIVE_STRENGTH, properties) &&
test_bit(PIN_CONFIG_DRIVE_STRENGTH_UA, properties))
- pr_err("%s: cannot have multiple drive strength properties\n",
- np->name);
+ pr_err("%pfw: cannot have multiple drive strength properties\n",
+ fwnode);
test = test_bit(PIN_CONFIG_BIAS_BUS_HOLD, properties) +
test_bit(PIN_CONFIG_BIAS_DISABLE, properties) +
@@ -282,15 +283,15 @@ static int parse_dt_cfg(struct device_node *np,
test_bit(PIN_CONFIG_BIAS_PULL_PIN_DEFAULT, properties) +
test_bit(PIN_CONFIG_BIAS_PULL_DOWN, properties);
if (test > 1)
- pr_err("%s: cannot have multiple bias configurations\n",
- np->name);
+ pr_err("%pfw: cannot have multiple bias configurations\n",
+ fwnode);
test = test_bit(PIN_CONFIG_DRIVE_OPEN_DRAIN, properties) +
test_bit(PIN_CONFIG_DRIVE_OPEN_SOURCE, properties) +
test_bit(PIN_CONFIG_DRIVE_PUSH_PULL, properties);
if (test > 1)
- pr_err("%s: cannot have multiple drive configurations\n",
- np->name);
+ pr_err("%pfw: cannot have multiple drive configurations\n",
+ fwnode);
bitmap_free(properties);
return 0;
@@ -371,6 +372,7 @@ int pinconf_generic_parse_dt_config(struct device_node *np,
unsigned long **configs,
unsigned int *nconfigs)
{
+ struct fwnode_handle *fwnode = of_fwnode_handle(np);
unsigned long *cfg;
unsigned int max_cfg, ncfg = 0;
int ret;
@@ -386,12 +388,12 @@ int pinconf_generic_parse_dt_config(struct device_node *np,
if (!cfg)
return -ENOMEM;
- ret = parse_dt_cfg(np, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
+ ret = parse_fw_cfg(fwnode, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
if (ret)
goto out;
if (pctldev && pctldev->desc->num_custom_params &&
pctldev->desc->custom_params) {
- ret = parse_dt_cfg(np, pctldev->desc->custom_params,
+ ret = parse_fw_cfg(fwnode, pctldev->desc->custom_params,
pctldev->desc->num_custom_params, cfg, &ncfg);
if (ret)
goto out;
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v1 1/1] pinctrl: pinconf-generic: Use only fwnode API in parse_dt_cfg()
2026-03-05 9:50 [PATCH v1 1/1] pinctrl: pinconf-generic: Use only fwnode API in parse_dt_cfg() Andy Shevchenko
@ 2026-03-10 9:19 ` Linus Walleij
2026-03-17 8:28 ` Andy Shevchenko
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2026-03-10 9:19 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-gpio, linux-kernel
On Thu, Mar 5, 2026 at 10:50 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> The parse_dt_cfg() uses OF and fwnode APIs. Fix this inconsistency by
> fully switching it to use fwnode API and rename the function accordingly.
>
> While at it, add missing linux/property.h inclusion.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Patch applied, because obviously the kernel looks better after
this patch than before it.
I had to rebase the last hunk of changes manually.
I think there is something more to do, but you probably
already have a plan:
> - ret = parse_dt_cfg(np, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
> + ret = parse_fw_cfg(fwnode, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
and that uses:
#ifdef CONFIG_OF
static const struct pinconf_generic_params dt_params[] = {
{ "bias-bus-hold", PIN_CONFIG_BIAS_BUS_HOLD, 0 },
{ "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
Are you already working on a patch? ;)
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1 1/1] pinctrl: pinconf-generic: Use only fwnode API in parse_dt_cfg()
2026-03-10 9:19 ` Linus Walleij
@ 2026-03-17 8:28 ` Andy Shevchenko
0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2026-03-17 8:28 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-gpio, linux-kernel
On Tue, Mar 10, 2026 at 10:19:40AM +0100, Linus Walleij wrote:
> On Thu, Mar 5, 2026 at 10:50 AM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
>
> > The parse_dt_cfg() uses OF and fwnode APIs. Fix this inconsistency by
> > fully switching it to use fwnode API and rename the function accordingly.
> >
> > While at it, add missing linux/property.h inclusion.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>
> Patch applied, because obviously the kernel looks better after
> this patch than before it.
>
> I had to rebase the last hunk of changes manually.
>
> I think there is something more to do, but you probably
> already have a plan:
>
> > - ret = parse_dt_cfg(np, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
> > + ret = parse_fw_cfg(fwnode, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
>
> and that uses:
>
> #ifdef CONFIG_OF
> static const struct pinconf_generic_params dt_params[] = {
> { "bias-bus-hold", PIN_CONFIG_BIAS_BUS_HOLD, 0 },
> { "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
Yes, this all is still OF-centric code. The patch was solely for bringing a bit
of consistency into one (parse_fw_cfg()) function. For now not much plans are here
because ACPI case most likely will require something totally (with the reuse of
the opaque pointers to the mappings, though) different.
> Are you already working on a patch? ;)
Actually I found one improvement I need to submit.
And looking now at pinconf_generic_parse_dt_pinmux() it also can be translated
to fwnode inside.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-17 8:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 9:50 [PATCH v1 1/1] pinctrl: pinconf-generic: Use only fwnode API in parse_dt_cfg() Andy Shevchenko
2026-03-10 9:19 ` Linus Walleij
2026-03-17 8:28 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox