diff mbox series

[v2,2/2] spi: realtek-rtl: Improve readability when clearing the size mask

Message ID 20220728152118.1429161-3-martin.blumenstingl@googlemail.com (mailing list archive)
State Superseded
Headers show
Series spi: realtek-rtl: two small improvements | expand

Commit Message

Martin Blumenstingl July 28, 2022, 3:21 p.m. UTC
Define the bitmask RTL_SPI_SFCSR_LEN_MASK so it only sets the bits of
this specific part of the register instead of setting all bits except
the relevant ones. This makes it consistent with single bit macros in
the spi-realtek-rtl driver as well as with the approach that many other
drivers use.

Suggested-by: Sander Vanheule <sander@svanheule.net>
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/spi/spi-realtek-rtl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Sander Vanheule July 28, 2022, 6:40 p.m. UTC | #1
On Thu, 2022-07-28 at 17:21 +0200, Martin Blumenstingl wrote:
> Define the bitmask RTL_SPI_SFCSR_LEN_MASK so it only sets the bits of
> this specific part of the register instead of setting all bits except
> the relevant ones. This makes it consistent with single bit macros in
> the spi-realtek-rtl driver as well as with the approach that many other
> drivers use.
> 
> Suggested-by: Sander Vanheule <sander@svanheule.net>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>

FWIW
Tested-by: Sander Vanheule <sander@svanheule.net>

on my Netgear GS110TPP v1.

> ---
>  drivers/spi/spi-realtek-rtl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/spi/spi-realtek-rtl.c b/drivers/spi/spi-realtek-rtl.c
> index 866b0477dbd7..0371d44cbfbd 100644
> --- a/drivers/spi/spi-realtek-rtl.c
> +++ b/drivers/spi/spi-realtek-rtl.c
> @@ -20,7 +20,7 @@ struct rtspi {
>  #define RTL_SPI_SFCSR_CSB1             BIT(30)
>  #define RTL_SPI_SFCSR_RDY              BIT(27)
>  #define RTL_SPI_SFCSR_CS               BIT(24)
> -#define RTL_SPI_SFCSR_LEN_MASK         ~(0x03 << 28)
> +#define RTL_SPI_SFCSR_LEN_MASK         (0x03 << 28)
>  #define RTL_SPI_SFCSR_LEN1             (0x00 << 28)
>  #define RTL_SPI_SFCSR_LEN4             (0x03 << 28)
>  
> @@ -49,7 +49,7 @@ static void set_size(struct rtspi *rtspi, int size)
>         u32 value;
>  
>         value = readl(REG(RTL_SPI_SFCSR));
> -       value &= RTL_SPI_SFCSR_LEN_MASK;
> +       value &= ~RTL_SPI_SFCSR_LEN_MASK;
>         if (size == 4)
>                 value |= RTL_SPI_SFCSR_LEN4;
>         else if (size == 1)
diff mbox series

Patch

diff --git a/drivers/spi/spi-realtek-rtl.c b/drivers/spi/spi-realtek-rtl.c
index 866b0477dbd7..0371d44cbfbd 100644
--- a/drivers/spi/spi-realtek-rtl.c
+++ b/drivers/spi/spi-realtek-rtl.c
@@ -20,7 +20,7 @@  struct rtspi {
 #define RTL_SPI_SFCSR_CSB1		BIT(30)
 #define RTL_SPI_SFCSR_RDY		BIT(27)
 #define RTL_SPI_SFCSR_CS		BIT(24)
-#define RTL_SPI_SFCSR_LEN_MASK		~(0x03 << 28)
+#define RTL_SPI_SFCSR_LEN_MASK		(0x03 << 28)
 #define RTL_SPI_SFCSR_LEN1		(0x00 << 28)
 #define RTL_SPI_SFCSR_LEN4		(0x03 << 28)
 
@@ -49,7 +49,7 @@  static void set_size(struct rtspi *rtspi, int size)
 	u32 value;
 
 	value = readl(REG(RTL_SPI_SFCSR));
-	value &= RTL_SPI_SFCSR_LEN_MASK;
+	value &= ~RTL_SPI_SFCSR_LEN_MASK;
 	if (size == 4)
 		value |= RTL_SPI_SFCSR_LEN4;
 	else if (size == 1)