diff options
| author | Viditha Hanumanthareddy <ngjq36@motorola.com> | 2014-07-01 12:59:44 -0500 |
|---|---|---|
| committer | Viditha H <ngjq36@motorola.com> | 2014-07-02 18:33:40 +0000 |
| commit | 293bf865f34e276119e34ad03bcd459e240ecd42 (patch) | |
| tree | a97cef422dc6afac039a573c4f68649d4574cbd7 /drivers/misc/m4sensorhub_pedometer.c | |
| parent | 87657812726120dcf42db4086fcc96163dfa9907 (diff) | |
| download | olio-linux-3.10-293bf865f34e276119e34ad03bcd459e240ecd42.tar.xz olio-linux-3.10-293bf865f34e276119e34ad03bcd459e240ecd42.zip | |
IKXCLOCK-2594: Restore pedometer data after m4 panic
When m4 panics and resets, the total stepcount start from 0,
and if an app was registered for pedometer data it would start
seeing stepcount restart from 0 when this happens. This fix is to
avoid the app from seeing total steps go lower than the previously
reported total steps.
Change-Id: Ia1c803175e34e582fa132de7ca88e8762e335fe7
Diffstat (limited to 'drivers/misc/m4sensorhub_pedometer.c')
| -rw-r--r-- | drivers/misc/m4sensorhub_pedometer.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/misc/m4sensorhub_pedometer.c b/drivers/misc/m4sensorhub_pedometer.c index 4f80122c7e1..85c1c2f9c9e 100644 --- a/drivers/misc/m4sensorhub_pedometer.c +++ b/drivers/misc/m4sensorhub_pedometer.c @@ -47,6 +47,8 @@ struct m4ped_driver_data { struct m4sensorhub_pedometer_iio_data iiodat; int16_t samplerate; uint16_t status; + struct m4sensorhub_pedometer_iio_data base_dat; + }; static int m4ped_read_report_data(struct iio_dev *iio, @@ -143,6 +145,12 @@ static int m4ped_read_report_data(struct iio_dev *iio, } dd->iiodat.timestamp = iio_get_time_ns(); + + dd->iiodat.total_distance += dd->base_dat.total_distance; + dd->iiodat.total_steps += dd->base_dat.total_steps; + dd->iiodat.healthy_minutes += dd->base_dat.healthy_minutes; + dd->iiodat.calories += dd->base_dat.calories; + iio_push_to_buffers(iio, (unsigned char *)&(dd->iiodat)); m4ped_read_fail: @@ -530,6 +538,24 @@ m4ped_create_iiodev_exit: return err; } +static void m4ped_panic_restore(struct m4sensorhub_data *m4sensorhub, + void *data) +{ + struct m4ped_driver_data *dd = (struct m4ped_driver_data *)data; + if (dd == NULL) { + m4ped_err("%s: Driver data is null, unable to restore\n", + __func__); + return; + } + dd->base_dat.total_distance = dd->iiodat.total_distance; + dd->base_dat.total_steps = dd->iiodat.total_steps; + dd->base_dat.healthy_minutes = dd->iiodat.healthy_minutes; + dd->base_dat.calories = dd->iiodat.calories; + m4ped_err("%s: Pedometer bases after panic = %d %d %d %d", __func__, + dd->base_dat.total_distance, dd->base_dat.total_steps, + dd->base_dat.healthy_minutes, dd->base_dat.calories); +} + static int m4ped_driver_init(struct init_calldata *p_arg) { struct iio_dev *iio = p_arg->p_data; @@ -559,6 +585,11 @@ static int m4ped_driver_init(struct init_calldata *p_arg) goto m4ped_driver_init_irq_act_fail; } + err = m4sensorhub_panic_register(dd->m4, PANICHDL_PEDOMETER_RESTORE, + m4ped_panic_restore, dd); + if (err < 0) + m4ped_err("Pedometer panic callbk register failed\n"); + goto m4ped_driver_init_exit; m4ped_driver_init_irq_act_fail: |