mutex_is_locked() was used to check the lock status. While it should not
be triggered unless a bug is introduced, it does not warn on lock being
held by another thread. Fix it with lockdep helpers.
Fixes: 186623f4aa72 ("net: dsa: yt921x: Add support for Motorcomm YT921x")
Signed-off-by: David Yang <mmyangfl@gmail.com>
---
drivers/net/dsa/yt921x.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/yt921x.c b/drivers/net/dsa/yt921x.c
index 159b16606f6c..44fcdd47ffb5 100644
--- a/drivers/net/dsa/yt921x.c
+++ b/drivers/net/dsa/yt921x.c
@@ -198,14 +198,14 @@ static u32 ethaddr_lo2_to_u32(const unsigned char *addr)
static int yt921x_reg_read(struct yt921x_priv *priv, u32 reg, u32 *valp)
{
- WARN_ON(!mutex_is_locked(&priv->reg_lock));
+ lockdep_assert_held_once(&priv->reg_lock);
return priv->reg_ops->read(priv->reg_ctx, reg, valp);
}
static int yt921x_reg_write(struct yt921x_priv *priv, u32 reg, u32 val)
{
- WARN_ON(!mutex_is_locked(&priv->reg_lock));
+ lockdep_assert_held_once(&priv->reg_lock);
return priv->reg_ops->write(priv->reg_ctx, reg, val);
}--
2.53.0