diff mbox series

pinctrl: just return if no valid maps

Message ID 29421e7720443a2454830963186f00583c76ce1e.1572588550.git.lijiazi@xiaomi.com
State New
Headers show
Series pinctrl: just return if no valid maps | expand

Commit Message

lijiazi Nov. 1, 2019, 11:43 a.m. UTC
If there is a problem with a pinctrl node of a device,
for example, config child node do not have prop specified in
dt_params, num_maps maybe 0. On this condition, no need remember
this map.

Signed-off-by: lijiazi <lijiazi@xiaomi.com>
---
 drivers/pinctrl/devicetree.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Linus Walleij Nov. 5, 2019, 10:26 a.m. UTC | #1
On Fri, Nov 1, 2019 at 12:44 PM lijiazi <jqqlijiazi@gmail.com> wrote:

> If there is a problem with a pinctrl node of a device,
> for example, config child node do not have prop specified in
> dt_params, num_maps maybe 0. On this condition, no need remember
> this map.
>
> Signed-off-by: lijiazi <lijiazi@xiaomi.com>

Good find. Patch applied! (I tweaked the text a bit.)

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c
index 5d6d8b1..dedf450 100644
--- a/drivers/pinctrl/devicetree.c
+++ b/drivers/pinctrl/devicetree.c
@@ -147,6 +147,14 @@  static int dt_to_map_one_config(struct pinctrl *p,
 	ret = ops->dt_node_to_map(pctldev, np_config, &map, &num_maps);
 	if (ret < 0)
 		return ret;
+	else if (num_maps == 0) {
+		/* if no valid maps, maybe caused by empty pinctrl node
+		 * or typing error, no need remember, just return
+		 */
+		dev_info(p->dev,
+			"there is not valid maps for state %s\n", statename);
+		return 0;
+	}
 
 	/* Stash the mapping table chunk away for later use */
 	return dt_remember_or_free_map(p, statename, pctldev, map, num_maps);