kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* confusing code....whats the point of this construct ?
@ 2015-03-11 14:17 Nicholas Mc Guire
  2015-03-11 14:40 ` Valdis.Kletnieks at vt.edu
  0 siblings, 1 reply; 13+ messages in thread
From: Nicholas Mc Guire @ 2015-03-11 14:17 UTC (permalink / raw)
  To: kernelnewbies


HI !

 Trying to understand the intent of this code construct

drivers/net/wireless/ath/ath10k/mac.c:ath10k_flush()
<snip>
        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);
<snip>

FYI include/linux/wait.h:wait_event_timeout()
<snip>
 * 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
<snip>

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

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-03-11 19:41 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-11 14:17 confusing code....whats the point of this construct ? Nicholas Mc Guire
2015-03-11 14:40 ` Valdis.Kletnieks at vt.edu
2015-03-11 14:50   ` Nicholas Mc Guire
2015-03-11 15:09   ` Bjørn Mork
2015-03-11 16:46     ` Nicholas Mc Guire
2015-03-11 17:00       ` Valdis.Kletnieks at vt.edu
2015-03-11 18:37         ` Jeff Haran
2015-03-11 18:47           ` Nicholas Krause
2015-03-11 18:53           ` Nicholas Mc Guire
2015-03-11 18:57           ` Valdis.Kletnieks at vt.edu
2015-03-11 19:16             ` Jeff Haran
2015-03-11 19:41             ` Bjørn Mork
2015-03-11 15:09   ` Malte Vesper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).