From 6b517ed017c763853efe4a04b69cf7fbe5e5e4a3 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 16 Jun 2016 06:28:04 -0600 Subject: [PATCH] Centralize definitions associated with CONFIG_DEBUG_WATCHDOG --- Kconfig | 37 ++++- arch/arm/src/sam34/sam_wdt.c | 14 -- arch/arm/src/sama5/sam_wdt.c | 14 -- arch/arm/src/samv7/sam_rswdt.c | 14 -- arch/arm/src/samv7/sam_wdt.c | 14 -- arch/arm/src/stm32/stm32_iwdg.c | 14 -- arch/arm/src/stm32/stm32_wwdg.c | 14 -- configs/sam4s-xplained-pro/src/sam_wdt.c | 54 ++------ drivers/timers/watchdog.c | 18 --- include/debug.h | 168 +++++++++++++++-------- 10 files changed, 156 insertions(+), 205 deletions(-) diff --git a/Kconfig b/Kconfig index 3e781bcc57..74de7c7db3 100644 --- a/Kconfig +++ b/Kconfig @@ -405,10 +405,6 @@ config DEBUG_FEATURES Note that enabling this option by itself does not produce debug output. Debug output must also be selected on a subsystem-by-subsystem basis. -config ARCH_HAVE_HEAPCHECK - bool - default n - if DEBUG_FEATURES comment "Debug SYSLOG Output Controls" @@ -1321,14 +1317,39 @@ config DEBUG_USB_INFO endif # DEBUG_USB config DEBUG_WATCHDOG - bool "Watchdog Timer Debug Output" + bool "Watchdog Timer Debug Features" default n depends on WATCHDOG ---help--- - Enable watchdog timer debug SYSLOG output (disabled by default). + Enable watchdog timer debug features. + Support for this debug option is architecture-specific and may not be available for some MCUs. +if DEBUG_WATCHDOG + +config DEBUG_WATCHDOG_ERROR + bool "Watchdog Timer Error Output" + default n + depends on DEBUG_ERROR + ---help--- + Enable watchdog time error output to SYSLOG. + +config DEBUG_WATCHDOG_WARN + bool "Watchdog Timer Warnings Output" + default n + depends on DEBUG_WARN + ---help--- + Enable watchdog time warning output to SYSLOG. + +config DEBUG_WATCHDOG_INFO + bool "Watchdog Timer Informational Output" + default n + depends on DEBUG_INFO + ---help--- + Enable watchdog time informational output to SYSLOG. + +endif # DEBUG_WATCHDOG endif # DEBUG_FEATURES config ARCH_HAVE_STACKCHECK @@ -1346,6 +1367,10 @@ config STACK_COLORATION Only supported by a few architectures. +config ARCH_HAVE_HEAPCHECK + bool + default n + config HEAP_COLORATION bool "Heap coloration" default n diff --git a/arch/arm/src/sam34/sam_wdt.c b/arch/arm/src/sam34/sam_wdt.c index 8fc5abf70c..d54297f5ab 100644 --- a/arch/arm/src/sam34/sam_wdt.c +++ b/arch/arm/src/sam34/sam_wdt.c @@ -81,20 +81,6 @@ # define CONFIG_SAM34_WDT_DEFTIMOUT WDT_MAXTIMEOUT #endif -/* Debug ********************************************************************/ -/* Non-standard debug that may be enabled just for testing the watchdog - * driver. NOTE: that only llerr types are used so that the output is - * immediately available. - */ - -#ifdef CONFIG_DEBUG_WATCHDOG -# define wderr llerr -# define wdinfo llinfo -#else -# define wderr(x...) -# define wdinfo(x...) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ diff --git a/arch/arm/src/sama5/sam_wdt.c b/arch/arm/src/sama5/sam_wdt.c index 60b079df58..be77357e97 100644 --- a/arch/arm/src/sama5/sam_wdt.c +++ b/arch/arm/src/sama5/sam_wdt.c @@ -80,20 +80,6 @@ #define WDT_MINTIMEOUT ((1000 + WDT_FREQUENCY - 1) / WDT_FREQUENCY) #define WDT_MAXTIMEOUT ((4096 * 1000) / WDT_FREQUENCY) -/* Debug ********************************************************************/ -/* Non-standard debug that may be enabled just for testing the watchdog - * driver. NOTE: that only llerr types are used so that the output is - * immediately available. - */ - -#ifdef CONFIG_DEBUG_WATCHDOG -# define wderr llerr -# define wdinfo llinfo -#else -# define wderr(x...) -# define wdinfo(x...) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ diff --git a/arch/arm/src/samv7/sam_rswdt.c b/arch/arm/src/samv7/sam_rswdt.c index a176d22d9c..a097a7056f 100644 --- a/arch/arm/src/samv7/sam_rswdt.c +++ b/arch/arm/src/samv7/sam_rswdt.c @@ -80,20 +80,6 @@ #define RSWDT_MINTIMEOUT ((1000 + RSWDT_FREQUENCY - 1) / RSWDT_FREQUENCY) #define RSWDT_MAXTIMEOUT ((4096 * 1000) / RSWDT_FREQUENCY) -/* Debug ********************************************************************/ -/* Non-standard debug that may be enabled just for testing the watchdog - * driver. NOTE: that only llerr types are used so that the output is - * immediately available. - */ - -#ifdef CONFIG_DEBUG_WATCHDOG -# define wderr llerr -# define wdinfo llinfo -#else -# define wderr(x...) -# define wdinfo(x...) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ diff --git a/arch/arm/src/samv7/sam_wdt.c b/arch/arm/src/samv7/sam_wdt.c index e55405785c..1c2d81cd9b 100644 --- a/arch/arm/src/samv7/sam_wdt.c +++ b/arch/arm/src/samv7/sam_wdt.c @@ -80,20 +80,6 @@ #define WDT_MINTIMEOUT ((1000 + WDT_FREQUENCY - 1) / WDT_FREQUENCY) #define WDT_MAXTIMEOUT ((4096 * 1000) / WDT_FREQUENCY) -/* Debug ********************************************************************/ -/* Non-standard debug that may be enabled just for testing the watchdog - * driver. NOTE: that only llerr types are used so that the output is - * immediately available. - */ - -#ifdef CONFIG_DEBUG_WATCHDOG -# define wderr llerr -# define wdinfo llinfo -#else -# define wderr(x...) -# define wdinfo(x...) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_iwdg.c b/arch/arm/src/stm32/stm32_iwdg.c index cc38922ff5..ab6b052714 100644 --- a/arch/arm/src/stm32/stm32_iwdg.c +++ b/arch/arm/src/stm32/stm32_iwdg.c @@ -105,20 +105,6 @@ # error "Both CONFIG_STM32_IWDG_ONETIMESETUP and CONFIG_STM32_IWDG_DEFERREDSETUP are defined" #endif -/* Debug ********************************************************************/ -/* Non-standard debug that may be enabled just for testing the watchdog - * driver. NOTE: that only llerr types are used so that the output is - * immediately available. - */ - -#ifdef CONFIG_DEBUG_WATCHDOG -# define wderr llerr -# define wdinfo llinfo -#else -# define wderr(x...) -# define wdinfo(x...) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ diff --git a/arch/arm/src/stm32/stm32_wwdg.c b/arch/arm/src/stm32/stm32_wwdg.c index 28a1bd8201..116d8d56ac 100644 --- a/arch/arm/src/stm32/stm32_wwdg.c +++ b/arch/arm/src/stm32/stm32_wwdg.c @@ -81,20 +81,6 @@ # define CONFIG_STM32_WWDG_DEFTIMOUT WWDG_MAXTIMEOUT #endif -/* Debug ********************************************************************/ -/* Non-standard debug that may be enabled just for testing the watchdog - * driver. NOTE: that only llerr types are used so that the output is - * immediately available. - */ - -#ifdef CONFIG_DEBUG_WATCHDOG -# define wderr llerr -# define wdinfo llinfo -#else -# define wderr(x...) -# define wdinfo(x...) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ diff --git a/configs/sam4s-xplained-pro/src/sam_wdt.c b/configs/sam4s-xplained-pro/src/sam_wdt.c index 5ad2a36255..4223671f39 100644 --- a/configs/sam4s-xplained-pro/src/sam_wdt.c +++ b/configs/sam4s-xplained-pro/src/sam_wdt.c @@ -82,34 +82,6 @@ # error "WDT_THREAD_INTERVAL must be greater than or equal to WDT_MINTIME" #endif -/* Debug ***************************************************************************/ -/* Non-standard debug that may be enabled just for testing the watchdog timer */ - -#ifndef CONFIG_DEBUG_FEATURES -# undef CONFIG_DEBUG_WATCHDOG -#endif - -#ifdef CONFIG_DEBUG_WATCHDOG -# define wdgerr err -# define wdgllerr llerr -# ifdef CONFIG_DEBUG_INFO -# define wdginfo info -# define wdgllinfo llinfo -# else -# define wdginfo(x...) -# define wdgllinfo(x...) -# endif -#else -# define wdgerr(x...) -# define wdgllerr(x...) -# define wdginfo(x...) -# define wdgllinfo(x...) -#endif - -/************************************************************************************ - * Private Functions - ************************************************************************************/ - /************************************************************************************ * Public Functions ************************************************************************************/ @@ -124,21 +96,21 @@ static int wdog_daemon(int argc, char *argv[]) /* Open the watchdog device for reading */ - wdginfo("Opening.\n"); + wdinfo("Opening.\n"); fd = open(CONFIG_WATCHDOG_DEVPATH, O_RDONLY); if (fd < 0) { - wdgerr("ERROR: open %s failed: %d\n", CONFIG_WATCHDOG_DEVPATH, errno); + wderr("ERROR: open %s failed: %d\n", CONFIG_WATCHDOG_DEVPATH, errno); goto errout; } /* Start the watchdog timer. */ - wdginfo("Starting.\n"); + wdinfo("Starting.\n"); ret = ioctl(fd, WDIOC_START, 0); if (ret < 0) { - wdgerr("ERROR: ioctl(WDIOC_START) failed: %d\n", errno); + wderr("ERROR: ioctl(WDIOC_START) failed: %d\n", errno); goto errout_with_dev; } @@ -147,11 +119,11 @@ static int wdog_daemon(int argc, char *argv[]) { usleep((CONFIG_WDT_THREAD_INTERVAL)*1000); - wdginfo("ping\n"); + wdinfo("ping\n"); ret = ioctl(fd, WDIOC_KEEPALIVE, 0); if (ret < 0) { - wdgerr("ERROR: ioctl(WDIOC_KEEPALIVE) failed: %d\n", errno); + wderr("ERROR: ioctl(WDIOC_KEEPALIVE) failed: %d\n", errno); goto errout_with_dev; } } @@ -181,36 +153,36 @@ int sam_watchdog_initialize(void) /* Initialize tha register the watchdog timer device */ - wdginfo("Initializing Watchdog driver...\n"); + wdinfo("Initializing Watchdog driver...\n"); sam_wdtinitialize(CONFIG_WATCHDOG_DEVPATH); /* Open the watchdog device */ - wdginfo("Opening.\n"); + wdinfo("Opening.\n"); fd = open(CONFIG_WATCHDOG_DEVPATH, O_RDONLY); if (fd < 0) { - wdgerr("ERROR: open %s failed: %d\n", CONFIG_WATCHDOG_DEVPATH, errno); + wderr("ERROR: open %s failed: %d\n", CONFIG_WATCHDOG_DEVPATH, errno); goto errout; } /* Set the watchdog timeout */ - wdginfo("Timeout = %d.\n", CONFIG_WDT_TIMEOUT); + wdinfo("Timeout = %d.\n", CONFIG_WDT_TIMEOUT); ret = ioctl(fd, WDIOC_SETTIMEOUT, (unsigned long)CONFIG_WDT_TIMEOUT); if (ret < 0) { - wdgerr("ERROR: ioctl(WDIOC_SETTIMEOUT) failed: %d\n", errno); + wderr("ERROR: ioctl(WDIOC_SETTIMEOUT) failed: %d\n", errno); goto errout_with_dev; } /* Set the watchdog minimum time */ - wdginfo("MinTime = %d.\n", CONFIG_WDT_MINTIME); + wdinfo("MinTime = %d.\n", CONFIG_WDT_MINTIME); ret = ioctl(fd, WDIOC_MINTIME, (unsigned long)CONFIG_WDT_MINTIME); if (ret < 0) { - wdgerr("ERROR: ioctl(WDIOC_MINTIME) failed: %d\n", errno); + wderr("ERROR: ioctl(WDIOC_MINTIME) failed: %d\n", errno); goto errout_with_dev; } diff --git a/drivers/timers/watchdog.c b/drivers/timers/watchdog.c index 13b23efd51..e9320a9612 100644 --- a/drivers/timers/watchdog.c +++ b/drivers/timers/watchdog.c @@ -56,24 +56,6 @@ #ifdef CONFIG_WATCHDOG -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ -/* Debug ********************************************************************/ -/* Non-standard debug that may be enabled just for testing the watchdog driver */ - -#ifdef CONFIG_DEBUG_WATCHDOG -# define wderr err -# define wdinfo info -# define wdllerr llerr -# define wdllinfo llinfo -#else -# define wderr(x...) -# define wdinfo(x...) -# define wdllerr(x...) -# define wdllinfo(x...) -#endif - /**************************************************************************** * Private Type Definitions ****************************************************************************/ diff --git a/include/debug.h b/include/debug.h index c644cb48bc..e6c835e552 100644 --- a/include/debug.h +++ b/include/debug.h @@ -285,30 +285,6 @@ # define nllinfo(x...) #endif -#ifdef CONFIG_DEBUG_USB_ERROR -# define uerr(format, ...) err(format, ##__VA_ARGS__) -# define ullerr(format, ...) llerr(format, ##__VA_ARGS__) -#else -# define uerr(x...) -# define ullerr(x...) -#endif - -#ifdef CONFIG_DEBUG_USB_WARN -# define uwarn(format, ...) warn(format, ##__VA_ARGS__) -# define ullwarn(format, ...) llwarn(format, ##__VA_ARGS__) -#else -# define uwarn(x...) -# define ullwarn(x...) -#endif - -#ifdef CONFIG_DEBUG_USB_INFO -# define uinfo(format, ...) info(format, ##__VA_ARGS__) -# define ullinfo(format, ...) llinfo(format, ##__VA_ARGS__) -#else -# define uinfo(x...) -# define ullinfo(x...) -#endif - #ifdef CONFIG_DEBUG_FS_ERROR # define ferr(format, ...) err(format, ##__VA_ARGS__) # define fllerr(format, ...) llerr(format, ##__VA_ARGS__) @@ -765,6 +741,54 @@ # define spillinfo(x...) #endif +#ifdef CONFIG_DEBUG_USB_ERROR +# define uerr(format, ...) err(format, ##__VA_ARGS__) +# define ullerr(format, ...) llerr(format, ##__VA_ARGS__) +#else +# define uerr(x...) +# define ullerr(x...) +#endif + +#ifdef CONFIG_DEBUG_USB_WARN +# define uwarn(format, ...) warn(format, ##__VA_ARGS__) +# define ullwarn(format, ...) llwarn(format, ##__VA_ARGS__) +#else +# define uwarn(x...) +# define ullwarn(x...) +#endif + +#ifdef CONFIG_DEBUG_USB_INFO +# define uinfo(format, ...) info(format, ##__VA_ARGS__) +# define ullinfo(format, ...) llinfo(format, ##__VA_ARGS__) +#else +# define uinfo(x...) +# define ullinfo(x...) +#endif + +#ifdef CONFIG_DEBUG_WATCHDOG_ERROR +# define wderr(format, ...) err(format, ##__VA_ARGS__) +# define wdllerr(format, ...) llerr(format, ##__VA_ARGS__) +#else +# define wderr(x...) +# define wdllerr(x...) +#endif + +#ifdef CONFIG_DEBUG_WATCHDOG_WARN +# define wdwarn(format, ...) warn(format, ##__VA_ARGS__) +# define wdllwarn(format, ...) llwarn(format, ##__VA_ARGS__) +#else +# define wdwarn(x...) +# define wdllwarn(x...) +#endif + +#ifdef CONFIG_DEBUG_WATCHDOG_INFO +# define wdinfo(format, ...) info(format, ##__VA_ARGS__) +# define wdllinfo(format, ...) llinfo(format, ##__VA_ARGS__) +#else +# define wdinfo(x...) +# define wdllinfo(x...) +#endif + #else /* CONFIG_CPP_HAVE_VARARGS */ /* Variadic macros NOT supported */ @@ -898,30 +922,6 @@ # define nllinfo (void) #endif -#ifdef CONFIG_DEBUG_USB_ERROR -# define uerr err -# define ullerr llerr -#else -# define uerr (void) -# define ullerr (void) -#endif - -#ifdef CONFIG_DEBUG_USB_WARN -# define uwarn warn -# define ullwarn llwarn -#else -# define uwarn (void) -# define ullwarn (void) -#endif - -#ifdef CONFIG_DEBUG_USB_INFO -# define uinfo info -# define ullinfo llinfo -#else -# define uinfo (void) -# define ullinfo (void) -#endif - #ifdef CONFIG_DEBUG_FS_ERROR # define ferr err # define fllerr llerr @@ -1378,6 +1378,54 @@ # define spillinfo (void) #endif +#ifdef CONFIG_DEBUG_USB_ERROR +# define uerr err +# define ullerr llerr +#else +# define uerr (void) +# define ullerr (void) +#endif + +#ifdef CONFIG_DEBUG_USB_WARN +# define uwarn warn +# define ullwarn llwarn +#else +# define uwarn (void) +# define ullwarn (void) +#endif + +#ifdef CONFIG_DEBUG_USB_INFO +# define uinfo info +# define ullinfo llinfo +#else +# define uinfo (void) +# define ullinfo (void) +#endif + +#ifdef CONFIG_DEBUG_WATCHDOG_ERROR +# define wderr err +# define wdllerr llerr +#else +# define wderr (void) +# define wdllerr (void) +#endif + +#ifdef CONFIG_DEBUG_WATCHDOG_WARN +# define wdwarn warn +# define wdllwarn llwarn +#else +# define wdwarn (void) +# define wdllwarn (void) +#endif + +#ifdef CONFIG_DEBUG_WATCHDOG_INFO +# define wdinfo info +# define wdllinfo llinfo +#else +# define wdinfo (void) +# define wdllinfo (void) +#endif + #endif /* CONFIG_CPP_HAVE_VARARGS */ /* Buffer dumping macros do not depend on varargs */ @@ -1428,14 +1476,6 @@ # define ninfodumpbuffer(m,b,n) #endif -#ifdef CONFIG_DEBUG_USB -# define uerrdumpbuffer(m,b,n) errdumpbuffer(m,b,n) -# define uinfodumpbuffer(m,b,n) infodumpbuffer(m,b,n) -#else -# define uerrdumpbuffer(m,b,n) -# define uinfodumpbuffer(m,b,n) -#endif - #ifdef CONFIG_DEBUG_FS # define ferrdumpbuffer(m,b,n) errdumpbuffer(m,b,n) # define finfodumpbuffer(m,b,n) infodumpbuffer(m,b,n) @@ -1572,6 +1612,22 @@ # define sninfodumpbuffer(m,b,n) #endif +#ifdef CONFIG_DEBUG_USB +# define uerrdumpbuffer(m,b,n) errdumpbuffer(m,b,n) +# define uinfodumpbuffer(m,b,n) infodumpbuffer(m,b,n) +#else +# define uerrdumpbuffer(m,b,n) +# define uinfodumpbuffer(m,b,n) +#endif + +#ifdef CONFIG_DEBUG_WATCHDOG +# define wderrdumpbuffer(m,b,n) errdumpbuffer(m,b,n) +# define wdinfodumpbuffer(m,b,n) infodumpbuffer(m,b,n) +#else +# define wderrdumpbuffer(m,b,n) +# define wdinfodumpbuffer(m,b,n) +#endif + /**************************************************************************** * Public Type Declarations ****************************************************************************/