Skip to content

Commit abe7015

Browse files
ij-intelgregkh
authored andcommitted
serial: 8250_pnp: Simplify "line" related code
8250_pnp sets drvdata to line + 1 if the probe is successful. The users of drvdata are in remove, suspend and resume callbacks, none of which will be called if probe failed. The line acquired from drvdata can never be zero in those functions and the checks for that can be removed. Eliminate also +/-1 step because all users of line subtract 1 from the value. These might have been leftover from legacy PM callbacks that could be called without probe being successful. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20240506121202.11253-1-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ae1b6b4 commit abe7015

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

drivers/tty/serial/8250/8250_pnp.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,9 @@ static int
435435
serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
436436
{
437437
struct uart_8250_port uart, *port;
438-
int ret, line, flags = dev_id->driver_data;
438+
int ret, flags = dev_id->driver_data;
439439
unsigned char iotype;
440+
long line;
440441

441442
if (flags & UNKNOWN_DEV) {
442443
ret = serial_pnp_guess_board(dev);
@@ -494,7 +495,7 @@ serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
494495
if (uart_console(&port->port))
495496
dev->capabilities |= PNP_CONSOLE;
496497

497-
pnp_set_drvdata(dev, (void *)((long)line + 1));
498+
pnp_set_drvdata(dev, (void *)line);
498499
return 0;
499500
}
500501

@@ -503,27 +504,22 @@ static void serial_pnp_remove(struct pnp_dev *dev)
503504
long line = (long)pnp_get_drvdata(dev);
504505

505506
dev->capabilities &= ~PNP_CONSOLE;
506-
if (line)
507-
serial8250_unregister_port(line - 1);
507+
serial8250_unregister_port(line);
508508
}
509509

510510
static int serial_pnp_suspend(struct device *dev)
511511
{
512512
long line = (long)dev_get_drvdata(dev);
513513

514-
if (!line)
515-
return -ENODEV;
516-
serial8250_suspend_port(line - 1);
514+
serial8250_suspend_port(line);
517515
return 0;
518516
}
519517

520518
static int serial_pnp_resume(struct device *dev)
521519
{
522520
long line = (long)dev_get_drvdata(dev);
523521

524-
if (!line)
525-
return -ENODEV;
526-
serial8250_resume_port(line - 1);
522+
serial8250_resume_port(line);
527523
return 0;
528524
}
529525

0 commit comments

Comments
 (0)