From: Johan Hovold Date: Mon, 6 Feb 2012 18:22:19 +0000 (+0100) Subject: USB: serial: add macro for console error reporting X-Git-Tag: MMI-PSA29.97-13-9~17266^2~22^2~121^2~9 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e688355bfeadf17ef522b1e62cc12f8e88e69667;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git 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 Signed-off-by: Greg Kroah-Hartman --- 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 { \ 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 */