drivers/platform/x86/xiaomi-wmi.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
Use devm_mutex_init() instead of hand-writing it.
This saves some LoC, improves readability and saves some space in the
generated .o file.
Before:
======
text data bss dec hex filename
3520 1112 64 4696 1258 drivers/platform/x86/xiaomi-wmi.o
After:
=====
text data bss dec hex filename
3069 1040 64 4173 104d drivers/platform/x86/xiaomi-wmi.o
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/platform/x86/xiaomi-wmi.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/platform/x86/xiaomi-wmi.c b/drivers/platform/x86/xiaomi-wmi.c
index cbed29ca502a..b892007b9863 100644
--- a/drivers/platform/x86/xiaomi-wmi.c
+++ b/drivers/platform/x86/xiaomi-wmi.c
@@ -26,13 +26,6 @@ struct xiaomi_wmi {
unsigned int key_code;
};
-static void xiaomi_mutex_destroy(void *data)
-{
- struct mutex *lock = data;
-
- mutex_destroy(lock);
-}
-
static int xiaomi_wmi_probe(struct wmi_device *wdev, const void *context)
{
struct xiaomi_wmi *data;
@@ -46,8 +39,7 @@ static int xiaomi_wmi_probe(struct wmi_device *wdev, const void *context)
return -ENOMEM;
dev_set_drvdata(&wdev->dev, data);
- mutex_init(&data->key_lock);
- ret = devm_add_action_or_reset(&wdev->dev, xiaomi_mutex_destroy, &data->key_lock);
+ ret = devm_mutex_init(&wdev->dev, &data->key_lock);
if (ret < 0)
return ret;
--
2.51.0
On Sun, 07 Sep 2025 12:09:09 +0200, Christophe JAILLET wrote: > Use devm_mutex_init() instead of hand-writing it. > > This saves some LoC, improves readability and saves some space in the > generated .o file. > > Before: > ====== > text data bss dec hex filename > 3520 1112 64 4696 1258 drivers/platform/x86/xiaomi-wmi.o > > [...] Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while. The list of commits applied: [1/1] platform/x86: xiaomi-wmi: Use devm_mutex_init() commit: b5a5a16e37c004052e9181de5cff0638d44a4b9b -- i.
© 2016 - 2025 Red Hat, Inc.