Skip to content

Commit

Permalink
pinctrl: re-enable old state in case of error in pinctrl_select_state
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Richard Genoud authored and Linus Walleij committed Mar 27, 2013
1 parent 3102a76 commit 50cf7c8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion drivers/pinctrl/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -973,7 +974,24 @@ static int pinctrl_select_state_locked(struct pinctrl *p,
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;
}

Expand Down

0 comments on commit 50cf7c8

Please sign in to comment.