From 1fb979f37cebc3ef5aecefe37637c652cc38eaaa Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Mon, 11 Dec 2023 22:03:52 +0200 Subject: [PATCH] uORB cleanup: change cb_triggered to simple boolean It is either set or not, there is no point in having a counter Signed-off-by: Jukka Laitinen --- platforms/common/uORB/uORBDeviceNode.cpp | 4 ++-- platforms/common/uORB/uORBDeviceNode.hpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/platforms/common/uORB/uORBDeviceNode.cpp b/platforms/common/uORB/uORBDeviceNode.cpp index cfb92a21c3b4..fea35e45522d 100644 --- a/platforms/common/uORB/uORBDeviceNode.cpp +++ b/platforms/common/uORB/uORBDeviceNode.cpp @@ -623,7 +623,7 @@ uORB::DeviceNode::write(const char *buffer, const orb_metadata *meta, orb_advert // Release poll waiters and callback threads if (Manager::isThreadAlive(item->lock)) { - __atomic_fetch_add(&item->cb_triggered, 1, __ATOMIC_SEQ_CST); + item->cb_triggered = true; Manager::unlockThread(item->lock); } else { @@ -889,7 +889,7 @@ uORB::DeviceNode::_register_callback(uORB::SubscriptionCallback *cb_sub, #ifdef CONFIG_BUILD_FLAT item->subscriber = cb_sub; #else - item->cb_triggered = 0; + item->cb_triggered = false; #endif item->last_update = last_update; item->interval_us = interval_us; diff --git a/platforms/common/uORB/uORBDeviceNode.hpp b/platforms/common/uORB/uORBDeviceNode.hpp index 2fc80a2f1bd8..997a512fcb3f 100644 --- a/platforms/common/uORB/uORBDeviceNode.hpp +++ b/platforms/common/uORB/uORBDeviceNode.hpp @@ -247,8 +247,8 @@ class DeviceNode #ifndef CONFIG_BUILD_FLAT int8_t ret = -1; - if (__atomic_load_n(&item->cb_triggered, __ATOMIC_SEQ_CST) > 0) { - __atomic_fetch_sub(&item->cb_triggered, 1, __ATOMIC_SEQ_CST); + if (item->cb_triggered) { + item->cb_triggered = false; ret = item->lock; } @@ -271,7 +271,7 @@ class DeviceNode #ifdef CONFIG_BUILD_FLAT class SubscriptionCallback *subscriber; #else - unsigned cb_triggered; + bool cb_triggered; #endif hrt_abstime last_update; uint32_t interval_us;