Skip to contentSkip to conversation

spi: sh-hspi: Remove duplicate code to set default transfer speed

PATCH Applied Axel Lin 3 participants 3 messages Mar 2, 2014 – Mar 3, 2014 SPI

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 spi: sh-hspi: Remove duplicate code to set default transfer speed

In the implementation of __spi_validate(), spi core will use spi device's max speed as default transfer speed if it is not set for this transfer. So we can remove the same logic in hspi_hw_setup().

---
 drivers/spi/spi-sh-hspi.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/spi/spi-sh-hspi.c +2 -7
index 3c5d3b8..7435626 100644
@@ -113,14 +113,9 @@ static void hspi_hw_setup(struct hspi_priv *hspi,
 {
 	struct spi_device *spi = msg->spi;
 	struct device *dev = hspi->dev;
-	u32 target_rate;
 	u32 spcr, idiv_clk;
 	u32 rate, best_rate, min, tmp;
 
-	target_rate = t ? t->speed_hz : 0;
-	if (!target_rate)
-		target_rate = spi->max_speed_hz;
-
 	/*
 	 * find best IDIV/CLKCx settings
 	 */
@@ -140,7 +135,7 @@ static void hspi_hw_setup(struct hspi_priv *hspi,
 		rate /= (((idiv_clk & 0x1F) + 1) * 2);
 
 		/* save best settings */
-		tmp = abs(target_rate - rate);
+		tmp = abs(t->speed_hz - rate);
 		if (tmp < min) {
 			min = tmp;
 			spcr = idiv_clk;
@@ -153,7 +148,7 @@ static void hspi_hw_setup(struct hspi_priv *hspi,
 	if (spi->mode & SPI_CPOL)
 		spcr |= 1 << 6;
 
-	dev_dbg(dev, "speed %d/%d\n", target_rate, best_rate);
+	dev_dbg(dev, "speed %d/%d\n", t->speed_hz, best_rate);
 
 	hspi_write(hspi, SPCR, spcr);
 	hspi_write(hspi, SPSR, 0x0);
Signature · 8 lines
1.8.1.2



--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Axel Lin

In the implementation of __spi_validate(), spi core will use spi device's max speed as default transfer speed if it is not set for this transfer. So we can remove the same logic in hspi_hw_setup().

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

Applied
#2 lore raw
In reply to Axel Lin
Quoted 3 lines · Axel Lin

In the implementation of __spi_validate(), spi core will use spi device's max speed as default transfer speed if it is not set for this transfer. So we can remove the same logic in hspi_hw_setup().

Applied, thanks.