diff options
author | Zhang Jiejing <jiejing.zhang@freescale.com> | 2012-05-02 13:38:07 +0800 |
---|---|---|
committer | Zhang Jiejing <jiejing.zhang@freescale.com> | 2012-05-03 10:11:34 +0800 |
commit | 72c5e50117057e6f3d0d8a8f91165942a625fc1d (patch) | |
tree | 8c9064565c05804ed038e158d0b36173ba4699c8 /drivers | |
parent | 41e4045d17de48d44a04481500c14a3dfcaa1582 (diff) |
ENGR00181387-1 suspend: add suspend counter driver
Add a misc driver to print suspend counter.
This driver not touch any common/core code,
only receive the broadcasts and print some logs.
Signed-off-by: Zhang Jiejing <jiejing.zhang@freescale.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/misc/Kconfig | 8 | ||||
-rw-r--r-- | drivers/misc/Makefile | 1 | ||||
-rw-r--r-- | drivers/misc/suspend_counter.c | 63 |
3 files changed, 72 insertions, 0 deletions
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index fddb3c567afc..28943647456e 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -384,6 +384,14 @@ config SENSORS_APDS990X To compile this driver as a module, choose M here: the module will be called apds990x. If unsure, say N here. +config SUSPEND_COUNTER + tristate "Suspend counter print suspend count meesage" + depends on SUSPEND + default n + help + Say Y here if you want to enable suspend counter + It will print suspend and counter message in console + config HMC6352 tristate "Honeywell HMC6352 compass" depends on I2C diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 3f0b6e77cbff..285a30e9be28 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -30,6 +30,7 @@ obj-$(CONFIG_APDS9802ALS) += apds9802als.o obj-$(CONFIG_ISL29003) += isl29003.o obj-$(CONFIG_ISL29020) += isl29020.o obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o +obj-$(CONFIG_SUSPEND_COUNTER) += suspend_counter.o obj-$(CONFIG_EP93XX_PWM) += ep93xx_pwm.o obj-$(CONFIG_DS1682) += ds1682.o obj-$(CONFIG_TI_DAC7512) += ti_dac7512.o diff --git a/drivers/misc/suspend_counter.c b/drivers/misc/suspend_counter.c new file mode 100644 index 000000000000..4aec4ab37c8c --- /dev/null +++ b/drivers/misc/suspend_counter.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2012 Freescale Semiconductor, Inc. All Rights Reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <linux/module.h> +#include <linux/init.h> +#include <linux/slab.h> +#include <linux/suspend.h> +#include <linux/delay.h> + + +static int suspend_counter; +static ktime_t suspend_time; +static ktime_t tmp_time; + +static int suspend_counter_notifier(struct notifier_block *nb, + unsigned long event, void *dummy) +{ + struct timespec tv; + switch (event) { + case PM_SUSPEND_PREPARE: + suspend_counter++; + suspend_time = ktime_get_real(); + printk(KERN_INFO "suspend: start %d suspend...\n", + suspend_counter); + case PM_POST_SUSPEND: + tmp_time = ktime_sub(ktime_get_real(), suspend_time); + tv = ktime_to_timespec(tmp_time); + printk(KERN_INFO "suspend: finish %d suspend " + "after:%lu.%03lu seconds...\n", + suspend_counter, + (unsigned long) tv.tv_sec, + (unsigned long) tv.tv_nsec); + default: + break; + } + return 0; +} + +static struct notifier_block suspend_counter_notifier_block = { + .notifier_call = suspend_counter_notifier, +}; + +static int __init suspend_counter_init(void) +{ + return register_pm_notifier(&suspend_counter_notifier_block); +} + +device_initcall(suspend_counter_init); |