diff mbox series

[v2,2/2] tty: serial: samsung_tty: cast the interrupt's void *id just once

Message ID 20240807-samsung-tty-cleanup-v2-2-1db5afc9d41b@linaro.org (mailing list archive)
State New
Headers show
Series tty: serial: samsung_tty: simple cleanups | expand

Commit Message

André Draszik Aug. 7, 2024, 11:58 a.m. UTC
The interrupt handler routines and helpers are casting the 'void *'
pointer to 'struct exynos_uart_port *' all over the place.

There is no need for that, we can do the casting once and keep passing
the 'struct exynos_uart_port *', simplifying the code and saving a few
lines of code.

No functional changes.

Reviewed-by: Tudor Ambarus <tudor.ambarus@linaro.org>
Signed-off-by: André Draszik <andre.draszik@linaro.org>
---
v2: fix -Wdiscarded-qualifiers, sorry
---
 drivers/tty/serial/samsung_tty.c | 33 ++++++++++++++-------------------
 1 file changed, 14 insertions(+), 19 deletions(-)

Comments

Jiri Slaby Aug. 8, 2024, 7:31 a.m. UTC | #1
On 07. 08. 24, 13:58, André Draszik wrote:
> The interrupt handler routines and helpers are casting the 'void *'
> pointer to 'struct exynos_uart_port *' all over the place.
> 
> There is no need for that, we can do the casting once and keep passing
> the 'struct exynos_uart_port *', simplifying the code and saving a few
> lines of code.
> 
> No functional changes.
...
> @@ -944,17 +939,17 @@ static irqreturn_t s3c24xx_serial_tx_irq(void *id)
>   /* interrupt handler for s3c64xx and later SoC's.*/
>   static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
>   {
> -	const struct s3c24xx_uart_port *ourport = id;
> -	const struct uart_port *port = &ourport->port;
> +	struct s3c24xx_uart_port *ourport = id;
> +	struct uart_port *port = &ourport->port;
>   	u32 pend = rd_regl(port, S3C64XX_UINTP);
>   	irqreturn_t ret = IRQ_HANDLED;
>   
>   	if (pend & S3C64XX_UINTM_RXD_MSK) {
> -		ret = s3c24xx_serial_rx_irq(id);
> +		ret = s3c24xx_serial_rx_irq(ourport);
>   		wr_regl(port, S3C64XX_UINTP, S3C64XX_UINTM_RXD_MSK);
>   	}
>   	if (pend & S3C64XX_UINTM_TXD_MSK) {
> -		ret = s3c24xx_serial_tx_irq(id);
> +		ret = s3c24xx_serial_tx_irq(ourport);
>   		wr_regl(port, S3C64XX_UINTP, S3C64XX_UINTM_TXD_MSK);
>   	}
>   	return ret;
> @@ -963,19 +958,19 @@ static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
>   /* interrupt handler for Apple SoC's.*/
>   static irqreturn_t apple_serial_handle_irq(int irq, void *id)
>   {
> -	const struct s3c24xx_uart_port *ourport = id;
> -	const struct uart_port *port = &ourport->port;
> +	struct s3c24xx_uart_port *ourport = id;
> +	struct uart_port *port = &ourport->port;

No need to remove const from port here and above, right? (Only from 
ourport.)

Other than that, LGTM.

thanks,
André Draszik Aug. 8, 2024, 8:11 a.m. UTC | #2
On Thu, 2024-08-08 at 09:31 +0200, Jiri Slaby wrote:
> On 07. 08. 24, 13:58, André Draszik wrote:
> > The interrupt handler routines and helpers are casting the 'void *'
> > pointer to 'struct exynos_uart_port *' all over the place.
> > 
> > There is no need for that, we can do the casting once and keep passing
> > the 'struct exynos_uart_port *', simplifying the code and saving a few
> > lines of code.
> > 
> > No functional changes.
> ...
> > @@ -944,17 +939,17 @@ static irqreturn_t s3c24xx_serial_tx_irq(void *id)
> >   /* interrupt handler for s3c64xx and later SoC's.*/
> >   static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
> >   {
> > -	const struct s3c24xx_uart_port *ourport = id;
> > -	const struct uart_port *port = &ourport->port;
> > +	struct s3c24xx_uart_port *ourport = id;
> > +	struct uart_port *port = &ourport->port;
> >   	u32 pend = rd_regl(port, S3C64XX_UINTP);
> >   	irqreturn_t ret = IRQ_HANDLED;
> >   
> >   	if (pend & S3C64XX_UINTM_RXD_MSK) {
> > -		ret = s3c24xx_serial_rx_irq(id);
> > +		ret = s3c24xx_serial_rx_irq(ourport);
> >   		wr_regl(port, S3C64XX_UINTP, S3C64XX_UINTM_RXD_MSK);
> >   	}
> >   	if (pend & S3C64XX_UINTM_TXD_MSK) {
> > -		ret = s3c24xx_serial_tx_irq(id);
> > +		ret = s3c24xx_serial_tx_irq(ourport);
> >   		wr_regl(port, S3C64XX_UINTP, S3C64XX_UINTM_TXD_MSK);
> >   	}
> >   	return ret;
> > @@ -963,19 +958,19 @@ static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
> >   /* interrupt handler for Apple SoC's.*/
> >   static irqreturn_t apple_serial_handle_irq(int irq, void *id)
> >   {
> > -	const struct s3c24xx_uart_port *ourport = id;
> > -	const struct uart_port *port = &ourport->port;
> > +	struct s3c24xx_uart_port *ourport = id;
> > +	struct uart_port *port = &ourport->port;
> 
> No need to remove const from port here and above, right? (Only from 
> ourport.)

Jiri, you're right of course.

Thanks,
A.
diff mbox series

Patch

diff --git a/drivers/tty/serial/samsung_tty.c b/drivers/tty/serial/samsung_tty.c
index 1c6d0ffe5649..951e16c87471 100644
--- a/drivers/tty/serial/samsung_tty.c
+++ b/drivers/tty/serial/samsung_tty.c
@@ -707,9 +707,8 @@  static void enable_rx_pio(struct s3c24xx_uart_port *ourport)
 
 static void s3c24xx_serial_rx_drain_fifo(struct s3c24xx_uart_port *ourport);
 
-static irqreturn_t s3c24xx_serial_rx_chars_dma(void *dev_id)
+static irqreturn_t s3c24xx_serial_rx_chars_dma(struct s3c24xx_uart_port *ourport)
 {
-	struct s3c24xx_uart_port *ourport = dev_id;
 	struct uart_port *port = &ourport->port;
 	struct s3c24xx_uart_dma *dma = ourport->dma;
 	struct tty_struct *tty = tty_port_tty_get(&ourport->port.state->port);
@@ -843,9 +842,8 @@  static void s3c24xx_serial_rx_drain_fifo(struct s3c24xx_uart_port *ourport)
 	tty_flip_buffer_push(&port->state->port);
 }
 
-static irqreturn_t s3c24xx_serial_rx_chars_pio(void *dev_id)
+static irqreturn_t s3c24xx_serial_rx_chars_pio(struct s3c24xx_uart_port *ourport)
 {
-	struct s3c24xx_uart_port *ourport = dev_id;
 	struct uart_port *port = &ourport->port;
 
 	uart_port_lock(port);
@@ -855,13 +853,11 @@  static irqreturn_t s3c24xx_serial_rx_chars_pio(void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static irqreturn_t s3c24xx_serial_rx_irq(void *dev_id)
+static irqreturn_t s3c24xx_serial_rx_irq(struct s3c24xx_uart_port *ourport)
 {
-	struct s3c24xx_uart_port *ourport = dev_id;
-
 	if (ourport->dma && ourport->dma->rx_chan)
-		return s3c24xx_serial_rx_chars_dma(dev_id);
-	return s3c24xx_serial_rx_chars_pio(dev_id);
+		return s3c24xx_serial_rx_chars_dma(ourport);
+	return s3c24xx_serial_rx_chars_pio(ourport);
 }
 
 static void s3c24xx_serial_tx_chars(struct s3c24xx_uart_port *ourport)
@@ -928,9 +924,8 @@  static void s3c24xx_serial_tx_chars(struct s3c24xx_uart_port *ourport)
 		s3c24xx_serial_stop_tx(port);
 }
 
-static irqreturn_t s3c24xx_serial_tx_irq(void *id)
+static irqreturn_t s3c24xx_serial_tx_irq(struct s3c24xx_uart_port *ourport)
 {
-	struct s3c24xx_uart_port *ourport = id;
 	struct uart_port *port = &ourport->port;
 
 	uart_port_lock(port);
@@ -944,17 +939,17 @@  static irqreturn_t s3c24xx_serial_tx_irq(void *id)
 /* interrupt handler for s3c64xx and later SoC's.*/
 static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
 {
-	const struct s3c24xx_uart_port *ourport = id;
-	const struct uart_port *port = &ourport->port;
+	struct s3c24xx_uart_port *ourport = id;
+	struct uart_port *port = &ourport->port;
 	u32 pend = rd_regl(port, S3C64XX_UINTP);
 	irqreturn_t ret = IRQ_HANDLED;
 
 	if (pend & S3C64XX_UINTM_RXD_MSK) {
-		ret = s3c24xx_serial_rx_irq(id);
+		ret = s3c24xx_serial_rx_irq(ourport);
 		wr_regl(port, S3C64XX_UINTP, S3C64XX_UINTM_RXD_MSK);
 	}
 	if (pend & S3C64XX_UINTM_TXD_MSK) {
-		ret = s3c24xx_serial_tx_irq(id);
+		ret = s3c24xx_serial_tx_irq(ourport);
 		wr_regl(port, S3C64XX_UINTP, S3C64XX_UINTM_TXD_MSK);
 	}
 	return ret;
@@ -963,19 +958,19 @@  static irqreturn_t s3c64xx_serial_handle_irq(int irq, void *id)
 /* interrupt handler for Apple SoC's.*/
 static irqreturn_t apple_serial_handle_irq(int irq, void *id)
 {
-	const struct s3c24xx_uart_port *ourport = id;
-	const struct uart_port *port = &ourport->port;
+	struct s3c24xx_uart_port *ourport = id;
+	struct uart_port *port = &ourport->port;
 	u32 pend = rd_regl(port, S3C2410_UTRSTAT);
 	irqreturn_t ret = IRQ_NONE;
 
 	if (pend & (APPLE_S5L_UTRSTAT_RXTHRESH | APPLE_S5L_UTRSTAT_RXTO)) {
 		wr_regl(port, S3C2410_UTRSTAT,
 			APPLE_S5L_UTRSTAT_RXTHRESH | APPLE_S5L_UTRSTAT_RXTO);
-		ret = s3c24xx_serial_rx_irq(id);
+		ret = s3c24xx_serial_rx_irq(ourport);
 	}
 	if (pend & APPLE_S5L_UTRSTAT_TXTHRESH) {
 		wr_regl(port, S3C2410_UTRSTAT, APPLE_S5L_UTRSTAT_TXTHRESH);
-		ret = s3c24xx_serial_tx_irq(id);
+		ret = s3c24xx_serial_tx_irq(ourport);
 	}
 
 	return ret;