diff mbox

[v2,2/8] tty: serial: qcom_geni_serial: Cleanup redundant code

Message ID 1523302721-19439-3-git-send-email-kramasub@codeaurora.org (mailing list archive)
State Not Applicable, archived
Delegated to: Andy Gross
Headers show

Commit Message

Karthikeyan Ramasubramanian April 9, 2018, 7:38 p.m. UTC
* Remove redundant casting while using min_t
* Remove redundant initialization of port_setup flag
* Remove redundant error checking in get_tx_fifo_size
* Remove logging redundant error code in debug messages
* Remove redundant disable_irq before free_irq

Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
---
 drivers/tty/serial/qcom_geni_serial.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

Comments

Matthias Kaehlcke April 12, 2018, 10:30 p.m. UTC | #1
On Mon, Apr 09, 2018 at 01:38:35PM -0600, Karthikeyan Ramasubramanian wrote:
> * Remove redundant casting while using min_t
> * Remove redundant initialization of port_setup flag
> * Remove redundant error checking in get_tx_fifo_size
> * Remove logging redundant error code in debug messages
> * Remove redundant disable_irq before free_irq
> 
> Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
> ---
>  drivers/tty/serial/qcom_geni_serial.c | 18 +++++-------------
>  1 file changed, 5 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
> index 1652b1f..ae959d6 100644
> --- a/drivers/tty/serial/qcom_geni_serial.c
> +++ b/drivers/tty/serial/qcom_geni_serial.c
> @@ -309,7 +309,7 @@ static void qcom_geni_serial_wr_char(struct uart_port *uport, int ch)
>  		if (!qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS,
>  						M_TX_FIFO_WATERMARK_EN, true))
>  			break;
> -		chars_to_write = min_t(size_t, (size_t)(count - i), avail / 2);
> +		chars_to_write = min_t(size_t, count - i, avail / 2);
>  		uart_console_write(uport, s + i, chars_to_write,
>  						qcom_geni_serial_wr_char);
>  		writel_relaxed(M_TX_FIFO_WATERMARK_EN, uport->membase +
> @@ -602,7 +602,7 @@ static void qcom_geni_serial_handle_tx(struct uart_port *uport)
>  		unsigned int buf = 0;
>  		int c;
>  
> -		tx_bytes = min_t(size_t, remaining, (size_t)port->tx_bytes_pw);
> +		tx_bytes = min_t(size_t, remaining, port->tx_bytes_pw);
>  		for (c = 0; c < tx_bytes ; c++)
>  			buf |= (xmit->buf[tail + c] << (c * BITS_PER_BYTE));
>  
> @@ -675,9 +675,6 @@ static int get_tx_fifo_size(struct qcom_geni_serial_port *port)
>  {
>  	struct uart_port *uport;
>  
> -	if (!port)
> -		return -ENODEV;
> -

With this get_tx_fifo_size() returns always 0, also the only caller
doesn't evaluate the return value. Change to void?

>  	uport = &port->uport;
>  	port->tx_fifo_depth = geni_se_get_tx_fifo_depth(&port->se);
>  	port->tx_fifo_width = geni_se_get_tx_fifo_width(&port->se);
> @@ -706,7 +703,6 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport)
>  	/* Stop the console before stopping the current tx */
>  	console_stop(uport->cons);
>  
> -	disable_irq(uport->irq);
>  	free_irq(uport->irq, uport);
>  	spin_lock_irqsave(&uport->lock, flags);
>  	qcom_geni_serial_stop_tx(uport);
> @@ -914,7 +910,7 @@ static int __init qcom_geni_console_setup(struct console *co, char *options)
>  
>  	port = get_port_from_line(co->index);
>  	if (IS_ERR(port)) {
> -		pr_err("Invalid line %d(%d)\n", co->index, (int)PTR_ERR(port));
> +		pr_err("Invalid line %d\n", co->index);
>  		return PTR_ERR(port);
>  	}
>  
> @@ -1030,16 +1026,13 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
>  
>  	if (pdev->dev.of_node)
>  		line = of_alias_get_id(pdev->dev.of_node, "serial");
> -	else
> -		line = pdev->id;
>  
>  	if (line < 0 || line >= GENI_UART_CONS_PORTS)
>  		return -ENXIO;
>  	port = get_port_from_line(line);
>  	if (IS_ERR(port)) {
> -		ret = PTR_ERR(port);
> -		dev_err(&pdev->dev, "Invalid line %d(%d)\n", line, ret);
> -		return ret;
> +		dev_err(&pdev->dev, "Invalid line %d\n", line);
> +		return PTR_ERR(port);
>  	}
>  
>  	uport = &port->uport;
> @@ -1076,7 +1069,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
>  	uport->private_data = &qcom_geni_console_driver;
>  	platform_set_drvdata(pdev, port);
>  	port->handle_rx = handle_rx_console;
> -	port->setup = false;
>  	return uart_add_one_port(&qcom_geni_console_driver, uport);
>  }
>  
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Karthikeyan Ramasubramanian April 16, 2018, 9:56 p.m. UTC | #2
On 4/12/2018 4:30 PM, Matthias Kaehlcke wrote:
>> @@ -675,9 +675,6 @@ static int get_tx_fifo_size(struct qcom_geni_serial_port *port)
>>  {
>>  	struct uart_port *uport;
>>  
>> -	if (!port)
>> -		return -ENODEV;
>> -
> 
> With this get_tx_fifo_size() returns always 0, also the only caller
> doesn't evaluate the return value. Change to void?
> 
Yes, I will change the return to void.

Regards,
Karthik.
diff mbox

Patch

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 1652b1f..ae959d6 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -309,7 +309,7 @@  static void qcom_geni_serial_wr_char(struct uart_port *uport, int ch)
 		if (!qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS,
 						M_TX_FIFO_WATERMARK_EN, true))
 			break;
