]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitfeda610600775a05d6b2059eaa5744a54181d093
tree8bd830b1f2ff603887b0fa4a27a7930cd8c11f17
parent5e9ba36fb426b1820c81a93145de8a6373633cff
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