input: vsense: disable irqs on suspend
authorGrazvydas Ignotas <notasas@gmail.com>
Thu, 19 Jul 2012 21:18:53 +0000 (00:18 +0300)
committerGrazvydas Ignotas <notasas@gmail.com>
Mon, 6 Aug 2012 22:11:28 +0000 (01:11 +0300)
We can't access the device when i2c is disabled, so just turn off irqs
to that we are not even bothered.

drivers/input/misc/vsense.c

index 8b1f063..4d37774 100644 (file)
@@ -638,6 +638,32 @@ static int __devexit vsense_remove(struct i2c_client *client)
        return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int vsense_i2c_suspend(struct device *dev)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+       struct vsense_drvdata *ddata = i2c_get_clientdata(client);
+
+       /* we can't process irqs while i2c is suspended and we can't
+        * ask the device to not generate them, so just disable instead */
+       cancel_delayed_work_sync(&ddata->work);
+       disable_irq(client->irq);
+
+       return 0;
+}
+
+static int vsense_i2c_resume(struct device *dev)
+{
+       struct i2c_client *client = to_i2c_client(dev);
+
+       enable_irq(client->irq);
+
+       return 0;
+}
+#endif /* CONFIG_PM_SLEEP */
+
+static SIMPLE_DEV_PM_OPS(vsense_pm_ops, vsense_i2c_suspend, vsense_i2c_resume);
+
 static const struct i2c_device_id vsense_id[] = {
        { "vsense", 0 },
        { }
@@ -646,6 +672,8 @@ static const struct i2c_device_id vsense_id[] = {
 static struct i2c_driver vsense_driver = {
        .driver = {
                .name   = "vsense",
+               .owner  = THIS_MODULE,
+               .pm     = &vsense_pm_ops,
        },
        .probe          = vsense_probe,
        .remove         = __devexit_p(vsense_remove),