mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gaetan Hug <ghug@induct.be>
To: <thierry.reding@gmail.com>
Cc: <linux-pwm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	Gaetan Hug <ghug@induct.be>
Subject: [PATCH 1/1] fixing pwm-mxs period divider computation
Date: Wed, 18 Feb 2015 09:18:56 +0100	[thread overview]
Message-ID: <1424247536-16476-2-git-send-email-ghug@induct.be> (raw)
In-Reply-To: <1424247536-16476-1-git-send-email-ghug@induct.be>

---
 drivers/pwm/pwm-mxs.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c
index f75ecb0..bbb2f8a 100644
--- a/drivers/pwm/pwm-mxs.c
+++ b/drivers/pwm/pwm-mxs.c
@@ -52,15 +52,18 @@ static int mxs_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
 	unsigned long rate;
 	unsigned long long c;
 
+    unsigned const int cdiv[PERIOD_CDIV_MAX] = {1, 2, 4, 8, 16, 64, 256, 1024};
+
 	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;
 	}
 
-- 
1.7.10.4


  reply	other threads:[~2015-02-18  8:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-18  8:18 [PATCH 0/1] fix for " Gaetan Hug
2015-02-18  8:18 ` Gaetan Hug [this message]
2015-02-18 12:11   ` [PATCH 1/1] fixing " Thierry Reding
2015-02-18 12:08 ` [PATCH 0/1] fix for " Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1424247536-16476-2-git-send-email-ghug@induct.be \
    --to=ghug@induct.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®