From mboxrd@z Thu Jan 1 00:00:00 1970 From: der.herr@hofr.at (Nicholas Mc Guire) Date: Wed, 11 Mar 2015 15:17:44 +0100 Subject: confusing code....whats the point of this construct ? Message-ID: <20150311141744.GC23845@opentech.at> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org HI ! Trying to understand the intent of this code construct drivers/net/wireless/ath/ath10k/mac.c:ath10k_flush() ret = wait_event_timeout(ar->htt.empty_tx_wq, ({ bool empty; spin_lock_bh(&ar->htt.tx_lock); empty = (ar->htt.num_pending_tx == 0); spin_unlock_bh(&ar->htt.tx_lock); skip = (ar->state == ATH10K_STATE_WEDGED) || test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags); (empty || skip); }), ATH10K_FLUSH_TIMEOUT_HZ); FYI include/linux/wait.h:wait_event_timeout() * wait_event_timeout - sleep until a condition gets true or a timeout elapses * @wq: the waitqueue to wait on * @condition: a C expression for the event to wait for * @timeout: timeout, in jiffies So the wait_event_timeout condition here ends up being (empty || skip) but what is the point of puting this code into the parameter list of wait_event_timeout() ? Would it not be equivalent to: bool empty; ... spin_lock_bh(&ar->htt.tx_lock); empty = (ar->htt.num_pending_tx == 0); spin_unlock_bh(&ar->htt.tx_lock); skip = (ar->state == ATH10K_STATE_WEDGED) || test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags); ret = wait_event_timeout(ar->htt.empty_tx_wq, (empty || skip), ATH10K_FLUSH_TIMEOUT_HZ); What am I missing here ? thx! hofrat