diff options
author | Ben Dooks <ben-linux@fluff.org> | 2008-07-01 09:18:27 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2008-07-03 08:25:07 -0400 |
commit | 43bda1a6d218744382547a2f8be3240d1c3a151b (patch) | |
tree | 7a765e743a6e2cfde5db08dfe073a412e42df873 /arch/arm/mach-pxa/pwm.c | |
parent | 3b73125af69f93972625f4b655675f42ca4274eb (diff) |
[ARM] 5141/1: PWM: pwm_request() should return an PTR_ERR() instead of NULL.
Make the return of pwm_request() be more informative than just
being NULL on error by using PTR_ERR() to respond with an
approriate error.
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-pxa/pwm.c')
-rw-r--r-- | arch/arm/mach-pxa/pwm.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/arch/arm/mach-pxa/pwm.c b/arch/arm/mach-pxa/pwm.c index 7c86dd1d108f..ce28cd9fed16 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) | |||
119 | mutex_lock(&pwm_lock); | 119 | mutex_lock(&pwm_lock); |
120 | 120 | ||
121 | list_for_each_entry(pwm, &pwm_list, node) { | 121 | list_for_each_entry(pwm, &pwm_list, node) { |
122 | if (pwm->pwm_id == pwm_id && pwm->use_count == 0) { | 122 | if (pwm->pwm_id == pwm_id) { |
123 | pwm->use_count++; | ||
124 | pwm->label = label; | ||
125 | found = 1; | 123 | found = 1; |
126 | break; | 124 | break; |
127 | } | 125 | } |
128 | } | 126 | } |
129 | 127 | ||
130 | mutex_unlock(&pwm_lock); | 128 | if (found) { |
129 | if (pwm->use_count == 0) { | ||
130 | pwm->use_count++; | ||
131 | pwm->label = label; | ||
132 | } else | ||
133 | pwm = ERR_PTR(-EBUSY); | ||
134 | } else | ||
135 | pwm = ERR_PTR(-ENOENT); | ||
131 | 136 | ||
132 | return (found) ? pwm : NULL; | 137 | mutex_unlock(&pwm_lock); |
138 | return pwm; | ||
133 | } | 139 | } |
134 | EXPORT_SYMBOL(pwm_request); | 140 | EXPORT_SYMBOL(pwm_request); |
135 | 141 | ||