diff mbox

tty: serial: qcom_geni_serial: Use signed variable to get IRQ

Message ID 1523047859-9543-1-git-send-email-kramasub@codeaurora.org (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Karthikeyan Ramasubramanian April 6, 2018, 8:50 p.m. UTC
The platform_get_irq can return error. Assigning the return value to an
unsigned variable and checking it for negative value will always return
false.

Use an intermediate signed variable to get IRQ information, check for any
error and then assign it to 'irq' variable inside uart_port structure.

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

Comments

Stephen Boyd April 6, 2018, 9:43 p.m. UTC | #1
Quoting Karthikeyan Ramasubramanian (2018-04-06 13:50:59)
> The platform_get_irq can return error. Assigning the return value to an
> unsigned variable and checking it for negative value will always return
> false.
> 
> Use an intermediate signed variable to get IRQ information, check for any
> error and then assign it to 'irq' variable inside uart_port structure.
> 
> Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
> ---

Was this reported by Dan? Add a reported-by tag if so.

Reviewed-by: Stephen Boyd <swboyd@chromium.org>

--
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 7, 2018, 12:48 a.m. UTC | #2
On 4/6/2018 3:43 PM, Stephen Boyd wrote:
> Quoting Karthikeyan Ramasubramanian (2018-04-06 13:50:59)
>> The platform_get_irq can return error. Assigning the return value to an
>> unsigned variable and checking it for negative value will always return
>> false.
>>
>> Use an intermediate signed variable to get IRQ information, check for any
>> error and then assign it to 'irq' variable inside uart_port structure.
>>
>> Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
>> ---
> 
> Was this reported by Dan? Add a reported-by tag if so.
> 
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
> 
Yes it was reported by Dan. I will add the reported-by tag.

Regards,
Karthik.
diff mbox

Patch

diff --git a/drivers/tty/serial/qcom_geni_serial.c b/drivers/tty/serial/qcom_geni_serial.c
index 65ff669..a1b3eb0 100644
--- a/drivers/tty/serial/qcom_geni_serial.c
+++ b/drivers/tty/serial/qcom_geni_serial.c
@@ -1022,6 +1022,7 @@  static int qcom_geni_serial_probe(struct platform_device *pdev)
 	struct qcom_geni_serial_port *port;
 	struct uart_port *uport;
 	struct resource *res;
+	int irq;
 
 	if (pdev->dev.of_node)
 		line = of_alias_get_id(pdev->dev.of_node, "serial");
@@ -1061,11 +1062,12 @@  static int qcom_geni_serial_probe(struct platform_device *pdev)
 	port->rx_fifo_depth = DEF_FIFO_DEPTH_WORDS;
 	port->tx_fifo_width = DEF_FIFO_WIDTH_BITS;
 
-	uport->irq = platform_get_irq(pdev, 0);
-	if (uport->irq < 0) {
-		dev_err(&pdev->dev, "Failed to get IRQ %d\n", uport->irq);
-		return uport->irq;
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		dev_err(&pdev->dev, "Failed to get IRQ %d\n", irq);
+		return irq;
 	}
+	uport->irq = irq;
 
 	uport->private_data = &qcom_geni_console_driver;
 	platform_set_drvdata(pdev, port);