[PATCH] hwmon: (nzxt-smart2) Use devm_mutex_init()

Christophe JAILLET posted 1 patch 1 day, 5 hours ago
drivers/hwmon/nzxt-smart2.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
[PATCH] hwmon: (nzxt-smart2) Use devm_mutex_init()
Posted by Christophe JAILLET 1 day, 5 hours ago
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
  25878	  11329	    128	  37335	   91d7	drivers/hwmon/nzxt-smart2.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  25551	  11257	    128	  36936	   9048	drivers/hwmon/nzxt-smart2.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/hwmon/nzxt-smart2.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/hwmon/nzxt-smart2.c b/drivers/hwmon/nzxt-smart2.c
index c2d1173f42fe..58ef9fa0184b 100644
--- a/drivers/hwmon/nzxt-smart2.c
+++ b/drivers/hwmon/nzxt-smart2.c
@@ -721,11 +721,6 @@ static int __maybe_unused nzxt_smart2_hid_reset_resume(struct hid_device *hdev)
 	return init_device(drvdata, drvdata->update_interval);
 }
 
-static void mutex_fini(void *lock)
-{
-	mutex_destroy(lock);
-}
-
 static int nzxt_smart2_hid_probe(struct hid_device *hdev,
 				 const struct hid_device_id *id)
 {
@@ -741,8 +736,7 @@ static int nzxt_smart2_hid_probe(struct hid_device *hdev,
 
 	init_waitqueue_head(&drvdata->wq);
 
-	mutex_init(&drvdata->mutex);
-	ret = devm_add_action_or_reset(&hdev->dev, mutex_fini, &drvdata->mutex);
+	ret = devm_mutex_init(&hdev->dev, &drvdata->mutex);
 	if (ret)
 		return ret;
 
-- 
2.51.0
Re: [PATCH] hwmon: (nzxt-smart2) Use devm_mutex_init()
Posted by Guenter Roeck 1 day, 2 hours ago
On Sun, Sep 07, 2025 at 12:20:20PM +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
>   25878	  11329	    128	  37335	   91d7	drivers/hwmon/nzxt-smart2.o
> 
> After:
> =====
>    text	   data	    bss	    dec	    hex	filename
>   25551	  11257	    128	  36936	   9048	drivers/hwmon/nzxt-smart2.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Applied.

Guenter