media: video: tegra: lm3565: timer cannot be zero
Charlie Huang [Fri, 29 Mar 2013 23:00:07 +0000 (16:00 -0700)]
a zero timer can cause the camera app crash.

bug 1263377

Change-Id: I857a32bfbc86359805e2dc8b47fcdf3ad2d45d04
Signed-off-by: Charlie Huang <chahuang@nvidia.com>
Reviewed-on: http://git-master/r/214713
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Thomas Cherry <tcherry@nvidia.com>

drivers/media/video/tegra/lm3565.c

index edf6a82..dda3f0e 100644 (file)
@@ -66,7 +66,7 @@
 
 #define LM3565_MAX_FLASH_LEVEL         17
 #define LM3565_MAX_TORCH_LEVEL         3
-#define LM3565_FLASH_TIMER_NUM         257
+#define LM3565_FLASH_TIMER_NUM         256
 #define LM3565_TORCH_TIMER_NUM         1
 
 #define LM3565_LEVEL_OFF               0xFFFF
@@ -528,8 +528,8 @@ static int lm3565_configure(struct lm3565_info *info, bool update)
        pfcap->timeout_off = (void *)ptmcap - (void *)pfcap;
        pfcap->timeout_num = LM3565_FLASH_TIMER_NUM;
        ptmcap->timeout_num = LM3565_FLASH_TIMER_NUM;
-       for (i = 1; i < ptmcap->timeout_num; i++) {
-               ptmcap->timeouts[i].timeout = 2000 * i;
+       for (i = 0; i < ptmcap->timeout_num; i++) {
+               ptmcap->timeouts[i].timeout = 2000 * (i + 1);
                dev_dbg(info->dev,
                        "t: %03d - %06d uS\n", i, ptmcap->timeouts[i].timeout);
        }