linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] 8250_dwlib: Convert bitops to newer form
@ 2022-06-30 10:05 Ilpo Järvinen
  2022-06-30 10:17 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Ilpo Järvinen @ 2022-06-30 10:05 UTC (permalink / raw)
  To: Ilpo Järvinen, Andy Shevchenko, Greg Kroah-Hartman,
	Jiri Slaby, linux-serial, linux-kernel

Instead of open-coding, use BIT(), GENMASK(), and FIELD_GET() helpers.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
 drivers/tty/serial/8250/8250_dwlib.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c
index da330ef46446..a8bbed74ea70 100644
--- a/drivers/tty/serial/8250/8250_dwlib.c
+++ b/drivers/tty/serial/8250/8250_dwlib.c
@@ -46,21 +46,21 @@
 #define DW_UART_LCR_EXT_TRANSMIT_MODE	BIT(3)
 
 /* Component Parameter Register bits */
-#define DW_UART_CPR_ABP_DATA_WIDTH	(3 << 0)
-#define DW_UART_CPR_AFCE_MODE		(1 << 4)
-#define DW_UART_CPR_THRE_MODE		(1 << 5)
-#define DW_UART_CPR_SIR_MODE		(1 << 6)
-#define DW_UART_CPR_SIR_LP_MODE		(1 << 7)
-#define DW_UART_CPR_ADDITIONAL_FEATURES	(1 << 8)
-#define DW_UART_CPR_FIFO_ACCESS		(1 << 9)
-#define DW_UART_CPR_FIFO_STAT		(1 << 10)
-#define DW_UART_CPR_SHADOW		(1 << 11)
-#define DW_UART_CPR_ENCODED_PARMS	(1 << 12)
-#define DW_UART_CPR_DMA_EXTRA		(1 << 13)
-#define DW_UART_CPR_FIFO_MODE		(0xff << 16)
+#define DW_UART_CPR_ABP_DATA_WIDTH	GENMASK(1, 0)
+#define DW_UART_CPR_AFCE_MODE		BIT(4)
+#define DW_UART_CPR_THRE_MODE		BIT(5)
+#define DW_UART_CPR_SIR_MODE		BIT(6)
+#define DW_UART_CPR_SIR_LP_MODE		BIT(7)
+#define DW_UART_CPR_ADDITIONAL_FEATURES	BIT(8)
+#define DW_UART_CPR_FIFO_ACCESS		BIT(9)
+#define DW_UART_CPR_FIFO_STAT		BIT(10)
+#define DW_UART_CPR_SHADOW		BIT(11)
+#define DW_UART_CPR_ENCODED_PARMS	BIT(12)
+#define DW_UART_CPR_DMA_EXTRA		BIT(13)
+#define DW_UART_CPR_FIFO_MODE		GENMASK(23, 16)
 
 /* Helper for FIFO size calculation */
