From 5b8774c73e835cfe43da5f529bb3e84ac38d1b2c Mon Sep 17 00:00:00 2001 From: Kazuhiro Ondo Date: Mon, 29 Nov 2010 22:03:00 -0600 Subject: [PATCH] misc: kxtf9: If enabled before suspend, reenable If the sensor were enabled on suspend, reenable it on resume. Without this change the sensor stops sending data if it were kept open across suspend and resume. Commit for Ken Hu Change-Id: Ifea2c8ed30d350a5e41d73a530faa89c1e4b5f2b Signed-off-by: Rebecca Schultz Zavin --- drivers/misc/kxtf9.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/misc/kxtf9.c b/drivers/misc/kxtf9.c index 6eaa64abf043..7a4d233fb24c 100755 --- a/drivers/misc/kxtf9.c +++ b/drivers/misc/kxtf9.c @@ -125,6 +125,7 @@ struct kxtf9_data { int hw_initialized; atomic_t enabled; + int enabled_b4_suspend; u8 shift_adj; u8 resume_state[RESUME_ENTRIES]; int irq; @@ -1151,6 +1152,7 @@ static int kxtf9_probe(struct i2c_client *client, kxtf9_device_power_off(tf9); atomic_set(&tf9->enabled, 0); + tf9->enabled_b4_suspend = 0; err = request_irq(tf9->irq, kxtf9_isr, IRQF_TRIGGER_RISING, "kxtf9_irq", tf9); @@ -1207,15 +1209,21 @@ static int __devexit kxtf9_remove(struct i2c_client *client) static int kxtf9_resume(struct i2c_client *client) { + int err = -1 ; struct kxtf9_data *tf9 = i2c_get_clientdata(client); - - return kxtf9_enable(tf9); + if(tf9->enabled_b4_suspend != 0) { + err = kxtf9_enable(tf9); + if(!err) { + err = kxtf9_update_odr(tf9,tf9->pdata->poll_interval); + } + } + return err; } static int kxtf9_suspend(struct i2c_client *client, pm_message_t mesg) { struct kxtf9_data *tf9 = i2c_get_clientdata(client); - + tf9->enabled_b4_suspend = atomic_read(&tf9->enabled); return kxtf9_disable(tf9); } -- 2.34.1