mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/3] spi: mvebu: various non-critical improvements to armada_370_xp_spi_set_baudrate
Date: Thu,  8 Dec 2016 10:05:44 +0100	[thread overview]
Message-ID: <20161208090544.10267-3-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20161208090544.10267-1-u.kleine-koenig@pengutronix.de>

 - Initialize pdiv in declaration
 - fix format specifiers
 - simplify range check, pdiv can never be > 7

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/spi/mvebu_spi.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/mvebu_spi.c b/drivers/spi/mvebu_spi.c
index 319d213872e0..58ac6057afe3 100644
--- a/drivers/spi/mvebu_spi.c
+++ b/drivers/spi/mvebu_spi.c
@@ -135,22 +135,21 @@ static int mvebu_spi_set_baudrate(struct mvebu_spi *p, u32 speed)
 #if defined(CONFIG_ARCH_ARMADA_370) || defined(CONFIG_ARCH_ARMADA_XP)
 static int armada_370_xp_spi_set_baudrate(struct mvebu_spi *p, u32 speed)
 {
-	u32 pscl, pdiv, val;
+	u32 pscl, pdiv = 0, val;
 
 	/* prescaler values: 1,2,3,...,15 */
 	pscl = DIV_ROUND_UP(clk_get_rate(p->clk), speed);
 
 	/* additional prescaler divider: 1, 2, 4, 8, 16, 32, 64, 128 */
-	pdiv = 0;
 	while (pscl > 15 && pdiv <= 7) {
 		pscl = DIV_ROUND_UP(pscl, 2);
 		pdiv++;
 	}
 
-	dev_dbg(p->master.dev, "%s: clk = %lu, speed = %u, pscl = %d, pdiv = %d\n",
+	dev_dbg(p->master.dev, "%s: clk = %lu, speed = %u, pscl = %u, pdiv = %u\n",
 		__func__, clk_get_rate(p->clk), speed, pscl, pdiv);
 
-	if (pscl > 15 || pdiv > 7)
+	if (pscl > 15)
 		return -EINVAL;
 
 	val = readl(p->base + SPI_IF_CONFIG) & ~(IF_CLK_PRESCALE_MASK);
-- 
2.10.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2016-12-08  9:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-08  9:05 [PATCH 1/3] spi: mvebu: fix register macros for Armada 370/XP clock divider Uwe Kleine-König
2016-12-08  9:05 ` [PATCH 2/3] spi: mvebu: make sure the value calculated for PSCL is also used Uwe Kleine-König
2016-12-08  9:05 ` Uwe Kleine-König [this message]
2016-12-12  5:15 ` [PATCH 1/3] spi: mvebu: fix register macros for Armada 370/XP clock divider Sascha Hauer
2017-01-11 16:33   ` Uwe Kleine-König
2017-01-12  6:44     ` Sascha Hauer

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=20161208090544.10267-3-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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