From mboxrd@z Thu Jan 1 00:00:00 1970 From: bjorn@mork.no (=?utf-8?Q?Bj=C3=B8rn_Mork?=) Date: Wed, 11 Mar 2015 16:09:25 +0100 Subject: confusing code....whats the point of this construct ? In-Reply-To: <55475.1426084817@turing-police.cc.vt.edu> (Valdis Kletnieks's message of "Wed, 11 Mar 2015 10:40:17 -0400") References: <20150311141744.GC23845@opentech.at> <55475.1426084817@turing-police.cc.vt.edu> Message-ID: <87twxr4llm.fsf@nemi.mork.no> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Valdis.Kletnieks at vt.edu writes: > On Wed, 11 Mar 2015 15:17:44 +0100, Nicholas Mc Guire said: > >> 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 ? > > Umm... a Signed-off-by: and formatting it as an actual patch? :) > > Seriously - you're right, it's ugly code that needs fixing... Huh? The condition needs to be re-evaluated every time the process wakes up. Evaluating it once and then reusing that result is not the same. Something elseis supposed to modify ar->htt.num_pending_tx, ar->state or ar->dev_flags while we are waiting. Bj?rn