summaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/core.c
diff options
context:
space:
mode:
authorRichard Genoud2013-03-25 15:47:23 +0100
committerLinus Walleij2013-03-27 23:18:28 +0100
commit50cf7c8ab324de348990bb028ad9ed10872d527a (patch)
tree86754978ef05885b409dd28d1eafc6da1ae25151 /drivers/pinctrl/core.c
parentpinctrl: disable and free setting in select_state in case of error (diff)
downloadkernel-qcow2-linux-50cf7c8ab324de348990bb028ad9ed10872d527a.tar.gz
kernel-qcow2-linux-50cf7c8ab324de348990bb028ad9ed10872d527a.tar.xz
kernel-qcow2-linux-50cf7c8ab324de348990bb028ad9ed10872d527a.zip
pinctrl: re-enable old state in case of error in pinctrl_select_state
If a new state is applied, the groups configured in the old state but not in the new state are disabled. If something goes wrong and the new state can't be applied, we have to re-enable those groups. Signed-off-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/core.c')
-rw-r--r--drivers/pinctrl/core.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c
index 09f79f251800..3e969813154f 100644
--- a/drivers/pinctrl/core.c
+++ b/drivers/pinctrl/core.c
@@ -897,6 +897,7 @@ static int pinctrl_select_state_locked(struct pinctrl *p,
struct pinctrl_state *state)
{
struct pinctrl_setting *setting, *setting2;
+ struct pinctrl_state *old_state = p->state;
int ret;
if (p->state == state)
@@ -973,7 +974,24 @@ unapply_new_state:
pinctrl_free_setting(true, setting2);
}
reapply_old_state:
- /* FIXME: re-enable old setting */
+ 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);
+ }
+ }
return ret;
}