* [PATCH 1/1] serial: 8250_pnp: Simplify "line" related code
@ 2024-04-23 13:49 Ilpo Järvinen
2024-04-23 14:01 ` Andy Shevchenko
2024-05-04 16:10 ` Greg Kroah-Hartman
0 siblings, 2 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2024-04-23 13:49 UTC (permalink / raw)
To: Andy Shevchenko, Greg Kroah-Hartman, Jiri Slaby, linux-kernel,
linux-serial
Cc: Ilpo Järvinen
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.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
---
drivers/tty/serial/8250/8250_pnp.c | 16 ++++++----------
1 file changed, 6 insertions(+), 10 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_pnp.c b/drivers/tty/serial/8250/8250_pnp.c
index 8f72a7de1d1d..fc206afaf671 100644
--- a/drivers/tty/serial/8250/8250_pnp.c
+++ b/drivers/tty/serial/8250/8250_pnp.c
@@ -434,8 +434,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);
@@ -493,7 +494,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;
}
@@ -502,17 +503,14 @@ 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 __maybe_unused 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;
}
@@ -520,9 +518,7 @@ static int __maybe_unused 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;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] serial: 8250_pnp: Simplify "line" related code
2024-04-23 13:49 [PATCH 1/1] serial: 8250_pnp: Simplify "line" related code Ilpo Järvinen
@ 2024-04-23 14:01 ` Andy Shevchenko
2024-05-04 16:10 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2024-04-23 14:01 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Greg Kroah-Hartman, Jiri Slaby, linux-kernel, linux-serial
On Tue, Apr 23, 2024 at 04:49:30PM +0300, Ilpo Järvinen wrote:
> 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.
Also noticed that, looks like a leftover from the legacy PM callbacks that
might be called without probe being succeeded.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] serial: 8250_pnp: Simplify "line" related code
2024-04-23 13:49 [PATCH 1/1] serial: 8250_pnp: Simplify "line" related code Ilpo Järvinen
2024-04-23 14:01 ` Andy Shevchenko
@ 2024-05-04 16:10 ` Greg Kroah-Hartman
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2024-05-04 16:10 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: Andy Shevchenko, Jiri Slaby, linux-kernel, linux-serial
On Tue, Apr 23, 2024 at 04:49:30PM +0300, Ilpo Järvinen wrote:
> 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.
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> ---
> drivers/tty/serial/8250/8250_pnp.c | 16 ++++++----------
> 1 file changed, 6 insertions(+), 10 deletions(-)
Doesn't apply to my tty-next branch, can you rebase and resend?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-04 16:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-23 13:49 [PATCH 1/1] serial: 8250_pnp: Simplify "line" related code Ilpo Järvinen
2024-04-23 14:01 ` Andy Shevchenko
2024-05-04 16:10 ` Greg Kroah-Hartman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).