aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-pxa/pwm.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/arch/arm/mach-pxa/pwm.c b/arch/arm/mach-pxa/pwm.c
index 7c86dd1d108..ce28cd9fed1 100644
--- a/arch/arm/mach-pxa/pwm.c
+++ b/arch/arm/mach-pxa/pwm.c
@@ -119,17 +119,23 @@ struct pwm_device *pwm_request(int pwm_id, const char *label)
mutex_lock(&pwm_lock);
list_for_each_entry(pwm, &pwm_list, node) {
- if (pwm->pwm_id == pwm_id && pwm->use_count == 0) {
- pwm->use_count++;
- pwm->label = label;
+ if (pwm->pwm_id == pwm_id) {
found = 1;
break;
}
}
- mutex_unlock(&pwm_lock);
+ if (found) {
+ if (pwm->use_count == 0) {
+ pwm->use_count++;
+ pwm->label = label;
+ } else
+ pwm = ERR_PTR(-EBUSY);
+ } else
+ pwm = ERR_PTR(-ENOENT);
- return (found) ? pwm : NULL;
+ mutex_unlock(&pwm_lock);
+ return pwm;
}
EXPORT_SYMBOL(pwm_request);