提交 e688355b 编写于 作者: J Johan Hovold 提交者: Greg Kroah-Hartman

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: NJohan Hovold <jhovold@gmail.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 d35e70d5
......@@ -389,5 +389,20 @@ do { \
printk(KERN_DEBUG "%s: " format "\n", __FILE__, ##arg); \
} while (0)
/*
* Macro for reporting errors in write path to avoid inifinite loop
* when port is used as a console.
*/
#define dev_err_console(usport, fmt, ...) \
do { \
static bool __print_once; \
struct usb_serial_port *__port = (usport); \
\
if (!__port->port.console || !__print_once) { \
__print_once = true; \
dev_err(&__port->dev, fmt, ##__VA_ARGS__); \
} \
} while (0)
#endif /* __LINUX_USB_SERIAL_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册