Skip to contentSkip to conversation

pinctrl: imx: Return NULL if no group is matched and found

PATCH In review Hui Wang 3 participants 3 messages Mar 27, 2025 – Apr 15, 2025

Subsystems (4)
lore
Share & tools
lore

Hui Wang

author
#0 lore raw

PATCH 1/1 pinctrl: imx: Return NULL if no group is matched and found

Currently if no group is matched and found, this function will return the last grp to the caller, this is not expected, it is supposed to return NULL in this case.

Fixes e566fc11ea76 ("pinctrl: imx: use generic pinctrl helpers for managing groups")
---
 drivers/pinctrl/freescale/pinctrl-imx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx.c +3 -3
index 842a1e6cbfc4..18de31328540 100644
@@ -37,16 +37,16 @@ static inline const struct group_desc *imx_pinctrl_find_group_by_name(
 				struct pinctrl_dev *pctldev,
 				const char *name)
 {
-	const struct group_desc *grp = NULL;
+	const struct group_desc *grp;
 	int i;
 
 	for (i = 0; i < pctldev->num_groups; i++) {
 		grp = pinctrl_generic_get_group(pctldev, i);
 		if (grp && !strcmp(grp->grp.name, name))
-			break;
+			return grp;
 	}
 
-	return grp;
+	return NULL;
 }
 
 static void imx_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Hui Wang

Currently if no group is matched and found, this function will return the last grp to the caller, this is not expected, it is supposed to return NULL in this case.

Fixes e566fc11ea76 ("pinctrl: imx: use generic pinctrl helpers for managing groups")
Quoted 31 lines
---
 drivers/pinctrl/freescale/pinctrl-imx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/freescale/pinctrl-imx.c +3 -4
index 842a1e6cbfc4..18de31328540 100644
@@ -37,16 +37,16 @@ static inline const struct group_desc *imx_pinctrl_find_group_by_name(
 				struct pinctrl_dev *pctldev,
 				const char *name)
 {
-	const struct group_desc *grp = NULL;
+	const struct group_desc *grp;
 	int i;
 
 	for (i = 0; i < pctldev->num_groups; i++) {
 		grp = pinctrl_generic_get_group(pctldev, i);
 		if (grp && !strcmp(grp->grp.name, name))
-			break;
+			return grp;
 	}
 
-	return grp;
+	return NULL;
 }
 
 static void imx_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
--

2.34.1

#2 lore raw
In reply to Hui Wang
Quoted 6 lines · Hui Wang

Currently if no group is matched and found, this function will return the last grp to the caller, this is not expected, it is supposed to return NULL in this case.

Fixes e566fc11ea76 ("pinctrl: imx: use generic pinctrl helpers for managing groups")

Patch applied for fixes.

Yours,
Linus Walleij