Skip to content

Commit

Permalink
serial: 8250_pnp: Simplify "line" related code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Ilpo Järvinen authored and Greg Kroah-Hartman committed May 10, 2024
1 parent ae1b6b4 commit abe7015
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions drivers/tty/serial/8250/8250_pnp.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,9 @@ static int
serial_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id *dev_id)
{
struct uart_8250_port uart, *port;
int ret, line, flags = dev_id->driver_data;
int ret, flags = dev_id->driver_data;
unsigned char iotype;
long line;

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

pnp_set_drvdata(dev, (void *)((long)line + 1));
pnp_set_drvdata(dev, (void *)line);
return 0;
}

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

dev->capabilities &= ~PNP_CONSOLE;
if (line)
serial8250_unregister_port(line - 1);
serial8250_unregister_port(line);
}

static int serial_pnp_suspend(struct device *dev)
{
long line = (long)dev_get_drvdata(dev);

if (!line)
return -ENODEV;
serial8250_suspend_port(line - 1);
serial8250_suspend_port(line);
return 0;
}

static int serial_pnp_resume(struct device *dev)
{
long line = (long)dev_get_drvdata(dev);

if (!line)
return -ENODEV;
serial8250_resume_port(line - 1);
serial8250_resume_port(line);
return 0;
}

Expand Down

0 comments on commit abe7015

Please sign in to comment.