Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43bda1a6 authored by Ben Dooks's avatar Ben Dooks Committed by Russell King
Browse files

[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: default avatarBen Dooks <ben-linux@fluff.org>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 3b73125a
Loading
Loading
Loading
Loading
+11 −5
Original line number Original line Diff line number Diff line
@@ -119,17 +119,23 @@ struct pwm_device *pwm_request(int pwm_id, const char *label)
	mutex_lock(&pwm_lock);
	mutex_lock(&pwm_lock);


	list_for_each_entry(pwm, &pwm_list, node) {
	list_for_each_entry(pwm, &pwm_list, node) {
		if (pwm->pwm_id == pwm_id && pwm->use_count == 0) {
		if (pwm->pwm_id == pwm_id) {
			pwm->use_count++;
			pwm->label = label;
			found = 1;
			found = 1;
			break;
			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);
EXPORT_SYMBOL(pwm_request);


+2 −2
Original line number Original line Diff line number Diff line
@@ -87,9 +87,9 @@ static int pwm_backlight_probe(struct platform_device *pdev)
	pb->notify = data->notify;
	pb->notify = data->notify;


	pb->pwm = pwm_request(data->pwm_id, "backlight");
	pb->pwm = pwm_request(data->pwm_id, "backlight");
	if (pb->pwm == NULL) {
	if (IS_ERR(pb->pwm)) {
		dev_err(&pdev->dev, "unable to request PWM for backlight\n");
		dev_err(&pdev->dev, "unable to request PWM for backlight\n");
		ret = -EBUSY;
		ret = PTR_ERR(pb->pwm);
		goto err_pwm;
		goto err_pwm;
	}
	}