From b57006e567081f8c9e4e24033831c8ea7c40c578 Mon Sep 17 00:00:00 2001 From: wangjianyu3 Date: Wed, 25 Dec 2024 12:18:44 +0800 Subject: [PATCH] drivers/sensors/gnss: Fix deactivate failure when using both topic and device Deactivate lower driver fails when both uORB topic and driver device are subscribed and opened. Signed-off-by: wangjianyu3 --- drivers/sensors/gnss_uorb.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/sensors/gnss_uorb.c b/drivers/sensors/gnss_uorb.c index 2353b786fcdcd..63164a50e90bc 100644 --- a/drivers/sensors/gnss_uorb.c +++ b/drivers/sensors/gnss_uorb.c @@ -171,10 +171,11 @@ static int gnss_activate(FAR struct sensor_lowerhalf_s *lower, if ((upper->crefs == 0 && enable) || (upper->crefs == 1 && !enable)) { ret = upper->lower->ops->activate(upper->lower, filep, enable); - if (ret >= 0) - { - upper->crefs += enable ? 1 : -1; - } + } + + if (ret >= 0) + { + upper->crefs += enable ? 1 : -1; } nxmutex_unlock(&upper->lock);