Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3.8: add pwm-test patches so people can well, test them
- Loading branch information
Showing
3 changed files
with
657 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
From 0333af354769189d806876f6e160a7012efde77e Mon Sep 17 00:00:00 2001 | ||
From: Jack Mitchell <jack@embed.me.uk> | ||
Date: Tue, 9 Apr 2013 16:47:31 +0200 | ||
Subject: [PATCH 160/162] pwm_test: fix some issues | ||
|
||
--- | ||
drivers/pwm/pwm_test.c | 39 ++++++++++++++++++++++++++++++--------- | ||
1 file changed, 30 insertions(+), 9 deletions(-) | ||
|
||
diff --git a/drivers/pwm/pwm_test.c b/drivers/pwm/pwm_test.c | ||
index d9948db..3da1890 100644 | ||
--- a/drivers/pwm/pwm_test.c | ||
+++ b/drivers/pwm/pwm_test.c | ||
@@ -91,6 +91,11 @@ static ssize_t pwm_test_store_config(struct device *dev, | ||
struct pwm_test *pwm_test = dev_get_drvdata(dev); | ||
int ret; | ||
|
||
+ if (pwm_test->pwm == NULL) { | ||
+ pr_err("PWM Device has not been requested\n"); | ||
+ return -ENODEV; | ||
+ } | ||
+ | ||
if (pwm_test->duty_s == 0) { | ||
ret = pwm_config(pwm_test->pwm, 0, pwm_test->period_s); | ||
if (ret) { | ||
@@ -199,6 +204,12 @@ static ssize_t pwm_test_store_request(struct device *dev, | ||
return rc; | ||
|
||
if (pwm_test->requested_s) { | ||
+ | ||
+ if (pwm_test->pwm) { | ||
+ pr_info("PWM already requested!\n"); | ||
+ return count; | ||
+ } | ||
+ | ||
pwm_test->pwm = pwm_get(dev, NULL); | ||
|
||
if (IS_ERR(pwm_test->pwm)) { | ||
@@ -206,9 +217,9 @@ static ssize_t pwm_test_store_request(struct device *dev, | ||
PTR_ERR(pwm_test->pwm)); | ||
rc = -EINVAL; | ||
} | ||
- } else { | ||
- pwm_free(pwm_test->pwm); | ||
- pwm_test->polarity = 0; | ||
+ } else if (pwm_test->pwm != NULL) { | ||
+ | ||
+ pwm_test->polarity = 0; | ||
pwm_test->run = 0; | ||
pwm_test->duty = 0; | ||
pwm_test->period = 0; | ||
@@ -218,8 +229,18 @@ static ssize_t pwm_test_store_request(struct device *dev, | ||
pwm_test->duty_s = 0; | ||
pwm_test->period_s = 0; | ||
pwm_test->config_s = 0; | ||
+ | ||
+ pwm_config(pwm_test->pwm, pwm_test->duty_s, | ||
+ pwm_test->period_s); | ||
+ | ||
+ pwm_disable(pwm_test->pwm); | ||
+ | ||
rc = 0; | ||
} | ||
+ else { | ||
+ pr_info("PWM was already unrequested\n"); | ||
+ } | ||
+ | ||
|
||
if (rc) { | ||
pr_err("operation failed %d\n", rc); | ||
@@ -231,13 +252,13 @@ static ssize_t pwm_test_store_request(struct device *dev, | ||
return count; | ||
} | ||
|
||
-static DEVICE_ATTR(duty, 0644, pwm_test_show_duty, pwm_test_store_duty); | ||
-static DEVICE_ATTR(period, 0644, pwm_test_show_period, pwm_test_store_period); | ||
-static DEVICE_ATTR(polarity, 0644, pwm_test_show_polarity, | ||
+static DEVICE_ATTR(duty, S_IRUSR | S_IWUSR, pwm_test_show_duty, pwm_test_store_duty); | ||
+static DEVICE_ATTR(period, S_IRUSR | S_IWUSR, pwm_test_show_period, pwm_test_store_period); | ||
+static DEVICE_ATTR(polarity, S_IRUSR | S_IWUSR, pwm_test_show_polarity, | ||
pwm_test_store_polarity); | ||
-static DEVICE_ATTR(config, 0644 , pwm_test_show_config, pwm_test_store_config); | ||
-static DEVICE_ATTR(run, 0644 , pwm_test_show_run, pwm_test_store_run); | ||
-static DEVICE_ATTR(request, 0644 , pwm_test_show_request, pwm_test_store_request); | ||
+static DEVICE_ATTR(config, S_IRUSR | S_IWUSR , pwm_test_show_config, pwm_test_store_config); | ||
+static DEVICE_ATTR(run, S_IRUSR | S_IWUSR , pwm_test_show_run, pwm_test_store_run); | ||
+static DEVICE_ATTR(request, S_IRUSR | S_IWUSR , pwm_test_show_request, pwm_test_store_request); | ||
|
||
static const struct attribute *pwm_attrs[] = { | ||
&dev_attr_duty.attr, | ||
-- | ||
1.8.1.4 | ||
|
Oops, something went wrong.