Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e428a420 authored by Axel Lin's avatar Axel Lin Committed by Mark Brown
Browse files

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().

Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
Acked-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarMark Brown <broonie@linaro.org>
parent 80d68ca5
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -111,14 +111,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
	 */
@@ -138,7 +133,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;
@@ -151,7 +146,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);