diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-24 10:11:24 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-24 10:11:24 -0700 |
commit | 06b45f2aa703837163496f5db6a53575665cc6b4 (patch) | |
tree | 8ab499b2926e64a53ae43905f5b838f97e7643af /drivers/pwm/pwm-mxs.c | |
parent | b3f4ef0bf21da37e4dfc1cdfa0288ba39186fb56 (diff) | |
parent | c264f1110d27185f8531602f5fce400a6bbce946 (diff) |
Merge tag 'pwm/for-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm
Pull pwm changes from Thierry Reding:
"Not much has been happening in PWM land lately, so this contains
mostly minor fixes that didn't seem urgent enough for a late
pull-request last cycle"
* tag 'pwm/for-4.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/thierry.reding/linux-pwm:
pwm: Remove __init initializer for pwm_add_table()
pwm: samsung: Fix output race on disabling
pwm: mxs: Fix period divider computation
pwm: atmel-hlcdc: Add errata handling for sama5d4
pwm: pca9685: Constify struct regmap_config
pwm: imx-pwm: add explicit compatible strings and required clock properties
Diffstat (limited to 'drivers/pwm/pwm-mxs.c')
-rw-r--r-- | drivers/pwm/pwm-mxs.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c index f75ecb09d97d..b430811e14f5 100644 --- a/drivers/pwm/pwm-mxs.c +++ b/drivers/pwm/pwm-mxs.c @@ -35,6 +35,10 @@ #define PERIOD_CDIV(div) (((div) & 0x7) << 20) #define PERIOD_CDIV_MAX 8 +static const unsigned int cdiv[PERIOD_CDIV_MAX] = { + 1, 2, 4, 8, 16, 64, 256, 1024 +}; + struct mxs_pwm_chip { struct pwm_chip chip; struct clk *clk; @@ -54,13 +58,13 @@ static int mxs_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, rate = clk_get_rate(mxs->clk); while (1) { - c = rate / (1 << div); + c = rate / cdiv[div]; c = c * period_ns; do_div(c, 1000000000); if (c < PERIOD_PERIOD_MAX) break; div++; - if (div > PERIOD_CDIV_MAX) + if (div >= PERIOD_CDIV_MAX) return -EINVAL; } |