]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
staging: iio: light: add shutdown
authorSang-Hun Lee <sanlee@nvidia.com>
Mon, 9 Jun 2014 21:48:18 +0000 (17:48 -0400)
committerSimone Willett <swillett@nvidia.com>
Wed, 11 Jun 2014 17:11:24 +0000 (10:11 -0700)
 - Depending on the platform, i2c bus may be shutdown
   as we shutdown the systme
 - In such a case, any lingering workqueue would slowdown
   the system, as the access will be made to the i2c bus
   which has been shutdown
 - To mitigate the above, cancel all workqueue jobs as we shutdown

Bug 1522172

Change-Id: Idebab822c0ef8ddad7352ef25a546acb3f3e5870
Signed-off-by: Sang-Hun Lee <sanlee@nvidia.com>
Reviewed-on: http://git-master/r/420889
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sri Krishna Chowdary <schowdary@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Sri Krishna Chowdary <schowdary@nvidia.com>
drivers/staging/iio/light/cm3217.c

index 35f54c714463dc9c247526999b7f94c2e28a7810..a104341b4c2865f3a97835f08160ba9ea142a05d 100644 (file)
@@ -517,6 +517,16 @@ static const struct i2c_device_id cm3217_i2c_device_id[] = {
 
 MODULE_DEVICE_TABLE(i2c, cm3217_i2c_device_id);
 
+static void cm3217_shutdown(struct i2c_client *client)
+{
+       struct iio_dev *indio_dev = i2c_get_clientdata(client);
+       struct cm3217_inf *inf = iio_priv(indio_dev);
+       inf->als_state = CHIP_POWER_OFF;
+       smp_wmb();
+       cancel_delayed_work_sync(&inf->dw);
+       cm3217_vreg_exit(inf);
+}
+
 #ifdef CONFIG_OF
 static const struct of_device_id cm3217_of_match[] = {
        { .compatible = "capella,cm3217", },
@@ -535,6 +545,7 @@ static struct i2c_driver cm3217_driver = {
                .of_match_table = of_match_ptr(cm3217_of_match),
                .pm = CM3217_PM_OPS,
        },
+       .shutdown = cm3217_shutdown,
 };
 module_i2c_driver(cm3217_driver);