* [PATCH 4/6] mfd/ab8500: print switch off cause
@ 2012-04-17 7:30 Linus Walleij
2012-05-01 11:16 ` Samuel Ortiz
0 siblings, 1 reply; 2+ messages in thread
From: Linus Walleij @ 2012-04-17 7:30 UTC (permalink / raw)
To: Samuel Ortiz, linux-kernel; +Cc: Jonas Aaberg, Linus Walleij
From: Jonas Aaberg <jonas.aberg@stericsson.com>
Instead of just printing the register value, also output some
description of the value.
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Reviewed-by: Mattias Wallin <mattias.wallin@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/mfd/ab8500-core.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c
index eee9560..9781e1e 100644
--- a/drivers/mfd/ab8500-core.c
+++ b/drivers/mfd/ab8500-core.c
@@ -1072,6 +1072,16 @@ static struct attribute_group ab9540_attr_group = {
int __devinit ab8500_init(struct ab8500 *ab8500, enum ab8500_version version)
{
+ static char *switch_off_status[] = {
+ "Swoff bit programming",
+ "Thermal protection activation",
+ "Vbat lower then BattOk falling threshold",
+ "Watchdog expired",
+ "Non presence of 32kHz clock",
+ "Battery level lower than power on reset threshold",
+ "Power on key 1 pressed longer than 10 seconds",
+ "DB8500 thermal shutdown"};
+
struct ab8500_platform_data *plat = dev_get_platdata(ab8500->dev);
int ret;
int i;
@@ -1139,7 +1149,20 @@ int __devinit ab8500_init(struct ab8500 *ab8500, enum ab8500_version version)
AB8500_SWITCH_OFF_STATUS, &value);
if (ret < 0)
return ret;
- dev_info(ab8500->dev, "switch off status: %#x", value);
+ dev_info(ab8500->dev, "switch off cause(s) (%#x): ", value);
+
+ if (value) {
+ for (i = 0; i < ARRAY_SIZE(switch_off_status); i++) {
+ if (value & 1)
+ printk("\"%s\" ", switch_off_status[i]);
+ value = value >> 1;
+
+ }
+ printk("\n");
+ } else {
+ printk("None\n");
+ }
+
if (plat && plat->init)
plat->init(ab8500);
--
1.7.9.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 4/6] mfd/ab8500: print switch off cause
2012-04-17 7:30 [PATCH 4/6] mfd/ab8500: print switch off cause Linus Walleij
@ 2012-05-01 11:16 ` Samuel Ortiz
0 siblings, 0 replies; 2+ messages in thread
From: Samuel Ortiz @ 2012-05-01 11:16 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-kernel, Jonas Aaberg, Linus Walleij
Hi Linus,
On Tue, Apr 17, 2012 at 09:30:40AM +0200, Linus Walleij wrote:
> @@ -1139,7 +1149,20 @@ int __devinit ab8500_init(struct ab8500 *ab8500, enum ab8500_version version)
> AB8500_SWITCH_OFF_STATUS, &value);
> if (ret < 0)
> return ret;
> - dev_info(ab8500->dev, "switch off status: %#x", value);
> + dev_info(ab8500->dev, "switch off cause(s) (%#x): ", value);
> +
> + if (value) {
> + for (i = 0; i < ARRAY_SIZE(switch_off_status); i++) {
> + if (value & 1)
> + printk("\"%s\" ", switch_off_status[i]);
> + value = value >> 1;
> +
> + }
> + printk("\n");
> + } else {
> + printk("None\n");
> + }
So if your default loglevel is not KERN_INFO, you may miss the dev_info
output while getting the printk one. Why not using dev_info() only with e.g.
tabs for the causes ?
Cheers,
Samuel.
--
Intel Open Source Technology Centre
http://oss.intel.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-05-01 11:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-17 7:30 [PATCH 4/6] mfd/ab8500: print switch off cause Linus Walleij
2012-05-01 11:16 ` Samuel Ortiz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox