diff options
| author | Viditha Hanumanthareddy <ngjq36@motorola.com> | 2014-10-09 13:21:38 -0500 |
|---|---|---|
| committer | Viditha H <ngjq36@motorola.com> | 2014-11-03 16:55:00 +0000 |
| commit | 1ed2c055841349716a07e0e9f2d3bd5dda28913a (patch) | |
| tree | 7eb106b3815e1ea62f478ca1925dc04b964b498c | |
| parent | 7e89d1dec09111bcbac2d7aa4a0484ee302d4f02 (diff) | |
| download | olio-linux-3.10-1ed2c055841349716a07e0e9f2d3bd5dda28913a.tar.xz olio-linux-3.10-1ed2c055841349716a07e0e9f2d3bd5dda28913a.zip | |
IKXCLOCK-4153: M4 logger enhancements
Change-Id: I8a3d2f5a7c367dbbe28b0422ff508a4921624249
| -rw-r--r-- | drivers/mfd/m4sensorhub-core.c | 62 | ||||
| -rw-r--r-- | include/linux/m4sensorhub/MemMapLog.h | 111 |
2 files changed, 97 insertions, 76 deletions
diff --git a/drivers/mfd/m4sensorhub-core.c b/drivers/mfd/m4sensorhub-core.c index a10ab20280b..7a7976bd45b 100644 --- a/drivers/mfd/m4sensorhub-core.c +++ b/drivers/mfd/m4sensorhub-core.c @@ -540,20 +540,27 @@ static DEVICE_ATTR(debug_level, S_IRUSR|S_IWUSR, m4sensorhub_get_dbg, static ssize_t m4sensorhub_get_loglevel(struct device *dev, struct device_attribute *attr, char *buf) { - unsigned long long loglevel; + uint32_t logenable[LOG_EN_SIZE], len, i; m4sensorhub_reg_read(&m4sensorhub_misc_data, - M4SH_REG_LOG_LOGENABLE, (char *)&loglevel); - KDEBUG(M4SH_INFO, "M4 loglevel = %llx", loglevel); - return sprintf(buf, "%llu\n", loglevel); + M4SH_REG_LOG_LOGENABLE, (char *)&logenable); + + len = sprintf(tempbuf, "M4 log levels = 0x"); + for (i = 0; i < LOG_EN_SIZE; i++) + len += sprintf(buf+len, "%08x", logenable[i]); + KDEBUG(M4SH_INFO, "%s\n", buf); + return snprintf(buf, PAGE_SIZE, "%s\n", buf); } -void m4sensorhub_update_loglevels(char *tag, char *level, - unsigned long long *log_levels) +void m4sensorhub_update_loglevels(int8_t *tag, int8_t *level, + uint32_t *log_level) { - int i; - int levelindex = -1; - int tagindex = -1; - unsigned long long mask; + uint32_t i; + int32_t levelindex = -1; + int32_t tagindex = -1; + uint32_t mask; + int32_t logenableindex; + int32_t en = LOG_TAGS_PER_ENABLE; + int32_t b = LOG_NO_OF_BITS_PER_TAG; for (i = 0; i < LOG_LEVELS_MAX; i++) { if (strcmp(acLogLevels[i], level) == 0) { @@ -568,16 +575,21 @@ void m4sensorhub_update_loglevels(char *tag, char *level, break; } } - if ((tagindex == -1) || (levelindex == -1)) return; + logenableindex = tagindex/LOG_TAGS_PER_ENABLE; + /*Clear the revelant bits*/ - mask = 0x03; - *log_levels &= ~(mask << (tagindex * 2)); + mask = LOG_TAG_MASK; + *(log_level+logenableindex) &= ~(mask << ((tagindex % en) * b)); /*set debug level for the relevant bits*/ - *log_levels |= (levelindex << (tagindex * 2)); - KDEBUG(M4SH_INFO, "New M4 log levels = 0x%llx\n", *log_levels); + *(log_level+logenableindex) |= (levelindex << ((tagindex % en) * b)); + + KDEBUG(M4SH_DEBUG, "New M4 log levels = "); + for (i = 0; i < LOG_EN_SIZE; i++) + KDEBUG(M4SH_DEBUG, "enable %d = 0x%08x ", i, *(log_level+i)); + KDEBUG(M4SH_DEBUG, "\n"); } /* Usage: adb shell into the directory of sysinterface log_level and @@ -585,25 +597,29 @@ void m4sensorhub_update_loglevels(char *tag, char *level, static ssize_t m4sensorhub_set_loglevel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - unsigned long long cur_loglevels; + uint32_t cur_loglevels[LOG_EN_SIZE]; char *tag, *level; char **logbuf = (char **) &buf; m4sensorhub_reg_read(&m4sensorhub_misc_data, - M4SH_REG_LOG_LOGENABLE, (char *)&cur_loglevels); + M4SH_REG_LOG_LOGENABLE, (char *)cur_loglevels); + while (1) { tag = strsep(logbuf, "=,\n "); - if (tag == NULL) + if ((tag == NULL) || (logbuf == NULL)) break; level = strsep(logbuf, "=,\n "); - if (level == NULL) + if ((level == NULL) || (logbuf == NULL)) break; - m4sensorhub_update_loglevels(tag, level, &cur_loglevels); + m4sensorhub_update_loglevels(tag, level, + (uint32_t *)cur_loglevels); } - return m4sensorhub_reg_write(&m4sensorhub_misc_data, - M4SH_REG_LOG_LOGENABLE, (char *)&cur_loglevels, - m4sh_no_mask); + m4sensorhub_reg_write(&m4sensorhub_misc_data, + M4SH_REG_LOG_LOGENABLE, (char *)cur_loglevels, + m4sh_no_mask); + + return count; } static DEVICE_ATTR(log_level, S_IRUSR|S_IWUSR, m4sensorhub_get_loglevel, diff --git a/include/linux/m4sensorhub/MemMapLog.h b/include/linux/m4sensorhub/MemMapLog.h index 9aab2f4cea8..2b7882a4df4 100644 --- a/include/linux/m4sensorhub/MemMapLog.h +++ b/include/linux/m4sensorhub/MemMapLog.h @@ -1,53 +1,58 @@ -/**********************************************************************
-*
-* Copyright (C) 2012 Motorola, Inc.
-*
-**********************************************************************
-File : MemMapLog.h
-Purpose :
-**********************************************************************/
-#ifndef __MEMMAP_LOG_H__
-#define __MEMMAP_LOG_H__
-/****************************** Defines *******************************/
-struct memMapLog
-{
- u64 logEnable;
- u8 isLogImmediate;
-};
-
-#define LOG_MAX 24
-#define LOG_LEVELS_MAX 4
-
-static char acLogTags[LOG_MAX][40] = {
- "LOG_GENERAL",
- "LOG_TIMER",
- "LOG_ACCEL",
- "LOG_TEMPERATURE",
- "LOG_PRESSURE",
- "LOG_PEDOMETER",
- "LOG_TCMD",
- "LOG_GYRO",
- "LOG_COMPASS",
- "LOG_FUSION",
- "LOG_METS",
- "LOG_GESTURE",
- "LOG_POWER",
- "LOG_CORRELATION",
- "LOG_GPS",
- "LOG_DL",
- "LOG_AUDIO",
- "LOG_DISP",
- "LOG_WRIST",
- "LOG_PASSIVE",
- "LOG_EMG"
- "LOG_HR",
- "LOG_ALS"
-};
-
-static char acLogLevels[LOG_LEVELS_MAX][15] = {
- "LOG_DISABLE",
- "LOG_ERROR",
- "LOG_VERBOSE",
- "LOG_DEBUG"
-};
-#endif /* __MEMMAP_LOG_H__ */
+/********************************************************************** +* +* Copyright (C) 2012 Motorola, Inc. +* +********************************************************************** +File : MemMapLog.h +Purpose : +**********************************************************************/ +#ifndef __MEMMAP_LOG_H__ +#define __MEMMAP_LOG_H__ +/****************************** Defines *******************************/ +#define LOG_EN_SIZE 2 +/* Number of log tags per element of logenable array */ +#define LOG_TAGS_PER_ENABLE 16 +#define LOG_MAX 23 +#define LOG_NO_OF_BITS_PER_TAG 2 +/*This is set to 0x03 since each logtag uses 2 bits in logenable */ +#define LOG_TAG_MASK 0x03 +#define LOG_LEVELS_MAX 4 + +struct memMapLog { + u32 logEnable[LOG_EN_SIZE]; + u8 isLogImmediate; +}; + +static char acLogTags[LOG_MAX][40] = { + "LOG_GENERAL", + "LOG_TIMER", + "LOG_ACCEL", + "LOG_TEMPERATURE", + "LOG_PRESSURE", + "LOG_PEDOMETER", + "LOG_TCMD", + "LOG_GYRO", + "LOG_COMPASS", + "LOG_FUSION", + "LOG_METS", + "LOG_GESTURE", + "LOG_POWER", + "LOG_CORRELATION", + "LOG_GPS", + "LOG_DL", + "LOG_AUDIO", + "LOG_DISP", + "LOG_WRIST", + "LOG_PASSIVE", + "LOG_EMG", + "LOG_HR", + "LOG_ALS", +}; + +static char acLogLevels[LOG_LEVELS_MAX][15] = { + "LOG_DISABLE", + "LOG_ERROR", + "LOG_VERBOSE", + "LOG_DEBUG" +}; +#endif /* __MEMMAP_LOG_H__ */ |