The old driver does not support runtime pm feature. This patch add keypad runtime pm support. As a keypad driver, it will never go to power down mode. HW will goto power saving mode when there is no key pressed. So the runtime pm callback functions do nothing.
Signed-off-by: Bin Yang <[email protected]> --- drivers/input/keyboard/tc35894xbg.c | 32 +++++++++++++++++++++++++++++++- 1 files changed, 31 insertions(+), 1 deletions(-) diff --git a/drivers/input/keyboard/tc35894xbg.c b/drivers/input/keyboard/tc35894xbg.c index 321892f..5c39f09 100644 --- a/drivers/input/keyboard/tc35894xbg.c +++ b/drivers/input/keyboard/tc35894xbg.c @@ -19,6 +19,7 @@ #include <linux/device.h> #include <linux/gpio.h> #include <linux/slab.h> +#include <linux/pm_runtime.h> #include <linux/i2c/tc35894xbg.h> #include "tc35894xbg_regs.h" @@ -659,6 +660,10 @@ keypad_probe(struct i2c_client *client, const struct i2c_device_id *id) device_init_wakeup(&client->dev, 1); enable_irq_wake(client->irq); + pm_runtime_set_active(&client->dev); + pm_runtime_enable(&client->dev); + pm_runtime_allow(&client->dev); + return 0; fail3: input_unregister_device(idev); @@ -679,6 +684,8 @@ static int __devexit keypad_remove(struct i2c_client *client) dev_dbg(&client->dev, "keypad driver remove\n"); + pm_runtime_forbid(&client->dev); + pm_runtime_disable(&client->dev); disable_irq_wake(client->irq); free_irq(client->irq, tc); cancel_work_sync(&tc->work); @@ -725,9 +732,24 @@ static int keypad_resume(struct i2c_client *client) return 0; } +static int keypad_runtime_suspend(struct device *dev) +{ + /*it has nothing to do here. this device will not + be power down in runtime suspend*/ + return 0; +} + +static int keypad_runtime_resume(struct device *dev) +{ + /*it has nothing to do here. this device will not + be power down in runtime suspend*/ + return 0; +} #else #define keypad_suspend NULL #define keypad_resume NULL +#define keypad_runtime_suspend NULL +#define keypad_runtime_resume NULL #endif @@ -737,9 +759,17 @@ static const struct i2c_device_id keypad_id[] = { { } }; +static const struct dev_pm_ops keypad_pm = { + .runtime_suspend = keypad_runtime_suspend, + .runtime_resume = keypad_runtime_resume, +}; + static struct i2c_driver keypad_i2c_driver = { .class = I2C_CLASS_HWMON, - .driver = {.name = "keypad",}, + .driver = { + .name = "keypad", + .pm = &keypad_pm, + }, .probe = keypad_probe, .remove = __devexit_p(keypad_remove), .suspend = keypad_suspend, -- 1.7.0.4 _______________________________________________ MeeGo-kernel mailing list [email protected] http://lists.meego.com/listinfo/meego-kernel
