diff options
author | Dawid Niedzwiecki <dn@semihalf.com> | 2020-10-07 12:13:52 +0200 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-10-27 09:35:49 +0000 |
commit | a05f7b9f469e7c171f4a737968ab5cbd11ba1253 (patch) | |
tree | ab128a89ce9206ca967ad104e307d6c0b4c33a52 /common/motion_sense.c | |
parent | 3cba51e9e807e7015d81c2891c47ea4c59587a1c (diff) | |
download | chrome-ec-a05f7b9f469e7c171f4a737968ab5cbd11ba1253.tar.gz |
tree: Use new atomic_* implementation
It is done as a part of porting to Zephyr.
Since the implementation of atomic functions is done for all architectures
use atomic_* instead of deprecated_atomic_*.
Sometimes there was a compilation error "discards 'volatile' qualifier"
due to dropping "volatile" in the argument of the functions, thus
some pointers casts need to be made. It shouldn't cause any issues,
because we are sure about generated asm (store operation will be
performed).
BUG=b:169151160
BRANCH=none
TEST=buildall
Signed-off-by: Dawid Niedzwiecki <dn@semihalf.com>
Change-Id: I98f590c323c3af52035e62825e8acfa358e0805a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2478949
Tested-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Jett Rink <jettrink@chromium.org>
Reviewed-by: Tom Hughes <tomhughes@chromium.org>
Diffstat (limited to 'common/motion_sense.c')
-rw-r--r-- | common/motion_sense.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index a283ce7346..6feed6738d 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -677,12 +677,11 @@ static int motion_sense_process(struct motion_sensor_t *sensor, if (*event & TASK_EVENT_MOTION_ODR_CHANGE) { const int sensor_bit = 1 << sensor_num; - int odr_pending = - deprecated_atomic_read_clear(&odr_event_required); + int odr_pending = atomic_read_clear(&odr_event_required); is_odr_pending = odr_pending & sensor_bit; odr_pending &= ~sensor_bit; - deprecated_atomic_or(&odr_event_required, odr_pending); + atomic_or(&odr_event_required, odr_pending); } #ifdef CONFIG_ACCEL_INTERRUPTS @@ -708,8 +707,7 @@ static int motion_sense_process(struct motion_sensor_t *sensor, } if (IS_ENABLED(CONFIG_ACCEL_FIFO) && *event & TASK_EVENT_MOTION_FLUSH_PENDING) { - int flush_pending = - deprecated_atomic_read_clear(&sensor->flush_pending); + int flush_pending = atomic_read_clear(&sensor->flush_pending); for (; flush_pending > 0; flush_pending--) { motion_sense_fifo_insert_async_event( @@ -1172,8 +1170,8 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args) * The new ODR may suspend sensor, leaving samples * in the FIFO. Flush it explicitly. */ - deprecated_atomic_or(&odr_event_required, - 1 << (sensor - motion_sensors)); + atomic_or(&odr_event_required, + 1 << (sensor - motion_sensors)); task_set_event(TASK_ID_MOTIONSENSE, TASK_EVENT_MOTION_ODR_CHANGE, 0); } @@ -1294,7 +1292,7 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args) if (sensor == NULL) return EC_RES_INVALID_PARAM; - deprecated_atomic_add(&sensor->flush_pending, 1); + atomic_add(&sensor->flush_pending, 1); task_set_event(TASK_ID_MOTIONSENSE, TASK_EVENT_MOTION_FLUSH_PENDING, 0); @@ -1645,8 +1643,7 @@ static int command_accel_data_rate(int argc, char **argv) sensor->config[config_id].odr = data | (round ? ROUND_UP_FLAG : 0); - deprecated_atomic_or(&odr_event_required, - 1 << (sensor - motion_sensors)); + atomic_or(&odr_event_required, 1 << (sensor - motion_sensors)); task_set_event(TASK_ID_MOTIONSENSE, TASK_EVENT_MOTION_ODR_CHANGE, 0); } else { |