static int tmf8829_app_poll_irq_thread(void *tof_chip)
{
tmf8829_chip *chip = (tmf8829_chip *)tof_chip;
int us_sleep = 0;
int period = chip->tof_core.config[TMF8829_CFG_PERIOD_MS_MSB-TMF8829_CFG_PERIOD_MS_LSB] * 256;
period += chip->tof_core.config[TMF8829_CFG_PERIOD_MS_LSB];
AMS_MUTEX_LOCK(&chip->lock);
us_sleep = period * 1000;// Poll period is interpreted in units of 100 usec
if (us_sleep == 0 ) {
us_sleep = 10000;
}
dev_info(&chip->client->dev, "Starting ToF irq polling thread, period: %u us\n", us_sleep);
AMS_MUTEX_UNLOCK(&chip->lock);
while (!kthread_should_stop()) {
(void) tof_irq_handler(0, tof_chip);
delayInMicroseconds(us_sleep);
}
return 0;
}
The line period += chip->tof_core.config[TMF8829_CFG_PERIOD_MS_LSB]; is incorrect; the array access should be [TMF8829_CFG_PERIOD_MS_LSB-TMF8829_CFG_PERIOD_MS_LSB] or [0] instead.
The line
period += chip->tof_core.config[TMF8829_CFG_PERIOD_MS_LSB];is incorrect; the array access should be[TMF8829_CFG_PERIOD_MS_LSB-TMF8829_CFG_PERIOD_MS_LSB]or[0]instead.