aboutsummaryrefslogtreecommitdiff
path: root/drivers/tty/serial
diff options
context:
space:
mode:
authorGravatar Hugo Villeneuve <hvilleneuve@dimonoff.com> 2024-01-18 10:22:05 -0500
committerGravatar Greg Kroah-Hartman <gregkh@linuxfoundation.org> 2024-01-27 19:05:04 -0800
commit5d888f1c32e2281843d58eef963e3ebd625b77a9 (patch)
tree594df7640ab7a633a2eb6ffa94d82098f82140b7 /drivers/tty/serial
parentserial: max310x: use separate regmap name for each port (diff)
downloadlinux-5d888f1c32e2281843d58eef963e3ebd625b77a9.tar.gz
linux-5d888f1c32e2281843d58eef963e3ebd625b77a9.tar.bz2
linux-5d888f1c32e2281843d58eef963e3ebd625b77a9.zip
serial: max310x: simplify probe() and remove() error handling
Simplify error handling and only call uart_remove_one_port() if line bit is set, instead of having to manually set s->p[i].port.dev to NULL. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Link: https://lore.kernel.org/r/20240118152213.2644269-10-hugo@hugovil.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r--drivers/tty/serial/max310x.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c
index d6219077d23c..9ef146f09d5b 100644
--- a/drivers/tty/serial/max310x.c
+++ b/drivers/tty/serial/max310x.c
@@ -1395,10 +1395,9 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
/* Register port */
ret = uart_add_one_port(&max310x_uart, &s->p[i].port);
- if (ret) {
- s->p[i].port.dev = NULL;
+ if (ret)
goto out_uart;
- }
+
set_bit(line, max310x_lines);
/* Go to suspend mode */
@@ -1433,10 +1432,8 @@ static int max310x_probe(struct device *dev, const struct max310x_devtype *devty
out_uart:
for (i = 0; i < devtype->nr; i++) {
- if (s->p[i].port.dev) {
+ if (test_and_clear_bit(s->p[i].port.line, max310x_lines))
uart_remove_one_port(&max310x_uart, &s->p[i].port);
- clear_bit(s->p[i].port.line, max310x_lines);
- }
}
out_clk:
@@ -1454,8 +1451,10 @@ static void max310x_remove(struct device *dev)
cancel_work_sync(&s->p[i].tx_work);
cancel_work_sync(&s->p[i].md_work);
cancel_work_sync(&s->p[i].rs_work);
- uart_remove_one_port(&max310x_uart, &s->p[i].port);
- clear_bit(s->p[i].port.line, max310x_lines);
+
+ if (test_and_clear_bit(s->p[i].port.line, max310x_lines))
+ uart_remove_one_port(&max310x_uart, &s->p[i].port);
+
s->devtype->power(&s->p[i].port, 0);
}