Skip to contentSkip to conversation

pinctrl: select_state: don't call pinctrl_free_setting on error

PATCH In review Richard Genoud 3 participants 6 messages Mar 29, 2013 – Apr 3, 2013 Pin control

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 pinctrl: select_state: don't call pinctrl_free_setting on error

As Stephen Warren pointed out, pinctrl_free_setting() was called instead of pinmux_disable_setting() on error.
In this error code, we want to call pinmux_disable_setting() where pinmux_enable_setting() was called.
And when pinconf_apply_setting() was called, we can't do much to undo the pin muxing (the closest thing I can think about for "unmuxing" a pin is muxing it as GPIO input).

---
This commit is on top of:
[PATCH 3/3] pinctrl: pinctrl_select_state: set the old_state back on error

 drivers/pinctrl/core.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
drivers/pinctrl/core.c +9 -1
index 714cf74..ddd9a150 100644
@@ -926,7 +926,15 @@ unapply_new_state:
 	list_for_each_entry(setting2, &state->settings, node) {
 		if (&setting2->node == &setting->node)
 			break;
-		pinctrl_free_setting(true, setting2);
+		/*
+		 * All we can do here is pinmux_disable_setting.
+		 * That means that some pins are muxed differently now
+		 * than they were before applying the setting (We can't
+		 * "unmux a pin"!), but it's not a big deal since the pins
+		 * are free to be muxed by another apply_setting.
+		 */
+		if (setting2->type == PIN_MAP_TYPE_MUX_GROUP)
+			pinmux_disable_setting(setting2);
 	}
 
 	if (old_state) {
Signature · 1 line
1.7.2.5
#1 lore raw

PATCH 2/2 pinctrl: simplify the re-enable old state code in pinctrl_select_state

Instead of just enabling the settings that were disabled in the 1st loop, it's simpler to recall pinctrl_select_state with the old state.

---
 drivers/pinctrl/core.c |   22 +++-------------------
 1 files changed, 3 insertions(+), 19 deletions(-)
drivers/pinctrl/core.c +3 -19
index ddd9a150..caf9bf9 100644
@@ -937,26 +937,10 @@ unapply_new_state:
 			pinmux_disable_setting(setting2);
 	}
 
-	if (old_state) {
-		list_for_each_entry(setting, &old_state->settings, node) {
-			bool found = false;
-			if (setting->type != PIN_MAP_TYPE_MUX_GROUP)
-				continue;
-			list_for_each_entry(setting2, &state->settings, node) {
-				if (setting2->type != PIN_MAP_TYPE_MUX_GROUP)
-					continue;
-				if (setting2->data.mux.group ==
-						setting->data.mux.group) {
-					found = true;
-					break;
-				}
-			}
-			if (!found)
-				pinmux_enable_setting(setting);
-		}
-	}
+	/* There's no infinite recursive loop here because p->state is NULL */
+	if (old_state)
+		pinctrl_select_state_locked(p, old_state);
 
-	p->state = old_state;
 	return ret;
 }
 
Signature · 1 line
1.7.2.5
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] pinctrl: simplify the re-enable old state code in pinctrl_select_state

Quoted 2 lines · Richard Genoud

Instead of just enabling the settings that were disabled in the 1st loop, it's simpler to recall pinctrl_select_state with the old state.

#3 lore raw

Re: [PATCH 2/2] pinctrl: simplify the re-enable old state code in pinctrl_select_state

In reply to Richard Genoud
Quoted 4 lines · Richard Genoud

Instead of just enabling the settings that were disabled in the 1st loop, it's simpler to recall pinctrl_select_state with the old state.

Patch applied with Stephen's review tag.

Thanks,
Linus Walleij

Reviewed-by on v1 1/2
#4 lore raw
In reply to Richard Genoud
Quoted 8 lines · Richard Genoud

As Stephen Warren pointed out, pinctrl_free_setting() was called instead of pinmux_disable_setting() on error.
In this error code, we want to call pinmux_disable_setting() where pinmux_enable_setting() was called.

And when pinconf_apply_setting() was called, we can't do much to undo the pin muxing (the closest thing I can think about for "unmuxing" a pin is muxing it as GPIO input).

That's likely typically what pinmux_disable_setting() does, or perhaps it'll select a function for that pin/group that is guaranteed not to conflict with any possible other mux configuration.

#5 lore raw
In reply to Richard Genoud
Quoted 8 lines · Richard Genoud

As Stephen Warren pointed out, pinctrl_free_setting() was called instead of pinmux_disable_setting() on error.
In this error code, we want to call pinmux_disable_setting() where pinmux_enable_setting() was called.
And when pinconf_apply_setting() was called, we can't do much to undo the pin muxing (the closest thing I can think about for "unmuxing" a pin is muxing it as GPIO input).

Quoted 4 lines

---
This commit is on top of:
[PATCH 3/3] pinctrl: pinctrl_select_state: set the old_state back on error

Patch applied with Stephen's Review tag.

Thanks,
Linus Walleij