Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] pinctrl: scmi: Replace get function and group info with generic callbacks
@ 2026-09-17 22:55 Alex Tran
  2026-09-17 22:55 ` [PATCH v2 1/3] pinctrl: scmi: Replace pinmux ops get function info with generics Alex Tran
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Alex Tran @ 2026-09-17 22:55 UTC (permalink / raw)
  To: Sudeep Holla, Cristian Marussi, Linus Walleij
  Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel, Alex Tran

This series refactors the SCMI pinctrl driver to eliminate metadata
getter callbacks to be replaced with pinctrl and pinmux generics
provided by the pinctrl core.

Previously, the driver implemented its own get_functions_count,
get_function_name, get_function_groups, get_groups_count,
get_group_name, and get_group_pins callbacks, which required
maintaining driver metadata like the functions and count.

The pinctrl core already has support to store and manage this
topology in the pinctrl_dev via its own internal radix trees.
By registering functions and groups at probe time using
pinmux_generic_add_function and pinctrl_generic_add_group, the
driver can delegate group and function metadata management to
the core.

Signed-off-by: Alex Tran <alex.tran@oss.qualcomm.com>
---
Changes in v2:
- Add patch to select generic pinmux and pinctrl Kconfig symbols when PINCTRL_SCMI is selected
- Remove duplication of pins array while registering generic groups
- Check for duplicate function and group name during generic registration
- Allow functions with 0 groups and groups with 0 pins to be registered during probe but issue warning
- Link to v1: https://patch.msgid.link/20260731-scmi-pinctrl-generics-v1-0-8affd2b79a6b@oss.qualcomm.com

To: Sudeep Holla <sudeep.holla@kernel.org>
To: Cristian Marussi <cristian.marussi@arm.com>
To: Linus Walleij <linusw@kernel.org>
Cc: arm-scmi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

---
Alex Tran (3):
      pinctrl: scmi: Replace pinmux ops get function info with generics
      pinctrl: scmi: Replace pinctrl ops get group info with generics
      pinctrl: kconfig: Select generic pinctrl helpers for scmi pinctrl

 drivers/pinctrl/Kconfig        |   2 +
 drivers/pinctrl/pinctrl-scmi.c | 232 +++++++++++++++++++----------------------
 2 files changed, 108 insertions(+), 126 deletions(-)
---
base-commit: 48a5a7ab8d6ab7090564339e039c421f315de912
change-id: 20260724-scmi-pinctrl-generics-746484c98b66

Best regards,
--  
Alex Tran <alex.tran@oss.qualcomm.com>



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] pinctrl: scmi: Replace pinmux ops get function info with generics
  2026-09-17 22:55 [PATCH v2 0/3] pinctrl: scmi: Replace get function and group info with generic callbacks Alex Tran
@ 2026-09-17 22:55 ` Alex Tran
  2026-10-01 15:03   ` Sudeep Holla
  2026-09-17 22:55 ` [PATCH v2 2/3] pinctrl: scmi: Replace pinctrl ops get group " Alex Tran
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Alex Tran @ 2026-09-17 22:55 UTC (permalink / raw)
  To: Sudeep Holla, Cristian Marussi, Linus Walleij
  Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel, Alex Tran

During probe, populate the pinctrl device with function info
so that the generic callbacks can be used to fetch function
count, name, and groups. Remove locally stored functions
since caching them in this driver is no longer needed.

Signed-off-by: Alex Tran <alex.tran@oss.qualcomm.com>
---
 drivers/pinctrl/pinctrl-scmi.c | 151 +++++++++++++++++------------------------
 1 file changed, 61 insertions(+), 90 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index 1bb36ca477b7..1d85a16f300d 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -24,6 +24,7 @@
 #include "pinctrl-utils.h"
 #include "core.h"
 #include "pinconf.h"
+#include "pinmux.h"
 
 #define DRV_NAME "scmi-pinctrl"
 
@@ -37,8 +38,6 @@ struct scmi_pinctrl {
 	struct scmi_protocol_handle *ph;
 	struct pinctrl_dev *pctldev;
 	struct pinctrl_desc pctl_desc;
-	struct pinfunction *functions;
-	unsigned int nr_functions;
 };
 
 static int pinctrl_scmi_get_groups_count(struct pinctrl_dev *pctldev)
