aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-pxa/pwm.c16
-rw-r--r--drivers/video/backlight/pwm_bl.c4
2 files changed, 13 insertions, 7 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}
134EXPORT_SYMBOL(pwm_request); 140EXPORT_SYMBOL(pwm_request);
135 141
diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 8346dfc01cf6..6338d0e2fe07 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -87,9 +87,9 @@ static int pwm_backlight_probe(struct platform_device *pdev)
87 pb->notify = data->notify; 87 pb->notify = data->notify;
88 88
89 pb->pwm = pwm_request(data->pwm_id, "backlight"); 89 pb->pwm = pwm_request(data->pwm_id, "backlight");
90 if (pb->pwm == NULL) { 90 if (IS_ERR(pb->pwm)) {
91 dev_err(&pdev->dev, "unable to request PWM for backlight\n"); 91 dev_err(&pdev->dev, "unable to request PWM for backlight\n");
92 ret = -EBUSY; 92 ret = PTR_ERR(pb->pwm);
93 goto err_pwm; 93 goto err_pwm;
94 } 94 }
95 95