Guards can help to make the code more readable. So use it wherever they
do so.
On many places labels and 'ret' locals are eliminated completely.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
drivers/tty/serial/serial_core.c | 111 +++++++++++++------------------
1 file changed, 46 insertions(+), 65 deletions(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index d63e9b636e02..0e6c1e51da99 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1096,21 +1096,19 @@ static int uart_tiocmget(struct tty_struct *tty)
struct uart_state *state = tty->driver_data;
struct tty_port *port = &state->port;
struct uart_port *uport;
- int result = -EIO;
+ int result;
+
+ guard(mutex)(&port->mutex);
- mutex_lock(&port->mutex);
uport = uart_port_check(state);
- if (!uport)
- goto out;
+ if (!uport || tty_io_error(tty))
+ return -EIO;
+
+ uart_port_lock_irq(uport);
+ result = uport->mctrl;
+ result |= uport->ops->get_mctrl(uport);
+ uart_port_unlock_irq(uport);
- if (!tty_io_error(tty)) {
- uart_port_lock_irq(uport);
- result = uport->mctrl;
- result |= uport->ops->get_mctrl(uport);
- uart_port_unlock_irq(uport);
- }
-out:
- mutex_unlock(&port->mutex);
return result;
}
@@ -1120,20 +1118,16 @@ uart_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear)
struct uart_state *state = tty->driver_data;
struct tty_port *port = &state->port;
struct uart_port *uport;
- int ret = -EIO;
- mutex_lock(&port->mutex);
+ guard(mutex)(&port->mutex);
+
uport = uart_port_check(state);
- if (!uport)
- goto out;
+ if (!uport || tty_io_error(tty))
+ return -EIO;
- if (!tty_io_error(tty)) {
- uart_update_mctrl(uport, set, clear);
- ret = 0;
- }
-out:
- mutex_unlock(&port->mutex);
- return ret;
+ uart_update_mctrl(uport, set, clear);
+
+ return 0;
}
static int uart_break_ctl(struct tty_struct *tty, int break_state)
@@ -1141,19 +1135,17 @@ static int uart_break_ctl(struct tty_struct *tty, int break_state)
struct uart_state *state = tty->driver_data;
struct tty_port *port = &state->port;
struct uart_port *uport;
- int ret = -EIO;
- mutex_lock(&port->mutex);
+ guard(mutex)(&port->mutex);
+
uport = uart_port_check(state);
if (!uport)
- goto out;
+ return -EIO;
if (uport->type != PORT_UNKNOWN && uport->ops->break_ctl)
uport->ops->break_ctl(uport, break_state);
- ret = 0;
-out:
- mutex_unlock(&port->mutex);
- return ret;
+
+ return 0;
}
static int uart_do_autoconfig(struct tty_struct *tty, struct uart_state *state)
@@ -1170,17 +1162,14 @@ static int uart_do_autoconfig(struct tty_struct *tty, struct uart_state *state)
* changing, and hence any extra opens of the port while
* we're auto-configuring.
*/
- if (mutex_lock_interruptible(&port->mutex))
- return -ERESTARTSYS;
+ scoped_cond_guard(mutex_intr, return -ERESTARTSYS, &port->mutex) {
+ uport = uart_port_check(state);
+ if (!uport)
+ return -EIO;
- uport = uart_port_check(state);
- if (!uport) {
- ret = -EIO;
- goto out;
- }
+ if (tty_port_users(port) != 1)
+ return -EBUSY;
- ret = -EBUSY;
- if (tty_port_users(port) == 1) {
uart_shutdown(tty, state);
/*
@@ -1201,14 +1190,15 @@ static int uart_do_autoconfig(struct tty_struct *tty, struct uart_state *state)
uport->ops->config_port(uport, flags);
ret = uart_startup(tty, state, true);
- if (ret == 0)
- tty_port_set_initialized(port, true);
+ if (ret < 0)
+ return ret;
if (ret > 0)
- ret = 0;
+ return 0;
+
+ tty_port_set_initialized(port, true);
}
-out:
- mutex_unlock(&port->mutex);
- return ret;
+
+ return 0;
}
static void uart_enable_ms(struct uart_port *uport)
@@ -1703,10 +1693,11 @@ static void uart_set_termios(struct tty_struct *tty,
unsigned int iflag_mask = IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK;
bool sw_changed = false;
- mutex_lock(&state->port.mutex);
+ guard(mutex)(&state->port.mutex);
+
uport = uart_port_check(state);
if (!uport)
- goto out;
+ return;
/*
* Drivers doing software flow control also need to know
@@ -1729,9 +1720,8 @@ static void uart_set_termios(struct tty_struct *tty,
tty->termios.c_ospeed == old_termios->c_ospeed &&
tty->termios.c_ispeed == old_termios->c_ispeed &&
((tty->termios.c_iflag ^ old_termios->c_iflag) & iflag_mask) == 0 &&
- !sw_changed) {
- goto out;
- }
+ !sw_changed)
+ return;
uart_change_line_settings(tty, state, old_termios);
/* reload cflag from termios; port driver may have overridden flags */
@@ -1748,8 +1738,6 @@ static void uart_set_termios(struct tty_struct *tty,
mask |= TIOCM_RTS;
uart_set_mctrl(uport, mask);
}
-out:
- mutex_unlock(&state->port.mutex);
}
/*
@@ -2043,10 +2031,11 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i)
unsigned int status;
int mmio;
- mutex_lock(&port->mutex);
+ guard(mutex)(&port->mutex);
+
uport = uart_port_check(state);
if (!uport)
- goto out;
+ return;
mmio = uport->iotype >= UPIO_MEM;
seq_printf(m, "%d: uart:%s %s%08llX irq:%d",
@@ -2058,7 +2047,7 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i)
if (uport->type == PORT_UNKNOWN) {
seq_putc(m, '\n');
- goto out;
+ return;
}
if (capable(CAP_SYS_ADMIN)) {
@@ -2109,8 +2098,6 @@ static void uart_line_info(struct seq_file *m, struct uart_driver *drv, int i)
seq_putc(m, '\n');
#undef STATBIT
#undef INFOBIT
-out:
- mutex_unlock(&port->mutex);
}
static int uart_proc_show(struct seq_file *m, void *v)
@@ -2387,13 +2374,12 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
struct device *tty_dev;
struct uart_match match = {uport, drv};
- mutex_lock(&port->mutex);
+ guard(mutex)(&port->mutex);
tty_dev = device_find_child(&uport->port_dev->dev, &match, serial_match_port);
if (tty_dev && device_may_wakeup(tty_dev)) {
enable_irq_wake(uport->irq);
put_device(tty_dev);
- mutex_unlock(&port->mutex);
return 0;
}
put_device(tty_dev);
@@ -2454,8 +2440,6 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
console_stop(uport->cons);
uart_change_pm(state, UART_PM_STATE_OFF);
-unlock:
- mutex_unlock(&port->mutex);
return 0;
}
@@ -2469,14 +2453,13 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
struct uart_match match = {uport, drv};
struct ktermios termios;
- mutex_lock(&port->mutex);
+ guard(mutex)(&port->mutex);
tty_dev = device_find_child(&uport->port_dev->dev, &match, serial_match_port);
if (!uport->suspended && device_may_wakeup(tty_dev)) {
if (irqd_is_wakeup_set(irq_get_irq_data((uport->irq))))
disable_irq_wake(uport->irq);
put_device(tty_dev);
- mutex_unlock(&port->mutex);
return 0;
}
put_device(tty_dev);
@@ -2549,8 +2532,6 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport)
tty_port_set_suspended(port, false);
}
- mutex_unlock(&port->mutex);
-
return 0;
}
EXPORT_SYMBOL(uart_resume_port);
--
2.46.0
On Mon, Aug 05, 2024 at 12:20:38PM +0200, Jiri Slaby (SUSE) wrote: > Guards can help to make the code more readable. So use it wherever they > do so. > > On many places labels and 'ret' locals are eliminated completely. > > Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> > --- > drivers/tty/serial/serial_core.c | 111 +++++++++++++------------------ > 1 file changed, 46 insertions(+), 65 deletions(-) Ah, this was the breaking patch. I applied the first 4 now, will let you respin this one and resend the remaining. thanks, greg k-h
Hi Jiri,
kernel test robot noticed the following build errors:
[auto build test ERROR on tty/tty-testing]
[also build test ERROR on tty/tty-next tty/tty-linus usb/usb-testing usb/usb-next usb/usb-linus linus/master v6.11-rc2 next-20240805]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jiri-Slaby-SUSE/tty-simplify-tty_dev_name_to_number-using-guard-mutex/20240805-184227
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
patch link: https://lore.kernel.org/r/20240805102046.307511-6-jirislaby%40kernel.org
patch subject: [PATCH 05/13] serial: use guards for simple mutex locks
config: openrisc-defconfig (https://download.01.org/0day-ci/archive/20240806/202408060140.glPvoH1S-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240806/202408060140.glPvoH1S-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408060140.glPvoH1S-lkp@intel.com/
All errors (new ones prefixed by >>):
drivers/tty/serial/serial_core.c: In function 'uart_suspend_port':
>> drivers/tty/serial/serial_core.c:2400:17: error: label 'unlock' used but not defined
2400 | goto unlock;
| ^~~~
vim +/unlock +2400 drivers/tty/serial/serial_core.c
b3b708fa2780cd drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2369
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2370 int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2371 {
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2372 struct uart_state *state = drv->state + uport->line;
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2373 struct tty_port *port = &state->port;
b3b708fa2780cd drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2374 struct device *tty_dev;
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2375 struct uart_match match = {uport, drv};
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2376
d2d8bbc5cc74b7 drivers/tty/serial/serial_core.c Jiri Slaby (SUSE 2024-08-05 2377) guard(mutex)(&port->mutex);
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2378
b286f4e87e325b drivers/tty/serial/serial_core.c Tony Lindgren 2023-11-13 2379 tty_dev = device_find_child(&uport->port_dev->dev, &match, serial_match_port);
88e2582e90bb89 drivers/tty/serial/serial_core.c Lucas Stach 2017-05-11 2380 if (tty_dev && device_may_wakeup(tty_dev)) {
aef3ad103a686f drivers/tty/serial/serial_core.c Andy Shevchenko 2017-08-13 2381 enable_irq_wake(uport->irq);
b3b708fa2780cd drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2382 put_device(tty_dev);
b3b708fa2780cd drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2383 return 0;
b3b708fa2780cd drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2384 }
5a65dcc04cda41 drivers/tty/serial/serial_core.c Federico Vaga 2013-04-15 2385 put_device(tty_dev);
5a65dcc04cda41 drivers/tty/serial/serial_core.c Federico Vaga 2013-04-15 2386
c9d2325cdb92fd drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2387 /*
c9d2325cdb92fd drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2388 * Nothing to do if the console is not suspending
c9d2325cdb92fd drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2389 * except stop_rx to prevent any asynchronous data
cfab87c2c27157 drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-06-08 2390 * over RX line. However ensure that we will be
cfab87c2c27157 drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-06-08 2391 * able to Re-start_rx later.
c9d2325cdb92fd drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2392 */
c9d2325cdb92fd drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2393 if (!console_suspend_enabled && uart_console(uport)) {
abcb0cf1f5b2d9 drivers/tty/serial/serial_core.c John Ogness 2023-05-25 2394 if (uport->ops->start_rx) {
559c7ff4e32455 drivers/tty/serial/serial_core.c Thomas Gleixner 2023-09-14 2395 uart_port_lock_irq(uport);
c9d2325cdb92fd drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2396 uport->ops->stop_rx(uport);
559c7ff4e32455 drivers/tty/serial/serial_core.c Thomas Gleixner 2023-09-14 2397 uart_port_unlock_irq(uport);
abcb0cf1f5b2d9 drivers/tty/serial/serial_core.c John Ogness 2023-05-25 2398 }
a47cf07f60dcb0 drivers/tty/serial/serial_core.c Claudiu Beznea 2024-04-30 2399 device_set_awake_path(uport->dev);
b164c9721e3ea4 drivers/tty/serial/serial_core.c Peter Hurley 2015-01-22 @2400 goto unlock;
c9d2325cdb92fd drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2401 }
b164c9721e3ea4 drivers/tty/serial/serial_core.c Peter Hurley 2015-01-22 2402
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2403 uport->suspended = 1;
b3b708fa2780cd drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2404
d41861ca19c9e9 drivers/tty/serial/serial_core.c Peter Hurley 2016-04-09 2405 if (tty_port_initialized(port)) {
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2406 const struct uart_ops *ops = uport->ops;
c8c6bfa39d6bd7 drivers/serial/serial_core.c Russell King 2008-02-04 2407 int tries;
18c9d4a3c249e9 drivers/tty/serial/serial_core.c Al Cooper 2022-03-24 2408 unsigned int mctrl;
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2409
75b20a2ac425b9 drivers/tty/serial/serial_core.c Ilpo Järvinen 2023-01-17 2410 tty_port_set_suspended(port, true);
515be7baeddb04 drivers/tty/serial/serial_core.c Ilpo Järvinen 2023-01-17 2411 tty_port_set_initialized(port, false);
a6b93a90850881 drivers/serial/serial_core.c Russell King 2006-10-01 2412
559c7ff4e32455 drivers/tty/serial/serial_core.c Thomas Gleixner 2023-09-14 2413 uart_port_lock_irq(uport);
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2414 ops->stop_tx(uport);
7c7f9bc986e698 drivers/tty/serial/serial_core.c Lukas Wunner 2022-09-22 2415 if (!(uport->rs485.flags & SER_RS485_ENABLED))
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2416 ops->set_mctrl(uport, 0);
18c9d4a3c249e9 drivers/tty/serial/serial_core.c Al Cooper 2022-03-24 2417 /* save mctrl so it can be restored on resume */
18c9d4a3c249e9 drivers/tty/serial/serial_core.c Al Cooper 2022-03-24 2418 mctrl = uport->mctrl;
18c9d4a3c249e9 drivers/tty/serial/serial_core.c Al Cooper 2022-03-24 2419 uport->mctrl = 0;
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2420 ops->stop_rx(uport);
559c7ff4e32455 drivers/tty/serial/serial_core.c Thomas Gleixner 2023-09-14 2421 uart_port_unlock_irq(uport);
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2422
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2423 /*
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2424 * Wait for the transmitter to empty.
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2425 */
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2426 for (tries = 3; !ops->tx_empty(uport) && tries; tries--)
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2427 msleep(10);
c8c6bfa39d6bd7 drivers/serial/serial_core.c Russell King 2008-02-04 2428 if (!tries)
cade3580f79aeb drivers/tty/serial/serial_core.c Andy Shevchenko 2017-03-31 2429 dev_err(uport->dev, "%s: Unable to drain transmitter\n",
cade3580f79aeb drivers/tty/serial/serial_core.c Andy Shevchenko 2017-03-31 2430 uport->name);
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2431
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2432 ops->shutdown(uport);
18c9d4a3c249e9 drivers/tty/serial/serial_core.c Al Cooper 2022-03-24 2433 uport->mctrl = mctrl;
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2434 }
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2435
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2436 /*
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2437 * Disable the console device before suspending.
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2438 */
b164c9721e3ea4 drivers/tty/serial/serial_core.c Peter Hurley 2015-01-22 2439 if (uart_console(uport))
ccce6debb62d94 drivers/serial/serial_core.c Alan Cox 2009-09-19 2440 console_stop(uport->cons);
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2441
6f538fe31c1d45 drivers/tty/serial/serial_core.c Linus Walleij 2012-12-07 2442 uart_change_pm(state, UART_PM_STATE_OFF);
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2443
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2444 return 0;
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2445 }
15dc475bcc1739 drivers/tty/serial/serial_core.c Jiri Slaby 2022-01-24 2446 EXPORT_SYMBOL(uart_suspend_port);
^1da177e4c3f41 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2447
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Hi Jiri,
kernel test robot noticed the following build errors:
[auto build test ERROR on tty/tty-testing]
[also build test ERROR on tty/tty-next tty/tty-linus usb/usb-testing usb/usb-next usb/usb-linus linus/master v6.11-rc2 next-20240805]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jiri-Slaby-SUSE/tty-simplify-tty_dev_name_to_number-using-guard-mutex/20240805-184227
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
patch link: https://lore.kernel.org/r/20240805102046.307511-6-jirislaby%40kernel.org
patch subject: [PATCH 05/13] serial: use guards for simple mutex locks
config: i386-buildonly-randconfig-002-20240805 (https://download.01.org/0day-ci/archive/20240806/202408060106.20nUZZ2i-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240806/202408060106.20nUZZ2i-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408060106.20nUZZ2i-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/tty/serial/serial_core.c:2400:8: error: use of undeclared label 'unlock'
2400 | goto unlock;
| ^
1 error generated.
vim +/unlock +2400 drivers/tty/serial/serial_core.c
b3b708fa2780cd2 drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2369
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2370 int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2371 {
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2372 struct uart_state *state = drv->state + uport->line;
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2373 struct tty_port *port = &state->port;
b3b708fa2780cd2 drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2374 struct device *tty_dev;
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2375 struct uart_match match = {uport, drv};
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2376
d2d8bbc5cc74b7e drivers/tty/serial/serial_core.c Jiri Slaby (SUSE 2024-08-05 2377) guard(mutex)(&port->mutex);
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2378
b286f4e87e325b7 drivers/tty/serial/serial_core.c Tony Lindgren 2023-11-13 2379 tty_dev = device_find_child(&uport->port_dev->dev, &match, serial_match_port);
88e2582e90bb89f drivers/tty/serial/serial_core.c Lucas Stach 2017-05-11 2380 if (tty_dev && device_may_wakeup(tty_dev)) {
aef3ad103a686f2 drivers/tty/serial/serial_core.c Andy Shevchenko 2017-08-13 2381 enable_irq_wake(uport->irq);
b3b708fa2780cd2 drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2382 put_device(tty_dev);
b3b708fa2780cd2 drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2383 return 0;
b3b708fa2780cd2 drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2384 }
5a65dcc04cda41f drivers/tty/serial/serial_core.c Federico Vaga 2013-04-15 2385 put_device(tty_dev);
5a65dcc04cda41f drivers/tty/serial/serial_core.c Federico Vaga 2013-04-15 2386
c9d2325cdb92fd4 drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2387 /*
c9d2325cdb92fd4 drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2388 * Nothing to do if the console is not suspending
c9d2325cdb92fd4 drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2389 * except stop_rx to prevent any asynchronous data
cfab87c2c271576 drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-06-08 2390 * over RX line. However ensure that we will be
cfab87c2c271576 drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-06-08 2391 * able to Re-start_rx later.
c9d2325cdb92fd4 drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2392 */
c9d2325cdb92fd4 drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2393 if (!console_suspend_enabled && uart_console(uport)) {
abcb0cf1f5b2d99 drivers/tty/serial/serial_core.c John Ogness 2023-05-25 2394 if (uport->ops->start_rx) {
559c7ff4e324558 drivers/tty/serial/serial_core.c Thomas Gleixner 2023-09-14 2395 uart_port_lock_irq(uport);
c9d2325cdb92fd4 drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2396 uport->ops->stop_rx(uport);
559c7ff4e324558 drivers/tty/serial/serial_core.c Thomas Gleixner 2023-09-14 2397 uart_port_unlock_irq(uport);
abcb0cf1f5b2d99 drivers/tty/serial/serial_core.c John Ogness 2023-05-25 2398 }
a47cf07f60dcb02 drivers/tty/serial/serial_core.c Claudiu Beznea 2024-04-30 2399 device_set_awake_path(uport->dev);
b164c9721e3ea4c drivers/tty/serial/serial_core.c Peter Hurley 2015-01-22 @2400 goto unlock;
c9d2325cdb92fd4 drivers/tty/serial/serial_core.c Vijaya Krishna Nivarthi 2022-05-16 2401 }
b164c9721e3ea4c drivers/tty/serial/serial_core.c Peter Hurley 2015-01-22 2402
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2403 uport->suspended = 1;
b3b708fa2780cd2 drivers/serial/serial_core.c Guennadi Liakhovetski 2007-10-16 2404
d41861ca19c9e96 drivers/tty/serial/serial_core.c Peter Hurley 2016-04-09 2405 if (tty_port_initialized(port)) {
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2406 const struct uart_ops *ops = uport->ops;
c8c6bfa39d6bd73 drivers/serial/serial_core.c Russell King 2008-02-04 2407 int tries;
18c9d4a3c249e9d drivers/tty/serial/serial_core.c Al Cooper 2022-03-24 2408 unsigned int mctrl;
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2409
75b20a2ac425b94 drivers/tty/serial/serial_core.c Ilpo Järvinen 2023-01-17 2410 tty_port_set_suspended(port, true);
515be7baeddb04d drivers/tty/serial/serial_core.c Ilpo Järvinen 2023-01-17 2411 tty_port_set_initialized(port, false);
a6b93a908508810 drivers/serial/serial_core.c Russell King 2006-10-01 2412
559c7ff4e324558 drivers/tty/serial/serial_core.c Thomas Gleixner 2023-09-14 2413 uart_port_lock_irq(uport);
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2414 ops->stop_tx(uport);
7c7f9bc986e6988 drivers/tty/serial/serial_core.c Lukas Wunner 2022-09-22 2415 if (!(uport->rs485.flags & SER_RS485_ENABLED))
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2416 ops->set_mctrl(uport, 0);
18c9d4a3c249e9d drivers/tty/serial/serial_core.c Al Cooper 2022-03-24 2417 /* save mctrl so it can be restored on resume */
18c9d4a3c249e9d drivers/tty/serial/serial_core.c Al Cooper 2022-03-24 2418 mctrl = uport->mctrl;
18c9d4a3c249e9d drivers/tty/serial/serial_core.c Al Cooper 2022-03-24 2419 uport->mctrl = 0;
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2420 ops->stop_rx(uport);
559c7ff4e324558 drivers/tty/serial/serial_core.c Thomas Gleixner 2023-09-14 2421 uart_port_unlock_irq(uport);
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2422
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2423 /*
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2424 * Wait for the transmitter to empty.
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2425 */
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2426 for (tries = 3; !ops->tx_empty(uport) && tries; tries--)
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2427 msleep(10);
c8c6bfa39d6bd73 drivers/serial/serial_core.c Russell King 2008-02-04 2428 if (!tries)
cade3580f79aeba drivers/tty/serial/serial_core.c Andy Shevchenko 2017-03-31 2429 dev_err(uport->dev, "%s: Unable to drain transmitter\n",
cade3580f79aeba drivers/tty/serial/serial_core.c Andy Shevchenko 2017-03-31 2430 uport->name);
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2431
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2432 ops->shutdown(uport);
18c9d4a3c249e9d drivers/tty/serial/serial_core.c Al Cooper 2022-03-24 2433 uport->mctrl = mctrl;
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2434 }
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2435
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2436 /*
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2437 * Disable the console device before suspending.
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2438 */
b164c9721e3ea4c drivers/tty/serial/serial_core.c Peter Hurley 2015-01-22 2439 if (uart_console(uport))
ccce6debb62d949 drivers/serial/serial_core.c Alan Cox 2009-09-19 2440 console_stop(uport->cons);
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2441
6f538fe31c1d453 drivers/tty/serial/serial_core.c Linus Walleij 2012-12-07 2442 uart_change_pm(state, UART_PM_STATE_OFF);
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2443
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2444 return 0;
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2445 }
15dc475bcc1739c drivers/tty/serial/serial_core.c Jiri Slaby 2022-01-24 2446 EXPORT_SYMBOL(uart_suspend_port);
^1da177e4c3f415 drivers/serial/serial_core.c Linus Torvalds 2005-04-16 2447
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2025 Red Hat, Inc.