-#define DW_UART_CPR_FIFO_SIZE(a)	(((a >> 16) & 0xff) * 16)
+#define DW_UART_CPR_FIFO_SIZE(a)	(FIELD_GET(DW_UART_CPR_FIFO_MODE, (a)) * 16)
 
 /*
  * divisor = div(I) + div(F)
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] 8250_dwlib: Convert bitops to newer form
  2022-06-30 10:05 [PATCH 1/1] 8250_dwlib: Convert bitops to newer form Ilpo Järvinen
@ 2022-06-30 10:17 ` Andy Shevchenko
  2022-06-30 10:20   ` Ilpo Järvinen
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2022-06-30 10:17 UTC (permalink / raw)
  To: Ilpo Järvinen
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Jiri Slaby,
	open list:SERIAL DRIVERS, Linux Kernel Mailing List

On Thu, Jun 30, 2022 at 12:08 PM Ilpo Järvinen
<ilpo.jarvinen@linux.intel.com> wrote:
>
> Instead of open-coding, use BIT(), GENMASK(), and FIELD_GET() helpers.

FIELD_GET() requires bitfield.h to be included. Is this the case already?
If so,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
>  drivers/tty/serial/8250/8250_dwlib.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c
> index da330ef46446..a8bbed74ea70 100644
> --- a/drivers/tty/serial/8250/8250_dwlib.c
> +++ b/drivers/tty/serial/8250/8250_dwlib.c
> @@ -46,21 +46,21 @@
>  #define DW_UART_LCR_EXT_TRANSMIT_MODE  BIT(3)
>
>  /* Component Parameter Register bits */
> -#define DW_UART_CPR_ABP_DATA_WIDTH     (3 << 0)
> -#define DW_UART_CPR_AFCE_MODE          (1 << 4)
> -#define DW_UART_CPR_THRE_MODE          (1 << 5)
> -#define DW_UART_CPR_SIR_MODE           (1 << 6)
> -#define DW_UART_CPR_SIR_LP_MODE                (1 << 7)
> -#define DW_UART_CPR_ADDITIONAL_FEATURES        (1 << 8)
> -#define DW_UART_CPR_FIFO_ACCESS                (1 << 9)
> -#define DW_UART_CPR_FIFO_STAT          (1 << 10)
> -#define DW_UART_CPR_SHADOW             (1 << 11)
> -#define DW_UART_CPR_ENCODED_PARMS      (1 << 12)
> -#define DW_UART_CPR_DMA_EXTRA          (1 << 13)
> -#define DW_UART_CPR_FIFO_MODE          (0xff << 16)
> +#define DW_UART_CPR_ABP_DATA_WIDTH     GENMASK(1, 0)
> +#define DW_UART_CPR_AFCE_MODE          BIT(4)
> +#define DW_UART_CPR_THRE_MODE          BIT(5)
> +#define DW_UART_CPR_SIR_MODE           BIT(6)
> +#define DW_UART_CPR_SIR_LP_MODE                BIT(7)
> +#define DW_UART_CPR_ADDITIONAL_FEATURES        BIT(8)
> +#define DW_UART_CPR_FIFO_ACCESS                BIT(9)
> +#define DW_UART_CPR_FIFO_STAT          BIT(10)
> +#define DW_UART_CPR_SHADOW             BIT(11)
> +#define DW_UART_CPR_ENCODED_PARMS      BIT(12)
> +#define DW_UART_CPR_DMA_EXTRA          BIT(13)
> +#define DW_UART_CPR_FIFO_MODE          GENMASK(23, 16)
>
>  /* Helper for FIFO size calculation */
> -#define DW_UART_CPR_FIFO_SIZE(a)       (((a >> 16) & 0xff) * 16)
> +#define DW_UART_CPR_FIFO_SIZE(a)       (FIELD_GET(DW_UART_CPR_FIFO_MODE, (a)) * 16)
>
>  /*
>   * divisor = div(I) + div(F)
> --
> 2.30.2
>


-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] 8250_dwlib: Convert bitops to newer form
  2022-06-30 10:17 ` Andy Shevchenko
@ 2022-06-30 10:20   ` Ilpo Järvinen
  0 siblings, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2022-06-30 10:20 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Jiri Slaby,
	open list:SERIAL DRIVERS, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 2566 bytes --]

On Thu, 30 Jun 2022, Andy Shevchenko wrote:

> On Thu, Jun 30, 2022 at 12:08 PM Ilpo Järvinen
> <ilpo.jarvinen@linux.intel.com> wrote:
> >
> > Instead of open-coding, use BIT(), GENMASK(), and FIELD_GET() helpers.
> 
> FIELD_GET() requires bitfield.h to be included. Is this the case already?

It's there already.

-- 
 i.

> If so,
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> 
> > Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> > ---
> >  drivers/tty/serial/8250/8250_dwlib.c | 26 +++++++++++++-------------
> >  1 file changed, 13 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c
> > index da330ef46446..a8bbed74ea70 100644
> > --- a/drivers/tty/serial/8250/8250_dwlib.c
> > +++ b/drivers/tty/serial/8250/8250_dwlib.c
> > @@ -46,21 +46,21 @@
> >  #define DW_UART_LCR_EXT_TRANSMIT_MODE  BIT(3)
> >
> >  /* Component Parameter Register bits */
> > -#define DW_UART_CPR_ABP_DATA_WIDTH     (3 << 0)
> > -#define DW_UART_CPR_AFCE_MODE          (1 << 4)
> > -#define DW_UART_CPR_THRE_MODE          (1 << 5)
> > -#define DW_UART_CPR_SIR_MODE           (1 << 6)
> > -#define DW_UART_CPR_SIR_LP_MODE                (1 << 7)
> > -#define DW_UART_CPR_ADDITIONAL_FEATURES        (1 << 8)
> > -#define DW_UART_CPR_FIFO_ACCESS                (1 << 9)
> > -#define DW_UART_CPR_FIFO_STAT          (1 << 10)
> > -#define DW_UART_CPR_SHADOW             (1 << 11)
> > -#define DW_UART_CPR_ENCODED_PARMS      (1 << 12)
> > -#define DW_UART_CPR_DMA_EXTRA          (1 << 13)
> > -#define DW_UART_CPR_FIFO_MODE          (0xff << 16)
> > +#define DW_UART_CPR_ABP_DATA_WIDTH     GENMASK(1, 0)
> > +#define DW_UART_CPR_AFCE_MODE          BIT(4)
> > +#define DW_UART_CPR_THRE_MODE          BIT(5)
> > +#define DW_UART_CPR_SIR_MODE           BIT(6)
> > +#define DW_UART_CPR_SIR_LP_MODE                BIT(7)
> > +#define DW_UART_CPR_ADDITIONAL_FEATURES        BIT(8)
> > +#define DW_UART_CPR_FIFO_ACCESS                BIT(9)
> > +#define DW_UART_CPR_FIFO_STAT          BIT(10)
> > +#define DW_UART_CPR_SHADOW             BIT(11)
> > +#define DW_UART_CPR_ENCODED_PARMS      BIT(12)
> > +#define DW_UART_CPR_DMA_EXTRA          BIT(13)
> > +#define DW_UART_CPR_FIFO_MODE          GENMASK(23, 16)
> >
> >  /* Helper for FIFO size calculation */
> > -#define DW_UART_CPR_FIFO_SIZE(a)       (((a >> 16) & 0xff) * 16)
> > +#define DW_UART_CPR_FIFO_SIZE(a)       (FIELD_GET(DW_UART_CPR_FIFO_MODE, (a)) * 16)
> >
> >  /*
> >   * divisor = div(I) + div(F)
> > --
> > 2.30.2
> >
> 
> 
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-30 10:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-30 10:05 [PATCH 1/1] 8250_dwlib: Convert bitops to newer form Ilpo Järvinen
2022-06-30 10:17 ` Andy Shevchenko
2022-06-30 10:20   ` Ilpo Järvinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).