staging: iio: light: cm3217: report valid events
Sri Krishna chowdary [Fri, 16 Aug 2013 13:02:28 +0000 (18:02 +0530)]
1. polling delay set by user should be greater than
minimum time that an ADC conversion of luminance happens.
Else sensor will simply report zero.

2. After enabling the sensor, wait for one polling delay
before start reading the luminance values.

Bug 1350036

Change-Id: I64facd1a6ee7ef1870ce1ef90942e444b9744a3a
Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com>
(cherry picked from commit bfa4af9fb1499f04fc56b45d31e31b4db17f2f86)
Reviewed-on: http://git-master/r/281704
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: David Yu (Engrg-SW) <davyu@nvidia.com>
Tested-by: David Yu (Engrg-SW) <davyu@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Robert Collins <rcollins@nvidia.com>
Reviewed-by: Gabby Lee <galee@nvidia.com>

drivers/staging/iio/light/cm3217.c

index 7577322..32f4347 100644 (file)
@@ -370,7 +370,7 @@ static int lightsensor_enable(struct cm3217_info *lpi)
                pr_err("[LS][CM3217 error]%s: set auto light sensor fail\n",
                       __func__);
 
-       queue_work(lpi->lp_wq, &report_work.work);
+       queue_delayed_work(lpi->lp_wq, &report_work, lpi->polling_delay);
        lpi->als_enable = 1;
 
        mutex_unlock(&lpi->enable_lock);
@@ -468,7 +468,8 @@ static long lightsensor_ioctl(struct file *file, unsigned int cmd,
                D("[LS][CM3217] %s LIGHTSENSOR_IOCTL_SET_DELAY, delay %ld\n",
                        __func__, delay);
                delay = delay / 1000;
-               lpi->polling_delay = msecs_to_jiffies(delay);
+               if (delay > LS_POLLING_DELAY)
+                       lpi->polling_delay = msecs_to_jiffies(delay);
                break;
 
        default: