public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/1] serial: 8520_ce4100: Reuse mem_serial_in() in ce4100_mem_serial_in()
@ 2025-06-30 12:54 Andy Shevchenko
  2025-06-30 13:02 ` Jiri Slaby
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2025-06-30 12:54 UTC (permalink / raw)
  To: linux-kernel, linux-serial
  Cc: Greg Kroah-Hartman, Jiri Slaby, Andy Shevchenko

In one place in ce4100_mem_serial_in() the code may be replaced with
mem_serial_in() call. Do it so and collapse two conditionals into one.

Suggested-by: Jiri Slaby <jirislaby@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/8250/8250_ce4100.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_ce4100.c b/drivers/tty/serial/8250/8250_ce4100.c
index 3dd88f372a51..8221b872fd33 100644
--- a/drivers/tty/serial/8250/8250_ce4100.c
+++ b/drivers/tty/serial/8250/8250_ce4100.c
@@ -35,13 +35,8 @@ static u32 ce4100_mem_serial_in(struct uart_port *p, unsigned int offset)
 {
 	u32 ret, ier, lsr;
 
-	if (offset != UART_IIR)
-		return mem_serial_in(p, offset);
-
-	offset <<= p->regshift;
-
-	ret = readl(p->membase + offset);
-	if (!(ret & UART_IIR_NO_INT))
+	ret = mem_serial_in(p, offset);
+	if (!(offset == UART_IIR) && (ret & UART_IIR_NO_INT))
 		return ret;
 
 	/* see if the TX interrupt should have really set */
-- 
2.47.2


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

* Re: [PATCH v1 1/1] serial: 8520_ce4100: Reuse mem_serial_in() in ce4100_mem_serial_in()
  2025-06-30 12:54 [PATCH v1 1/1] serial: 8520_ce4100: Reuse mem_serial_in() in ce4100_mem_serial_in() Andy Shevchenko
@ 2025-06-30 13:02 ` Jiri Slaby
  2025-06-30 13:30   ` Andy Shevchenko
  0 siblings, 1 reply; 4+ messages in thread
From: Jiri Slaby @ 2025-06-30 13:02 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel, linux-serial; +Cc: Greg Kroah-Hartman

On 30. 06. 25, 14:54, Andy Shevchenko wrote:
> In one place in ce4100_mem_serial_in() the code may be replaced with
> mem_serial_in() call. Do it so and collapse two conditionals into one.
> 
> Suggested-by: Jiri Slaby <jirislaby@kernel.org>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>   drivers/tty/serial/8250/8250_ce4100.c | 9 ++-------
>   1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/tty/serial/8250/8250_ce4100.c b/drivers/tty/serial/8250/8250_ce4100.c
> index 3dd88f372a51..8221b872fd33 100644
> --- a/drivers/tty/serial/8250/8250_ce4100.c
> +++ b/drivers/tty/serial/8250/8250_ce4100.c
> @@ -35,13 +35,8 @@ static u32 ce4100_mem_serial_in(struct uart_port *p, unsigned int offset)
>   {
>   	u32 ret, ier, lsr;
>   
> -	if (offset != UART_IIR)
> -		return mem_serial_in(p, offset);
> -
> -	offset <<= p->regshift;
> -
> -	ret = readl(p->membase + offset);
> -	if (!(ret & UART_IIR_NO_INT))
> +	ret = mem_serial_in(p, offset);
> +	if (!(offset == UART_IIR) && (ret & UART_IIR_NO_INT))

I am in haste, but a misplaced right paren (should be at the end)?

>   		return ret;
>   
>   	/* see if the TX interrupt should have really set */


-- 
js
suse labs

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

* Re: [PATCH v1 1/1] serial: 8520_ce4100: Reuse mem_serial_in() in ce4100_mem_serial_in()
  2025-06-30 13:02 ` Jiri Slaby
@ 2025-06-30 13:30   ` Andy Shevchenko
  2025-07-01  5:14     ` Jiri Slaby
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2025-06-30 13:30 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: linux-kernel, linux-serial, Greg Kroah-Hartman

On Mon, Jun 30, 2025 at 03:02:11PM +0200, Jiri Slaby wrote:
> On 30. 06. 25, 14:54, Andy Shevchenko wrote:
> > In one place in ce4100_mem_serial_in() the code may be replaced with
> > mem_serial_in() call. Do it so and collapse two conditionals into one.

...

> >   	u32 ret, ier, lsr;
> > -	if (offset != UART_IIR)
> > -		return mem_serial_in(p, offset);
> > -
> > -	offset <<= p->regshift;
> > -
> > -	ret = readl(p->membase + offset);
> > -	if (!(ret & UART_IIR_NO_INT))
> > +	ret = mem_serial_in(p, offset);
> > +	if (!(offset == UART_IIR) && (ret & UART_IIR_NO_INT))
> 
> I am in haste, but a misplaced right paren (should be at the end)?

Ah, good catch! It's probably better in the original form, i.e.

	if ((offset != UART_IIR) || !(ret & UART_IIR_NO_INT))

What do you think?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v1 1/1] serial: 8520_ce4100: Reuse mem_serial_in() in ce4100_mem_serial_in()
  2025-06-30 13:30   ` Andy Shevchenko
@ 2025-07-01  5:14     ` Jiri Slaby
  0 siblings, 0 replies; 4+ messages in thread
From: Jiri Slaby @ 2025-07-01  5:14 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, linux-serial, Greg Kroah-Hartman

On 30. 06. 25, 15:30, Andy Shevchenko wrote:
> On Mon, Jun 30, 2025 at 03:02:11PM +0200, Jiri Slaby wrote:
>> On 30. 06. 25, 14:54, Andy Shevchenko wrote:
>>> In one place in ce4100_mem_serial_in() the code may be replaced with
>>> mem_serial_in() call. Do it so and collapse two conditionals into one.
> 
> ...
> 
>>>    	u32 ret, ier, lsr;
>>> -	if (offset != UART_IIR)
>>> -		return mem_serial_in(p, offset);
>>> -
>>> -	offset <<= p->regshift;
>>> -
>>> -	ret = readl(p->membase + offset);
>>> -	if (!(ret & UART_IIR_NO_INT))
>>> +	ret = mem_serial_in(p, offset);
>>> +	if (!(offset == UART_IIR) && (ret & UART_IIR_NO_INT))
>>
>> I am in haste, but a misplaced right paren (should be at the end)?
> 
> Ah, good catch! It's probably better in the original form, i.e.
> 
> 	if ((offset != UART_IIR) || !(ret & UART_IIR_NO_INT))
> 
> What do you think?

Without the parens around the offset check, yes.

-- 
js
suse labs

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

end of thread, other threads:[~2025-07-01  5:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30 12:54 [PATCH v1 1/1] serial: 8520_ce4100: Reuse mem_serial_in() in ce4100_mem_serial_in() Andy Shevchenko
2025-06-30 13:02 ` Jiri Slaby
2025-06-30 13:30   ` Andy Shevchenko
2025-07-01  5:14     ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox