[PATCH 5/9] spi: spi-sun6i: sun6i_spi_drain_fifo(): introduce sun6i_spi_get_rx_fifo_count() and make use of it
Maxime Ripard
maxime at cerno.tech
Mon Jul 6 08:36:21 EDT 2020
On Mon, Jul 06, 2020 at 09:17:57AM +0200, Marc Kleine-Budde wrote:
> This patch introduces the function sun6i_spi_get_rx_fifo_count(), similar to
> the existing sun6i_spi_get_tx_fifo_count(), to make the sun6i_spi_drain_fifo()
> function a bit easier to read.
>
> Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
> ---
> drivers/spi/spi-sun6i.c | 15 +++++++++++----
> 1 file changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/spi/spi-sun6i.c b/drivers/spi/spi-sun6i.c
> index 882492774986..f70d14229483 100644
> --- a/drivers/spi/spi-sun6i.c
> +++ b/drivers/spi/spi-sun6i.c
> @@ -106,6 +106,15 @@ static inline void sun6i_spi_write(struct sun6i_spi *sspi, u32 reg, u32 value)
> writel(value, sspi->base_addr + reg);
> }
>
> +static inline u32 sun6i_spi_get_rx_fifo_count(struct sun6i_spi *sspi)
> +{
> + u32 reg = sun6i_spi_read(sspi, SUN6I_FIFO_STA_REG);
> +
> + reg >>= SUN6I_FIFO_STA_RF_CNT_BITS;
> +
> + return reg & SUN6I_FIFO_STA_RF_CNT_MASK;
> +}
> +
I guess we could just use FIELD_GET here?
Looks good otherwise, thanks!
Maxime
More information about the linux-arm-kernel
mailing list