diff mbox series

[1/3] tty: serial: meson: modify request_irq and free_irq

Message ID 20211221071634.25980-2-yu.tu@amlogic.com (mailing list archive)
State New, archived
Headers show
Series the UART driver compatible with the Amlogic Meson S4 SoC | expand

Commit Message

Yu Tu Dec. 21, 2021, 7:16 a.m. UTC
Change request_irq to devm_request_irq and free_irq to devm_free_irq.
It's better to change the code this way.

The IRQF_SHARED interrupt flag was added because an interrupt error was
detected when the serial port was opened twice in a row on the project.

Signed-off-by: Yu Tu <yu.tu@amlogic.com>
---
 drivers/tty/serial/meson_uart.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Greg KH Dec. 21, 2021, 7:30 a.m. UTC | #1
On Tue, Dec 21, 2021 at 03:16:32PM +0800, Yu Tu wrote:
> Change request_irq to devm_request_irq and free_irq to devm_free_irq.
> It's better to change the code this way.

Why?  What did this fix up?  You still are manually requesting and
freeing the irq.  What bug did you fix?

> 
> The IRQF_SHARED interrupt flag was added because an interrupt error was
> detected when the serial port was opened twice in a row on the project.

That is a different change.  Make that a different patch.

thanks,

greg k-h
Yu Tu Dec. 22, 2021, 8:44 a.m. UTC | #2
On 2021/12/21 15:30, Greg Kroah-Hartman wrote:
> [ EXTERNAL EMAIL ]
> 
> On Tue, Dec 21, 2021 at 03:16:32PM +0800, Yu Tu wrote:
>> Change request_irq to devm_request_irq and free_irq to devm_free_irq.
>> It's better to change the code this way.
> 
> Why?  What did this fix up?  You still are manually requesting and
> freeing the irq.  What bug did you fix?
> 
I think this is exactly what you said. It's not necessary.
>>
>> The IRQF_SHARED interrupt flag was added because an interrupt error was
>> detected when the serial port was opened twice in a row on the project.
> 
> That is a different change.  Make that a different patch.
> 
The main purpose of this change is that I found some users in the actual 
project with the following usages:
(1)open(/dev/ttyAML0);
(2)open(/dev/ttyAML0);
The open function calls the meson_uart_startup function. If this is the 
case, an interrupt error is reported.So So the IRQF_SHARED flag was added.

I'm going to do this for now, remove free_irq and request_irq 
function,then add devm_request_irq in meson_uart_probe function.
This solves the above problem without adding IRQF_SHARED.
> thanks,
> 
> greg k-h
>
diff mbox series

Patch

diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index d2c08b760f83..02fafb8229d2 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -121,7 +121,7 @@  static void meson_uart_shutdown(struct uart_port *port)
 	unsigned long flags;
 	u32 val;
 
-	free_irq(port->irq, port);
+	devm_free_irq(port->dev, port->irq, port);
 
 	spin_lock_irqsave(&port->lock, flags);
 
@@ -287,8 +287,8 @@  static int meson_uart_startup(struct uart_port *port)
 	val = (AML_UART_RECV_IRQ(1) | AML_UART_XMIT_IRQ(port->fifosize / 2));
 	writel(val, port->membase + AML_UART_MISC);
 
-	ret = request_irq(port->irq, meson_uart_interrupt, 0,
-			  port->name, port);
+	ret = devm_request_irq(port->dev, port->irq, meson_uart_interrupt,
+			       IRQF_SHARED, port->name, port);
 
 	return ret;
 }