sys_log: replace old debug macros at ADC driver

ADC driver is now using new system log macros, also update the Kconfig
variable to be a level rather than a bool.
JIRA: ZEP-311

Change-Id: Iac96c37989e44484808ded515397d457186240e0
Signed-off-by: Genaro Saucedo Tejada <genaro.saucedo.tejada@intel.com>
This commit is contained in:
Genaro Saucedo Tejada 2016-06-13 12:21:06 -05:00 committed by Inaky Perez-Gonzalez
parent e8d0090808
commit a679f32920
2 changed files with 27 additions and 21 deletions

View File

@ -26,12 +26,27 @@ menuconfig ADC
help
Enable ADC (Analog to Digital Converter) driver configuration
config ADC_DEBUG
bool "ADC drivers debug output"
config SYS_LOG_ADC_LEVEL
int
prompt "ADC drivers log level"
depends on ADC
default n
default 0
range 0 4
help
Enable debug output for ADC drivers
Sets log level for ADC driver.
Levels are:
- 0 OFF, do not write
- 1 ERROR, only write SYS_LOG_ERR
- 2 WARNING, write SYS_LOG_WRN in adition to previous level
- 3 INFO, write SYS_LOG_INF in adition to previous levels
- 4 DEBUG, write SYS_LOG_DBG in adition to previous levels
config ADC_INIT_PRIORITY
int

View File

@ -20,28 +20,19 @@
#include <nanokernel.h>
#include <misc/util.h>
#define SYS_LOG_NO_NEWLINE
#define SYS_LOG_LEVEL CONFIG_SYS_LOG_ADC_LEVEL
#include <misc/sys_log.h>
#include <string.h>
#include <init.h>
#include "adc_ti_adc108s102.h"
#ifndef CONFIG_ADC_DEBUG
#define DBG(...) { ; }
#else
#if defined(CONFIG_STDOUT_CONSOLE)
#include <stdio.h>
#define DBG printf
#else
#include <misc/printk.h>
#define DBG printk
#endif /* CONFIG_STDOUT_CONSOLE */
#endif /* CONFIG_ADC_DEBUG */
static inline int _ti_adc108s102_sampling(struct device *dev)
{
struct ti_adc108s102_data *adc = dev->driver_data;
DBG("Sampling!\n");
SYS_LOG_DBG("Sampling!\n");
/* SPI deals with uint8_t buffers so multiplying by 2 the length */
return spi_transceive(adc->spi, adc->cmd_buffer,
@ -58,7 +49,7 @@ static inline void _ti_adc108s102_handle_result(struct device *dev)
struct adc_seq_entry *entry;
uint32_t s_i, i;
DBG("_ti_adc108s102_handle_result()");
SYS_LOG_DBG("_ti_adc108s102_handle_result()");
for (i = 0, s_i = 1; i < seq_table->num_entries; i++, s_i++) {
entry = &seq_table->entries[i];
@ -95,7 +86,7 @@ static inline int32_t _ti_adc108s102_prepare(struct device *dev)
continue;
}
DBG("Requesting channel %d\n", entry->channel_id);
SYS_LOG_DBG("Requesting channel %d\n", entry->channel_id);
adc->cmd_buffer[adc->cmd_buf_len] =
ADC108S102_CHANNEL_CMD(entry->channel_id);
@ -113,7 +104,7 @@ static inline int32_t _ti_adc108s102_prepare(struct device *dev)
adc->cmd_buffer[adc->cmd_buf_len] = 0;
adc->cmd_buf_len++;
DBG("ADC108S102 is prepared...");
SYS_LOG_DBG("ADC108S102 is prepared...");
return sampling_delay;
}
@ -226,7 +217,7 @@ int ti_adc108s102_init(struct device *dev)
return -EPERM;
}
DBG("ADC108s102 initialized\n");
SYS_LOG_DBG("ADC108s102 initialized\n");
dev->driver_api = &ti_adc108s102_api;