diff options
author | Johan Hovold <jhovold@gmail.com> | 2012-02-06 13:22:19 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-02-09 11:43:02 -0500 |
commit | e688355bfeadf17ef522b1e62cc12f8e88e69667 (patch) | |
tree | 468e72a4b8a7694163f257abcf2e892d2bc1042c /include/linux/usb/serial.h | |
parent | d35e70d50a0641ebc1502fd343bef9b4011ada27 (diff) |
USB: serial: add macro for console error reporting
Add macro which prints an error message only once if port is used a
console.
Reporting errors in a write path when port is used as a console could
otherwise result in an infinite loop.
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/usb/serial.h')
-rw-r--r-- | include/linux/usb/serial.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h index 4267a9c717ba..10cb74d2ad1d 100644 --- a/include/linux/usb/serial.h +++ b/include/linux/usb/serial.h | |||
@@ -389,5 +389,20 @@ do { \ | |||
389 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ | 389 | printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \ |
390 | } while (0) | 390 | } while (0) |
391 | 391 | ||
392 | /* | ||
393 | * Macro for reporting errors in write path to avoid inifinite loop | ||
394 | * when port is used as a console. | ||
395 | */ | ||
396 | #define dev_err_console(usport, fmt, ...) \ | ||
397 | do { \ | ||
398 | static bool __print_once; \ | ||
399 | struct usb_serial_port *__port = (usport); \ | ||
400 | \ | ||
401 | if (!__port->port.console || !__print_once) { \ | ||
402 | __print_once = true; \ | ||
403 | dev_err(&__port->dev, fmt, ##__VA_ARGS__); \ | ||
404 | } \ | ||
405 | } while (0) | ||
406 | |||
392 | #endif /* __LINUX_USB_SERIAL_H */ | 407 | #endif /* __LINUX_USB_SERIAL_H */ |
393 | 408 | ||