Commit 54178fe6 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Greg Kroah-Hartman

tty: serial: 8250: omap: line is unsigned, don't check < 0

Dan Carpenter reported:
|drivers/tty/serial/8250/8250_omap.c:1025 omap8250_probe()
|warn: unsigned 'up.port.line' is never less than zero.
|1025          if (up.port.line < 0) {

I (wrongly) assumed that line is an int and compiler didn't complain nor
did sparse. Since of_alias_get_id() and pdev->id can get negative I
check for the error via ret variable.
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6b1f40cf
...@@ -1014,19 +1014,20 @@ static int omap8250_probe(struct platform_device *pdev) ...@@ -1014,19 +1014,20 @@ static int omap8250_probe(struct platform_device *pdev)
up.port.unthrottle = omap_8250_unthrottle; up.port.unthrottle = omap_8250_unthrottle;
if (pdev->dev.of_node) { if (pdev->dev.of_node) {
up.port.line = of_alias_get_id(pdev->dev.of_node, "serial"); ret = of_alias_get_id(pdev->dev.of_node, "serial");
of_property_read_u32(pdev->dev.of_node, "clock-frequency", of_property_read_u32(pdev->dev.of_node, "clock-frequency",
&up.port.uartclk); &up.port.uartclk);
priv->wakeirq = irq_of_parse_and_map(pdev->dev.of_node, 1); priv->wakeirq = irq_of_parse_and_map(pdev->dev.of_node, 1);
} else { } else {
up.port.line = pdev->id; ret = pdev->id;
} }
if (ret < 0) {
if (up.port.line < 0) { dev_err(&pdev->dev, "failed to get alias/pdev id\n");
dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n", return ret;
up.port.line);
return -ENODEV;
} }
up.port.line = ret;
if (!up.port.uartclk) { if (!up.port.uartclk) {
up.port.uartclk = DEFAULT_CLK_SPEED; up.port.uartclk = DEFAULT_CLK_SPEED;
dev_warn(&pdev->dev, dev_warn(&pdev->dev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment