OSDN Git Service

net: tlan: Replace in_irq() usage
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Tue, 27 Oct 2020 22:54:44 +0000 (23:54 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 31 Oct 2020 16:55:38 +0000 (09:55 -0700)
commitbeca92820dc4fd6f2413420c9828b586a1e77df5
tree8bd830b1f2ff603887b0fa4a27a7930cd8c11f17
parentdc5e8bfcd12eec8032be83b334896c103cdef1aa
net: tlan: Replace in_irq() usage

The driver uses in_irq() to determine if the tlan_priv::lock has to be
acquired in tlan_mii_read_reg() and tlan_mii_write_reg().

The interrupt handler acquires the lock outside of these functions so the
in_irq() check is meant to prevent a lock recursion deadlock. But this
check is incorrect when interrupt force threading is enabled because then
the handler runs in thread context and in_irq() correctly returns false.

The usage of in_*() in drivers is phased out and Linus clearly requested
that code which changes behaviour depending on context should either be
seperated or the context be conveyed in an argument passed by the caller,
which usually knows the context.

tlan_set_timer() has this conditional as well, but this function is only
invoked from task context or the timer callback itself. So it always has to
lock and the check can be removed.

tlan_mii_read_reg(), tlan_mii_write_reg() and tlan_phy_print() are invoked
from interrupt and other contexts.

Split out the actual function body into helper variants which are called
from interrupt context and make the original functions wrappers which
acquire tlan_priv::lock unconditionally.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Samuel Chessman <chessman@tux.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/ti/tlan.c