int muxmode = -1;
int i;
- mutex_lock(&state->mutex);
+ guard(mutex)(&state->mutex);
/*
* Figure out to which port the requested GPIO belongs and how to
* Error: The requested pin is already
* used for something else.
*/
- mutex_unlock(&state->mutex);
return -EBUSY;
}
break;
if (muxport >= 0)
tb10x_pinctrl_set_config(state, muxport, muxmode);
- mutex_unlock(&state->mutex);
-
return 0;
}
if (grp->port < 0)
return 0;
- mutex_lock(&state->mutex);
+ guard(mutex)(&state->mutex);
/*
* Check if the requested function is compatible with previously
* requested functions.
*/
if (state->ports[grp->port].count
- && (state->ports[grp->port].mode != grp->mode)) {
- mutex_unlock(&state->mutex);
+ && (state->ports[grp->port].mode != grp->mode))
return -EBUSY;
- }
/*
* Check if the requested function is compatible with previously
* requested GPIOs.
*/
for (i = 0; i < grp->pincnt; i++)
- if (test_bit(grp->pins[i], state->gpios)) {
- mutex_unlock(&state->mutex);
+ if (test_bit(grp->pins[i], state->gpios))
return -EBUSY;
- }
tb10x_pinctrl_set_config(state, grp->port, grp->mode);
state->ports[grp->port].count++;
- mutex_unlock(&state->mutex);
-
return 0;
}