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

Commit f13639dc authored by Marek Vasut's avatar Marek Vasut Committed by Mark Brown
Browse files

mxs/spi: Rework the mxs_ssp_timeout to be more readable



Rework the mxs_ssp_timeout() function to make it a bit more readable
and hopefully less error prone. Also, have only one successful exit
from the function and one failing exit instead of two.

Finally, discard the udelay() from this function altogether, as this
tightloop is quick enough it's pointless.

Signed-off-by: default avatarMarek Vasut <marex@denx.de>
Signed-off-by: default avatarMark Brown <broonie@opensource.wolfsonmicro.com>
parent 727c10e3
Loading
Loading
Loading
Loading
+9 −11
Original line number Diff line number Diff line
@@ -177,26 +177,24 @@ static inline void mxs_spi_disable(struct mxs_spi *spi)

static int mxs_ssp_wait(struct mxs_spi *spi, int offset, int mask, bool set)
{
	unsigned long timeout = jiffies + msecs_to_jiffies(SSP_TIMEOUT);
	const unsigned long timeout = jiffies + msecs_to_jiffies(SSP_TIMEOUT);
	struct mxs_ssp *ssp = &spi->ssp;
	uint32_t reg;

	while (1) {
	do {
		reg = readl_relaxed(ssp->base + offset);

		if (set && ((reg & mask) == mask))
			break;
		if (!set)
			reg = ~reg;

		if (!set && ((~reg & mask) == mask))
			break;
		reg &= mask;

		udelay(1);
		if (reg == mask)
			return 0;
	} while (time_before(jiffies, timeout));

		if (time_after(jiffies, timeout))
	return -ETIMEDOUT;
}
	return 0;
}

static void mxs_ssp_dma_irq_callback(void *param)
{