From 99fd1f72139f33c118e651d3cb5f9ad22f424907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 24 Jul 2018 20:00:46 +0200 Subject: [PATCH] CDev::poll_notify_one: remove checking the semaphore counter The check is unnecessary. In the worst case the semaphore gets unlocked twice, but it's not an issue because the waiter is only interested in the first sem_post(), and the semaphore is then not used anymore. --- src/lib/drivers/device/CDev.cpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/lib/drivers/device/CDev.cpp b/src/lib/drivers/device/CDev.cpp index c3693b22b3..d71061b976 100644 --- a/src/lib/drivers/device/CDev.cpp +++ b/src/lib/drivers/device/CDev.cpp @@ -394,21 +394,12 @@ CDev::poll_notify_one(px4_pollfd_struct_t *fds, pollevent_t events) { DEVICE_DEBUG("CDev::poll_notify_one"); -#ifdef __PX4_NUTTX - int value = fds->sem->semcount; -#else - int value = -1; - px4_sem_getvalue(fds->sem, &value); -#endif - /* update the reported event set */ fds->revents |= fds->events & events; - DEVICE_DEBUG(" Events fds=%p %0x %0x %0x %d", fds, fds->revents, fds->events, events, value); + DEVICE_DEBUG(" Events fds=%p %0x %0x %0x", fds, fds->revents, fds->events, events); - /* if the state is now interesting, wake the waiter if it's still asleep */ - /* XXX semcount check here is a vile hack; counting semphores should not be abused as cvars */ - if ((fds->revents != 0) && (value <= 0)) { + if (fds->revents != 0) { px4_sem_post(fds->sem); } }