[PATCH v2 28/33] HID: logitech-hidpp: use guard() for send_mutex
From: Dmitry Torokhov
Date: Wed Nov 11 2026 - 02:01:57 EST
Manual mutex_lock() and mutex_unlock() calls force early loop exits to
break to a shared unlock path instead of returning directly. Convert
hidpp_send_message_sync() to use guard(mutex) so lock release is bound
to the function scope and busy-retry exits can return immediately.
Tested-by: Gideon Heinz <gideonheinz02@xxxxxxxxx>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/hid/hid-logitech-hidpp.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 181b791b3e0c..8f2a9d3e0f74 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -380,19 +380,17 @@ static int hidpp_send_message_sync(struct hidpp_device *hidpp,
int ret;
int max_retries = 3;
- mutex_lock(&hidpp->send_mutex);
+ guard(mutex)(&hidpp->send_mutex);
do {
ret = __do_hidpp_send_message_sync(hidpp, message, response);
if (ret != -EBUSY)
- break;
+ return ret;
dbg_hid("%s:got busy hidpp error, retrying\n", __func__);
} while (--max_retries);
- mutex_unlock(&hidpp->send_mutex);
return ret;
-
}
/*
--
2.56.0.542.g3ef89b7020-goog