@@ -84,86 +83,6 @@ static const struct pinctrl_ops pinctrl_scmi_pinctrl_ops = {
 #endif
 };
 
-static int pinctrl_scmi_get_functions_count(struct pinctrl_dev *pctldev)
-{
-	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
-
-	return pinctrl_ops->count_get(pmx->ph, FUNCTION_TYPE);
-}
-
-static const char *pinctrl_scmi_get_function_name(struct pinctrl_dev *pctldev,
-						  unsigned int selector)
-{
-	int ret;
-	const char *name;
-	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
-
-	ret = pinctrl_ops->name_get(pmx->ph, selector, FUNCTION_TYPE, &name);
-	if (ret) {
-		dev_err(pmx->dev, "get name failed with err %d", ret);
-		return NULL;
-	}
-
-	return name;
-}
-
-static int pinctrl_scmi_get_function_groups(struct pinctrl_dev *pctldev,
-					    unsigned int selector,
-					    const char * const **p_groups,
-					    unsigned int * const p_num_groups)
-{
-	struct pinfunction *func;
-	const unsigned int *group_ids;
-	unsigned int num_groups;
-	const char **groups;
-	int ret, i;
-	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
-
-	if (!p_groups || !p_num_groups)
-		return -EINVAL;
-
-	if (selector >= pmx->nr_functions)
-		return -EINVAL;
-
-	func = &pmx->functions[selector];
-	if (func->ngroups)
-		goto done;
-
-	ret = pinctrl_ops->function_groups_get(pmx->ph, selector, &num_groups,
-					       &group_ids);
-	if (ret) {
-		dev_err(pmx->dev, "Unable to get function groups, err %d", ret);
-		return ret;
-	}
-	if (!num_groups)
-		return -EINVAL;
-
-	groups = kcalloc(num_groups, sizeof(*groups), GFP_KERNEL);
-	if (!groups)
-		return -ENOMEM;
-
-	for (i = 0; i < num_groups; i++) {
-		groups[i] = pinctrl_scmi_get_group_name(pctldev, group_ids[i]);
-		if (!groups[i]) {
-			ret = -EINVAL;
-			goto err_free;
-		}
-	}
-
-	func->ngroups = num_groups;
-	func->groups = groups;
-done:
-	*p_groups = func->groups;
-	*p_num_groups = func->ngroups;
-
-	return 0;
-
-err_free:
-	kfree(groups);
-
-	return ret;
-}
-
 static int pinctrl_scmi_func_set_mux(struct pinctrl_dev *pctldev,
 				     unsigned int selector, unsigned int group)
 {
@@ -190,9 +109,9 @@ static int pinctrl_scmi_free(struct pinctrl_dev *pctldev, unsigned int offset)
 static const struct pinmux_ops pinctrl_scmi_pinmux_ops = {
 	.request = pinctrl_scmi_request,
 	.free = pinctrl_scmi_free,
-	.get_functions_count = pinctrl_scmi_get_functions_count,
-	.get_function_name = pinctrl_scmi_get_function_name,
-	.get_function_groups = pinctrl_scmi_get_function_groups,
+	.get_functions_count = pinmux_generic_get_function_count,
+	.get_function_name = pinmux_generic_get_function_name,
+	.get_function_groups = pinmux_generic_get_function_groups,
 	.set_mux = pinctrl_scmi_func_set_mux,
 };
 
@@ -487,6 +406,60 @@ static const struct pinconf_ops pinctrl_scmi_pinconf_ops = {
 	.pin_config_config_dbg_show = pinconf_generic_dump_config,
 };
 
+static int pinctrl_scmi_get_functions(struct scmi_pinctrl *pmx)
+{
+	unsigned int nr_funcs, nr_groups, i, j;
+	const unsigned int *group_ids;
+	const char *fname;
+	const char **gnames;
+	int ret;
+
+	nr_funcs = pinctrl_ops->count_get(pmx->ph, FUNCTION_TYPE);
+
+	for (i = 0; i < nr_funcs; i++) {
+		ret = pinctrl_ops->name_get(pmx->ph, i, FUNCTION_TYPE,
+					    &fname);
+		if (ret)
+			return ret;
+
+		ret = pinctrl_ops->function_groups_get(pmx->ph, i,
+						       &nr_groups,
+						       &group_ids);
+		if (ret)
+			return ret;
+
+		if (!nr_groups)
+			dev_warn(pmx->dev,
+				 "Function %s contains no groups\n",
+				 fname);
+
+		gnames = devm_kmalloc_array(pmx->dev, nr_groups,
+					    sizeof(*gnames), GFP_KERNEL);
+		if (!gnames)
+			return -ENOMEM;
+
+		for (j = 0; j < nr_groups; j++) {
+			ret = pinctrl_ops->name_get(pmx->ph, group_ids[j],
+						    GROUP_TYPE, &gnames[j]);
+			if (ret)
+				return ret;
+		}
+
+		ret = pinmux_generic_add_function(pmx->pctldev, fname, gnames,
+				  nr_groups, NULL);
+		if (ret < 0)
+			return ret;
+		if (ret != i) {
+			dev_err(pmx->dev,
+				"Duplicate function name: %s index: %u selector: %d\n",
+				fname, i, ret);
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
 static int pinctrl_scmi_get_pins(struct scmi_pinctrl *pmx,
 				 struct pinctrl_desc *desc)
 {
@@ -571,11 +544,9 @@ static int scmi_pinctrl_probe(struct scmi_device *sdev)
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to register pinctrl\n");
 
-	pmx->nr_functions = pinctrl_scmi_get_functions_count(pmx->pctldev);
-	pmx->functions = devm_kcalloc(dev, pmx->nr_functions,
-				      sizeof(*pmx->functions), GFP_KERNEL);
-	if (!pmx->functions)
-		return -ENOMEM;
+	ret = pinctrl_scmi_get_functions(pmx);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to register functions\n");
 
 	return pinctrl_enable(pmx->pctldev);
 }

-- 
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] pinctrl: scmi: Replace pinctrl ops get group info with generics
  2026-09-17 22:55 [PATCH v2 0/3] pinctrl: scmi: Replace get function and group info with generic callbacks Alex Tran
  2026-09-17 22:55 ` [PATCH v2 1/3] pinctrl: scmi: Replace pinmux ops get function info with generics Alex Tran
@ 2026-09-17 22:55 ` Alex Tran
  2026-10-01 15:18   ` Sudeep Holla
  2026-09-17 22:55 ` [PATCH v2 3/3] pinctrl: kconfig: Select generic pinctrl helpers for scmi pinctrl Alex Tran
  2026-10-07  6:48 ` [PATCH v2 0/3] pinctrl: scmi: Replace get function and group info with generic callbacks Linus Walleij
  3 siblings, 1 reply; 8+ messages in thread
From: Alex Tran @ 2026-09-17 22:55 UTC (permalink / raw)
  To: Sudeep Holla, Cristian Marussi, Linus Walleij
  Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel, Alex Tran

During probe, populate the pinctrl device with group info
so that the generic callbacks can be used to fetch group
count, name, and pins.

Signed-off-by: Alex Tran <alex.tran@oss.qualcomm.com>
---
 drivers/pinctrl/pinctrl-scmi.c | 81 +++++++++++++++++++++++-------------------
 1 file changed, 45 insertions(+), 36 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
index 1d85a16f300d..c93d61dfa282 100644
--- a/drivers/pinctrl/pinctrl-scmi.c
+++ b/drivers/pinctrl/pinctrl-scmi.c
@@ -40,43 +40,10 @@ struct scmi_pinctrl {
 	struct pinctrl_desc pctl_desc;
 };
 
-static int pinctrl_scmi_get_groups_count(struct pinctrl_dev *pctldev)
-{
-	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
-
-	return pinctrl_ops->count_get(pmx->ph, GROUP_TYPE);
-}
-
-static const char *pinctrl_scmi_get_group_name(struct pinctrl_dev *pctldev,
-					       unsigned int selector)
-{
-	int ret;
-	const char *name;
-	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
-
-	ret = pinctrl_ops->name_get(pmx->ph, selector, GROUP_TYPE, &name);
-	if (ret) {
-		dev_err(pmx->dev, "get name failed with err %d", ret);
-		return NULL;
-	}
-
-	return name;
-}
-
-static int pinctrl_scmi_get_group_pins(struct pinctrl_dev *pctldev,
-				       unsigned int selector,
-				       const unsigned int **pins,
-				       unsigned int *num_pins)
-{
-	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
-
-	return pinctrl_ops->group_pins_get(pmx->ph, selector, pins, num_pins);
-}
-
 static const struct pinctrl_ops pinctrl_scmi_pinctrl_ops = {
-	.get_groups_count = pinctrl_scmi_get_groups_count,
-	.get_group_name = pinctrl_scmi_get_group_name,
-	.get_group_pins = pinctrl_scmi_get_group_pins,
+	.get_groups_count = pinctrl_generic_get_group_count,
+	.get_group_name = pinctrl_generic_get_group_name,
+	.get_group_pins = pinctrl_generic_get_group_pins,
 #ifdef CONFIG_OF
 	.dt_node_to_map = pinconf_generic_dt_node_to_map_all,
 	.dt_free_map = pinconf_generic_dt_free_map,
@@ -460,6 +427,44 @@ static int pinctrl_scmi_get_functions(struct scmi_pinctrl *pmx)
 	return 0;
 }
 
+static int pinctrl_scmi_get_groups(struct scmi_pinctrl *pmx)
+{
+	unsigned int nr_groups, nr_pins, i;
+	const unsigned int *pins;
+	const char *gname;
+	int ret;
+
+	nr_groups = pinctrl_ops->count_get(pmx->ph, GROUP_TYPE);
+
+	for (i = 0; i < nr_groups; i++) {
+		ret = pinctrl_ops->name_get(pmx->ph, i, GROUP_TYPE, &gname);
+		if (ret)
+			return ret;
+
+		ret = pinctrl_ops->group_pins_get(pmx->ph, i, &pins,
+						  &nr_pins);
+		if (ret)
+			return ret;
+
+		if (!nr_pins)
+			dev_warn(pmx->dev,
+				 "Group %s contains no pins\n", gname);
+
+		ret = pinctrl_generic_add_group(pmx->pctldev, gname, pins,
+						nr_pins, NULL);
+		if (ret < 0)
+			return ret;
+		if (ret != i) {
+			dev_err(pmx->dev,
+				"Duplicate group name: %s index: %u selector: %d\n",
+				gname, i, ret);
+			return -EINVAL;
+		}
+	}
+
+	return 0;
+}
+
 static int pinctrl_scmi_get_pins(struct scmi_pinctrl *pmx,
 				 struct pinctrl_desc *desc)
 {
@@ -544,6 +549,10 @@ static int scmi_pinctrl_probe(struct scmi_device *sdev)
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to register pinctrl\n");
 
+	ret = pinctrl_scmi_get_groups(pmx);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to register groups\n");
+
 	ret = pinctrl_scmi_get_functions(pmx);
 	if (ret)
 		return dev_err_probe(dev, ret, "Failed to register functions\n");

-- 
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] pinctrl: kconfig: Select generic pinctrl helpers for scmi pinctrl
  2026-09-17 22:55 [PATCH v2 0/3] pinctrl: scmi: Replace get function and group info with generic callbacks Alex Tran
  2026-09-17 22:55 ` [PATCH v2 1/3] pinctrl: scmi: Replace pinmux ops get function info with generics Alex Tran
  2026-09-17 22:55 ` [PATCH v2 2/3] pinctrl: scmi: Replace pinctrl ops get group " Alex Tran
@ 2026-09-17 22:55 ` Alex Tran
  2026-10-01 15:19   ` Sudeep Holla
  2026-10-07  6:48 ` [PATCH v2 0/3] pinctrl: scmi: Replace get function and group info with generic callbacks Linus Walleij
  3 siblings, 1 reply; 8+ messages in thread
From: Alex Tran @ 2026-09-17 22:55 UTC (permalink / raw)
  To: Sudeep Holla, Cristian Marussi, Linus Walleij
  Cc: arm-scmi, linux-arm-kernel, linux-gpio, linux-kernel, Alex Tran

Select the corresponding pinctrl and pinmux generic Kconfig symbols
when PINCTRL_SCMI is enabled.

Signed-off-by: Alex Tran <alex.tran@oss.qualcomm.com>
---
 drivers/pinctrl/Kconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig
index c2cdd7b2c49b..c93f0bfcd7e9 100644
--- a/drivers/pinctrl/Kconfig
+++ b/drivers/pinctrl/Kconfig
@@ -532,6 +532,8 @@ config PINCTRL_SCMI
 	tristate "Pinctrl driver using SCMI protocol interface"
 	depends on ARM_SCMI_PROTOCOL || COMPILE_TEST
 	select PINMUX
+	select GENERIC_PINCTRL_GROUPS
+	select GENERIC_PINMUX_FUNCTIONS
 	select GENERIC_PINCONF
 	help
 	  This driver provides support for pinctrl which is controlled

-- 
2.43.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] pinctrl: scmi: Replace pinmux ops get function info with generics
  2026-09-17 22:55 ` [PATCH v2 1/3] pinctrl: scmi: Replace pinmux ops get function info with generics Alex Tran
@ 2026-10-01 15:03   ` Sudeep Holla
  0 siblings, 0 replies; 8+ messages in thread
From: Sudeep Holla @ 2026-10-01 15:03 UTC (permalink / raw)
  To: Alex Tran
  Cc: Cristian Marussi, Sudeep Holla, Linus Walleij, arm-scmi,
	linux-arm-kernel, linux-gpio, linux-kernel

On Thu, Sep 17, 2026 at 03:55:55PM -0700, Alex Tran wrote:
> During probe, populate the pinctrl device with function info
> so that the generic callbacks can be used to fetch function
> count, name, and groups. Remove locally stored functions
> since caching them in this driver is no longer needed.
> 
> Signed-off-by: Alex Tran <alex.tran@oss.qualcomm.com>
> ---
>  drivers/pinctrl/pinctrl-scmi.c | 151 +++++++++++++++++------------------------
>  1 file changed, 61 insertions(+), 90 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
> index 1bb36ca477b7..1d85a16f300d 100644
> --- a/drivers/pinctrl/pinctrl-scmi.c
> +++ b/drivers/pinctrl/pinctrl-scmi.c
> @@ -24,6 +24,7 @@
>  #include "pinctrl-utils.h"
>  #include "core.h"
>  #include "pinconf.h"
> +#include "pinmux.h"
>  
>  #define DRV_NAME "scmi-pinctrl"
>  
> @@ -37,8 +38,6 @@ struct scmi_pinctrl {
>  	struct scmi_protocol_handle *ph;
>  	struct pinctrl_dev *pctldev;
>  	struct pinctrl_desc pctl_desc;
> -	struct pinfunction *functions;
> -	unsigned int nr_functions;
>  };
>  
>  static int pinctrl_scmi_get_groups_count(struct pinctrl_dev *pctldev)
> @@ -84,86 +83,6 @@ static const struct pinctrl_ops pinctrl_scmi_pinctrl_ops = {
>  #endif
>  };
>  
> -static int pinctrl_scmi_get_functions_count(struct pinctrl_dev *pctldev)
> -{
> -	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
> -
> -	return pinctrl_ops->count_get(pmx->ph, FUNCTION_TYPE);
> -}
> -
> -static const char *pinctrl_scmi_get_function_name(struct pinctrl_dev *pctldev,
> -						  unsigned int selector)
> -{
> -	int ret;
> -	const char *name;
> -	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
> -
> -	ret = pinctrl_ops->name_get(pmx->ph, selector, FUNCTION_TYPE, &name);
> -	if (ret) {
> -		dev_err(pmx->dev, "get name failed with err %d", ret);
> -		return NULL;
> -	}
> -
> -	return name;
> -}
> -
> -static int pinctrl_scmi_get_function_groups(struct pinctrl_dev *pctldev,
> -					    unsigned int selector,
> -					    const char * const **p_groups,
> -					    unsigned int * const p_num_groups)
> -{
> -	struct pinfunction *func;
> -	const unsigned int *group_ids;
> -	unsigned int num_groups;
> -	const char **groups;
> -	int ret, i;
> -	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
> -
> -	if (!p_groups || !p_num_groups)
> -		return -EINVAL;
> -
> -	if (selector >= pmx->nr_functions)
> -		return -EINVAL;
> -
> -	func = &pmx->functions[selector];
> -	if (func->ngroups)
> -		goto done;
> -
> -	ret = pinctrl_ops->function_groups_get(pmx->ph, selector, &num_groups,
> -					       &group_ids);
> -	if (ret) {
> -		dev_err(pmx->dev, "Unable to get function groups, err %d", ret);
> -		return ret;
> -	}
> -	if (!num_groups)
> -		return -EINVAL;
> -
> -	groups = kcalloc(num_groups, sizeof(*groups), GFP_KERNEL);
> -	if (!groups)
> -		return -ENOMEM;
> -
> -	for (i = 0; i < num_groups; i++) {
> -		groups[i] = pinctrl_scmi_get_group_name(pctldev, group_ids[i]);
> -		if (!groups[i]) {
> -			ret = -EINVAL;
> -			goto err_free;
> -		}
> -	}
> -
> -	func->ngroups = num_groups;
> -	func->groups = groups;
> -done:
> -	*p_groups = func->groups;
> -	*p_num_groups = func->ngroups;
> -
> -	return 0;
> -
> -err_free:
> -	kfree(groups);
> -
> -	return ret;
> -}
> -
>  static int pinctrl_scmi_func_set_mux(struct pinctrl_dev *pctldev,
>  				     unsigned int selector, unsigned int group)
>  {
> @@ -190,9 +109,9 @@ static int pinctrl_scmi_free(struct pinctrl_dev *pctldev, unsigned int offset)
>  static const struct pinmux_ops pinctrl_scmi_pinmux_ops = {
>  	.request = pinctrl_scmi_request,
>  	.free = pinctrl_scmi_free,
> -	.get_functions_count = pinctrl_scmi_get_functions_count,
> -	.get_function_name = pinctrl_scmi_get_function_name,
> -	.get_function_groups = pinctrl_scmi_get_function_groups,
> +	.get_functions_count = pinmux_generic_get_function_count,
> +	.get_function_name = pinmux_generic_get_function_name,
> +	.get_function_groups = pinmux_generic_get_function_groups,
>  	.set_mux = pinctrl_scmi_func_set_mux,
>  };
>  
> @@ -487,6 +406,60 @@ static const struct pinconf_ops pinctrl_scmi_pinconf_ops = {
>  	.pin_config_config_dbg_show = pinconf_generic_dump_config,
>  };
>  
> +static int pinctrl_scmi_get_functions(struct scmi_pinctrl *pmx)
> +{
> +	unsigned int nr_funcs, nr_groups, i, j;
> +	const unsigned int *group_ids;
> +	const char *fname;
> +	const char **gnames;
> +	int ret;
> +
> +	nr_funcs = pinctrl_ops->count_get(pmx->ph, FUNCTION_TYPE);
> +
> +	for (i = 0; i < nr_funcs; i++) {
> +		ret = pinctrl_ops->name_get(pmx->ph, i, FUNCTION_TYPE,
> +					    &fname);
> +		if (ret)
> +			return ret;
> +
> +		ret = pinctrl_ops->function_groups_get(pmx->ph, i,
> +						       &nr_groups,
> +						       &group_ids);
> +		if (ret)
> +			return ret;
> +
> +		if (!nr_groups)
> +			dev_warn(pmx->dev,
> +				 "Function %s contains no groups\n",
> +				 fname);
> +
> +		gnames = devm_kmalloc_array(pmx->dev, nr_groups,
> +					    sizeof(*gnames), GFP_KERNEL);
> +		if (!gnames)
> +			return -ENOMEM;
> +
> +		for (j = 0; j < nr_groups; j++) {
> +			ret = pinctrl_ops->name_get(pmx->ph, group_ids[j],
> +						    GROUP_TYPE, &gnames[j]);
> +			if (ret)
> +				return ret;
> +		}
> +
> +		ret = pinmux_generic_add_function(pmx->pctldev, fname, gnames,
> +				  nr_groups, NULL);
> +		if (ret < 0)
> +			return ret;

Since this will fail the probe, don't we have to pinmux_generic_remove_function()
for all the added functions ? I don't know if devm_* takes care of it, just
thought I have check as I don't have much deeper knowledge of pinctl
sub-system.

If the above cleanup is needed, with that added, else w/o it:

Acked-by: Sudeep Holla <sudeep.holla@kernel.org>

It is a nice cleanup to avoid unnecessary duplication and move to reuse of
functionality provided already by the core pinctl.

-- 
Regards,
Sudeep


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] pinctrl: scmi: Replace pinctrl ops get group info with generics
  2026-09-17 22:55 ` [PATCH v2 2/3] pinctrl: scmi: Replace pinctrl ops get group " Alex Tran
@ 2026-10-01 15:18   ` Sudeep Holla
  0 siblings, 0 replies; 8+ messages in thread
From: Sudeep Holla @ 2026-10-01 15:18 UTC (permalink / raw)
  To: Alex Tran
  Cc: Cristian Marussi, Sudeep Holla, Linus Walleij, arm-scmi,
	linux-arm-kernel, linux-gpio, linux-kernel

On Thu, Sep 17, 2026 at 03:55:56PM -0700, Alex Tran wrote:
> During probe, populate the pinctrl device with group info
> so that the generic callbacks can be used to fetch group
> count, name, and pins.
> 
> Signed-off-by: Alex Tran <alex.tran@oss.qualcomm.com>
> ---
>  drivers/pinctrl/pinctrl-scmi.c | 81 +++++++++++++++++++++++-------------------
>  1 file changed, 45 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinctrl-scmi.c b/drivers/pinctrl/pinctrl-scmi.c
> index 1d85a16f300d..c93d61dfa282 100644
> --- a/drivers/pinctrl/pinctrl-scmi.c
> +++ b/drivers/pinctrl/pinctrl-scmi.c
> @@ -40,43 +40,10 @@ struct scmi_pinctrl {
>  	struct pinctrl_desc pctl_desc;
>  };
>  
> -static int pinctrl_scmi_get_groups_count(struct pinctrl_dev *pctldev)
> -{
> -	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
> -
> -	return pinctrl_ops->count_get(pmx->ph, GROUP_TYPE);
> -}
> -
> -static const char *pinctrl_scmi_get_group_name(struct pinctrl_dev *pctldev,
> -					       unsigned int selector)
> -{
> -	int ret;
> -	const char *name;
> -	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
> -
> -	ret = pinctrl_ops->name_get(pmx->ph, selector, GROUP_TYPE, &name);
> -	if (ret) {
> -		dev_err(pmx->dev, "get name failed with err %d", ret);
> -		return NULL;
> -	}
> -
> -	return name;
> -}
> -
> -static int pinctrl_scmi_get_group_pins(struct pinctrl_dev *pctldev,
> -				       unsigned int selector,
> -				       const unsigned int **pins,
> -				       unsigned int *num_pins)
> -{
> -	struct scmi_pinctrl *pmx = pinctrl_dev_get_drvdata(pctldev);
> -
> -	return pinctrl_ops->group_pins_get(pmx->ph, selector, pins, num_pins);
> -}
> -
>  static const struct pinctrl_ops pinctrl_scmi_pinctrl_ops = {
> -	.get_groups_count = pinctrl_scmi_get_groups_count,
> -	.get_group_name = pinctrl_scmi_get_group_name,
> -	.get_group_pins = pinctrl_scmi_get_group_pins,
> +	.get_groups_count = pinctrl_generic_get_group_count,
> +	.get_group_name = pinctrl_generic_get_group_name,
> +	.get_group_pins = pinctrl_generic_get_group_pins,
>  #ifdef CONFIG_OF
>  	.dt_node_to_map = pinconf_generic_dt_node_to_map_all,
>  	.dt_free_map = pinconf_generic_dt_free_map,
> @@ -460,6 +427,44 @@ static int pinctrl_scmi_get_functions(struct scmi_pinctrl *pmx)
>  	return 0;
>  }
>  
> +static int pinctrl_scmi_get_groups(struct scmi_pinctrl *pmx)
> +{
> +	unsigned int nr_groups, nr_pins, i;
> +	const unsigned int *pins;
> +	const char *gname;
> +	int ret;
> +
> +	nr_groups = pinctrl_ops->count_get(pmx->ph, GROUP_TYPE);
> +
> +	for (i = 0; i < nr_groups; i++) {
> +		ret = pinctrl_ops->name_get(pmx->ph, i, GROUP_TYPE, &gname);
> +		if (ret)
> +			return ret;
> +
> +		ret = pinctrl_ops->group_pins_get(pmx->ph, i, &pins,
> +						  &nr_pins);
> +		if (ret)
> +			return ret;
> +
> +		if (!nr_pins)
> +			dev_warn(pmx->dev,
> +				 "Group %s contains no pins\n", gname);

I think sashiko warning on the above can be ignored as it is not true.

> +
> +		ret = pinctrl_generic_add_group(pmx->pctldev, gname, pins,
> +						nr_pins, NULL);
> +		if (ret < 0)
> +			return ret;

Similar question about use of pinctrl_generic_remove_group(), but I did
check the driver and absence of driver remove() callback is the hint I
believe and devm_* takes care of cleanup I assume. Sashiko also points
at some possible race with devm_* cleanup. I will leave that to you as
I don't fully understand how devm_* cleanup works in pinctl.

Anyways, with fix if needed or without if not required,

Acked-by: Sudeep Holla <sudeep.holla@kernel.org>

-- 
Regards,
Sudeep


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] pinctrl: kconfig: Select generic pinctrl helpers for scmi pinctrl
  2026-09-17 22:55 ` [PATCH v2 3/3] pinctrl: kconfig: Select generic pinctrl helpers for scmi pinctrl Alex Tran
@ 2026-10-01 15:19   ` Sudeep Holla
  0 siblings, 0 replies; 8+ messages in thread
From: Sudeep Holla @ 2026-10-01 15:19 UTC (permalink / raw)
  To: Alex Tran
  Cc: Cristian Marussi, Sudeep Holla, Linus Walleij, arm-scmi,
	linux-arm-kernel, linux-gpio, linux-kernel

On Thu, Sep 17, 2026 at 03:55:57PM -0700, Alex Tran wrote:
> Select the corresponding pinctrl and pinmux generic Kconfig symbols
> when PINCTRL_SCMI is enabled.
> 

Acked-by: Sudeep Holla <sudeep.holla@kernel.org>

-- 
Regards,
Sudeep


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/3] pinctrl: scmi: Replace get function and group info with generic callbacks
  2026-09-17 22:55 [PATCH v2 0/3] pinctrl: scmi: Replace get function and group info with generic callbacks Alex Tran
                   ` (2 preceding siblings ...)
  2026-09-17 22:55 ` [PATCH v2 3/3] pinctrl: kconfig: Select generic pinctrl helpers for scmi pinctrl Alex Tran
@ 2026-10-07  6:48 ` Linus Walleij
  3 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2026-10-07  6:48 UTC (permalink / raw)
  To: Alex Tran
  Cc: Sudeep Holla, Cristian Marussi, arm-scmi, linux-arm-kernel,
	linux-gpio, linux-kernel

On Fri, Sep 18, 2026 at 12:56 AM Alex Tran <alex.tran@oss.qualcomm.com> wrote:

> This series refactors the SCMI pinctrl driver to eliminate metadata
> getter callbacks to be replaced with pinctrl and pinmux generics
> provided by the pinctrl core.
>
> Previously, the driver implemented its own get_functions_count,
> get_function_name, get_function_groups, get_groups_count,
> get_group_name, and get_group_pins callbacks, which required
> maintaining driver metadata like the functions and count.
>
> The pinctrl core already has support to store and manage this
> topology in the pinctrl_dev via its own internal radix trees.
> By registering functions and groups at probe time using
> pinmux_generic_add_function and pinctrl_generic_add_group, the
> driver can delegate group and function metadata management to
> the core.
>
> Signed-off-by: Alex Tran <alex.tran@oss.qualcomm.com>

Patches applied!

Yours,
Linus Walleij


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-10-07  6:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-17 22:55 [PATCH v2 0/3] pinctrl: scmi: Replace get function and group info with generic callbacks Alex Tran
2026-09-17 22:55 ` [PATCH v2 1/3] pinctrl: scmi: Replace pinmux ops get function info with generics Alex Tran
2026-10-01 15:03   ` Sudeep Holla
2026-09-17 22:55 ` [PATCH v2 2/3] pinctrl: scmi: Replace pinctrl ops get group " Alex Tran
2026-10-01 15:18   ` Sudeep Holla
2026-09-17 22:55 ` [PATCH v2 3/3] pinctrl: kconfig: Select generic pinctrl helpers for scmi pinctrl Alex Tran
2026-10-01 15:19   ` Sudeep Holla
2026-10-07  6:48 ` [PATCH v2 0/3] pinctrl: scmi: Replace get function and group info with generic callbacks Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox