diff options
author | Boris Brezillon <boris.brezillon@free-electrons.com> | 2016-04-14 15:17:21 -0400 |
---|---|---|
committer | Thierry Reding <thierry.reding@gmail.com> | 2016-05-03 07:44:37 -0400 |
commit | e39c0df1be5a97e0910b09af1530bdf3de057a06 (patch) | |
tree | 3299bb34c94cd6b989ecd54ff7cfcc9cc962d9ff /drivers/pwm | |
parent | f55532a0c0b8bb6148f4e07853b876ef73bc69ca (diff) |
pwm: Introduce the pwm_args concept
Currently the PWM core mixes the current PWM state with the per-platform
reference config (specified through the PWM lookup table, DT definition
or directly hardcoded in PWM drivers).
Create a struct pwm_args to store this reference configuration, so that
PWM users can differentiate between the current and reference
configurations.
Patch all places where pwm->args should be initialized. We keep the
pwm_set_polarity/period() calls until all PWM users are patched to use
pwm_args instead of pwm_get_period/polarity().
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[thierry.reding@gmail.com: reword kerneldoc comments]
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
Diffstat (limited to 'drivers/pwm')
-rw-r--r-- | drivers/pwm/core.c | 21 | ||||
-rw-r--r-- | drivers/pwm/pwm-clps711x.c | 2 | ||||
-rw-r--r-- | drivers/pwm/pwm-pxa.c | 2 |
3 files changed, 16 insertions, 9 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c index 7831bc6b51dd..680fbc795a0a 100644 --- a/drivers/pwm/core.c +++ b/drivers/pwm/core.c | |||
@@ -128,6 +128,13 @@ static int pwm_device_request(struct pwm_device *pwm, const char *label) | |||
128 | set_bit(PWMF_REQUESTED, &pwm->flags); | 128 | set_bit(PWMF_REQUESTED, &pwm->flags); |
129 | pwm->label = label; | 129 | pwm->label = label; |
130 | 130 | ||
131 | /* | ||
132 | * FIXME: This should be removed once all PWM users properly make use | ||
133 | * of struct pwm_args to initialize the PWM device. As long as this is | ||
134 | * here, the PWM state and hardware state can get out of sync. | ||
135 | */ | ||
136 | pwm_apply_args(pwm); | ||
137 | |||
131 | return 0; | 138 | return 0; |
132 | } | 139 | } |
133 | 140 | ||
@@ -146,12 +153,12 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args) | |||
146 | if (IS_ERR(pwm)) | 153 | if (IS_ERR(pwm)) |
147 | return pwm; | 154 | return pwm; |
148 | 155 | ||
149 | pwm_set_period(pwm, args->args[1]); | 156 | pwm->args.period = args->args[1]; |
150 | 157 | ||
151 | if (args->args[2] & PWM_POLARITY_INVERTED) | 158 | if (args->args[2] & PWM_POLARITY_INVERTED) |
152 | pwm_set_polarity(pwm, PWM_POLARITY_INVERSED); | 159 | pwm->args.polarity = PWM_POLARITY_INVERSED; |
153 | else | 160 | else |
154 | pwm_set_polarity(pwm, PWM_POLARITY_NORMAL); | 161 | pwm->args.polarity = PWM_POLARITY_NORMAL; |
155 | 162 | ||
156 | return pwm; | 163 | return pwm; |
157 | } | 164 | } |
@@ -172,7 +179,7 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) | |||
172 | if (IS_ERR(pwm)) | 179 | if (IS_ERR(pwm)) |
173 | return pwm; | 180 | return pwm; |
174 | 181 | ||
175 | pwm_set_period(pwm, args->args[1]); | 182 | pwm->args.period = args->args[1]; |
176 | 183 | ||
177 | return pwm; | 184 | return pwm; |
178 | } | 185 | } |
@@ -747,13 +754,13 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id) | |||
747 | if (!chip) | 754 | if (!chip) |
748 | goto out; | 755 | goto out; |
749 | 756 | ||
757 | pwm->args.period = chosen->period; | ||
758 | pwm->args.polarity = chosen->polarity; | ||
759 | |||
750 | pwm = pwm_request_from_chip(chip, chosen->index, con_id ?: dev_id); | 760 | pwm = pwm_request_from_chip(chip, chosen->index, con_id ?: dev_id); |
751 | if (IS_ERR(pwm)) | 761 | if (IS_ERR(pwm)) |
752 | goto out; | 762 | goto out; |
753 | 763 | ||
754 | pwm_set_period(pwm, chosen->period); | ||
755 | pwm_set_polarity(pwm, chosen->polarity); | ||
756 | |||
757 | out: | 764 | out: |
758 | mutex_unlock(&pwm_lookup_lock); | 765 | mutex_unlock(&pwm_lookup_lock); |
759 | return pwm; | 766 | return pwm; |
diff --git a/drivers/pwm/pwm-clps711x.c b/drivers/pwm/pwm-clps711x.c index a80c10803636..7d335422cfda 100644 --- a/drivers/pwm/pwm-clps711x.c +++ b/drivers/pwm/pwm-clps711x.c | |||
@@ -60,7 +60,7 @@ static int clps711x_pwm_request(struct pwm_chip *chip, struct pwm_device *pwm) | |||
60 | return -EINVAL; | 60 | return -EINVAL; |
61 | 61 | ||
62 | /* Store constant period value */ | 62 | /* Store constant period value */ |
63 | pwm_set_period(pwm, DIV_ROUND_CLOSEST(NSEC_PER_SEC, freq)); | 63 | pwm->args.period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, freq); |
64 | 64 | ||
65 | return 0; | 65 | return 0; |
66 | } | 66 | } |
diff --git a/drivers/pwm/pwm-pxa.c b/drivers/pwm/pwm-pxa.c index cb2f7024cf68..58b709f29130 100644 --- a/drivers/pwm/pwm-pxa.c +++ b/drivers/pwm/pwm-pxa.c | |||
@@ -160,7 +160,7 @@ pxa_pwm_of_xlate(struct pwm_chip *pc, const struct of_phandle_args *args) | |||
160 | if (IS_ERR(pwm)) | 160 | if (IS_ERR(pwm)) |
161 | return pwm; | 161 | return pwm; |
162 | 162 | ||
163 | pwm_set_period(pwm, args->args[0]); | 163 | pwm->args.period = args->args[0]; |
164 | 164 | ||
165 | return pwm; | 165 | return pwm; |
166 | } | 166 | } |