[PATCH v3 02/14] serial: liteuart: use bit number macros

Gabriel Somlo posted 14 patches 3 years, 5 months ago
There is a newer version of this series
[PATCH v3 02/14] serial: liteuart: use bit number macros
Posted by Gabriel Somlo 3 years, 5 months ago
Replace magic bit constants (e.g., 1, 2, 4) with BIT(x) expressions.

Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
---
 drivers/tty/serial/liteuart.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
index 32b81bd03d0c..1497d4cdc221 100644
--- a/drivers/tty/serial/liteuart.c
+++ b/drivers/tty/serial/liteuart.c
@@ -38,8 +38,8 @@
 #define OFF_EV_ENABLE	0x14
 
 /* events */
-#define EV_TX		0x1
-#define EV_RX		0x2
+#define EV_TX		BIT(0)
+#define EV_RX		BIT(1)
 
 struct liteuart_port {
 	struct uart_port port;
-- 
2.37.3
Re: [PATCH v3 02/14] serial: liteuart: use bit number macros
Posted by Ilpo Järvinen 3 years, 4 months ago
On Sat, 12 Nov 2022, Gabriel Somlo wrote:

> Replace magic bit constants (e.g., 1, 2, 4) with BIT(x) expressions.
> 
> Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
> ---
>  drivers/tty/serial/liteuart.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
> index 32b81bd03d0c..1497d4cdc221 100644
> --- a/drivers/tty/serial/liteuart.c
> +++ b/drivers/tty/serial/liteuart.c
> @@ -38,8 +38,8 @@
>  #define OFF_EV_ENABLE	0x14
>  
>  /* events */
> -#define EV_TX		0x1
> -#define EV_RX		0x2
> +#define EV_TX		BIT(0)
> +#define EV_RX		BIT(1)
>  
>  struct liteuart_port {
>  	struct uart_port port;
> 

This seems to assume some random header provides BIT() for you?

-- 
 i.
Re: [PATCH v3 02/14] serial: liteuart: use bit number macros
Posted by Gabriel L. Somlo 3 years, 4 months ago
On Tue, Nov 15, 2022 at 05:33:47PM +0200, Ilpo Järvinen wrote:
> On Sat, 12 Nov 2022, Gabriel Somlo wrote:
> 
> > Replace magic bit constants (e.g., 1, 2, 4) with BIT(x) expressions.
> > 
> > Signed-off-by: Gabriel Somlo <gsomlo@gmail.com>
> > ---
> >  drivers/tty/serial/liteuart.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
> > index 32b81bd03d0c..1497d4cdc221 100644
> > --- a/drivers/tty/serial/liteuart.c
> > +++ b/drivers/tty/serial/liteuart.c
> > @@ -38,8 +38,8 @@
> >  #define OFF_EV_ENABLE	0x14
> >  
> >  /* events */
> > -#define EV_TX		0x1
> > -#define EV_RX		0x2
> > +#define EV_TX		BIT(0)
> > +#define EV_RX		BIT(1)
> >  
> >  struct liteuart_port {
> >  	struct uart_port port;
> > 
> 
> This seems to assume some random header provides BIT() for you?

OK: version 4 of the series will have this commit explicitly
#include <linux/bits.h>, which right now is most likely brought
in implicitly by one or more of the existing headers.

Thanks,
--Gabriel