-		chars_to_write = min_t(size_t, (size_t)(count - i), avail / 2);
+		chars_to_write = min_t(size_t, count - i, avail / 2);
 		uart_console_write(uport, s + i, chars_to_write,
 						qcom_geni_serial_wr_char);
 		writel_relaxed(M_TX_FIFO_WATERMARK_EN, uport->membase +
@@ -602,7 +602,7 @@  static void qcom_geni_serial_handle_tx(struct uart_port *uport)
 		unsigned int buf = 0;
 		int c;
 
-		tx_bytes = min_t(size_t, remaining, (size_t)port->tx_bytes_pw);
+		tx_bytes = min_t(size_t, remaining, port->tx_bytes_pw);
 		for (c = 0; c < tx_bytes ; c++)
 			buf |= (xmit->buf[tail + c] << (c * BITS_PER_BYTE));
 
@@ -675,9 +675,6 @@  static int get_tx_fifo_size(struct qcom_geni_serial_port *port)
 {
 	struct uart_port *uport;
 
-	if (!port)
-		return -ENODEV;
-
 	uport = &port->uport;
 	port->tx_fifo_depth = geni_se_get_tx_fifo_depth(&port->se);
 	port->tx_fifo_width = geni_se_get_tx_fifo_width(&port->se);
@@ -706,7 +703,6 @@  static void qcom_geni_serial_shutdown(struct uart_port *uport)
 	/* Stop the console before stopping the current tx */
 	console_stop(uport->cons);
 
-	disable_irq(uport->irq);
 	free_irq(uport->irq, uport);
 	spin_lock_irqsave(&uport->lock, flags);
 	qcom_geni_serial_stop_tx(uport);
@@ -914,7 +910,7 @@  static int __init qcom_geni_console_setup(struct console *co, char *options)
 
 	port = get_port_from_line(co->index);
 	if (IS_ERR(port)) {
-		pr_err("Invalid line %d(%d)\n", co->index, (int)PTR_ERR(port));
+		pr_err("Invalid line %d\n", co->index);
 		return PTR_ERR(port);
 	}
 
@@ -1030,16 +1026,13 @@  static int qcom_geni_serial_probe(struct platform_device *pdev)
 
 	if (pdev->dev.of_node)
 		line = of_alias_get_id(pdev->dev.of_node, "serial");
-	else
-		line = pdev->id;
 
 	if (line < 0 || line >= GENI_UART_CONS_PORTS)
 		return -ENXIO;
 	port = get_port_from_line(line);
 	if (IS_ERR(port)) {
-		ret = PTR_ERR(port);
-		dev_err(&pdev->dev, "Invalid line %d(%d)\n", line, ret);
-		return ret;
+		dev_err(&pdev->dev, "Invalid line %d\n", line);
+		return PTR_ERR(port);
 	}
 
 	uport = &port->uport;
@@ -1076,7 +1069,6 @@  static int qcom_geni_serial_probe(struct platform_device *pdev)
 	uport->private_data = &qcom_geni_console_driver;
 	platform_set_drvdata(pdev, port);
 	port->handle_rx = handle_rx_console;
-	port->setup = false;
 	return uart_add_one_port(&qcom_geni_console_driver, uport);
 }