Skip to contentSkip to conversation

leds: is31fl319x: Wrap mutex_destroy() for devm_add_action_or_rest()

PATCH In review Andy Shevchenko 2 participants 3 messages Nov 4, 2022 – Nov 7, 2022 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: is31fl319x: Wrap mutex_destroy() for devm_add_action_or_rest()

Clang complains that devm_add_action() takes a parameter with a wrong type:

warning: cast from 'void (*)(struct mutex *)' to 'void (*)(void *)' converts to incompatible function type [-Wcast-function-type-strict]

    err = devm_add_action(dev, (void (*)(void *))mutex_destroy, &is31->lock);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 warning generated.

It appears that the commit e1af5c815586 ("leds: is31fl319x: Fix devm vs. non-devm ordering") missed two things:
- while mention devm_add_action_or_reset() the actual change got devm_add_action() call by unknown reason
- strictly speaking the parameter is not compatible by type

Fix both issues by switching to devm_add_action_or_reset() and adding a wrapper for mutex_destroy() call.

Fixes e1af5c815586 ("leds: is31fl319x: Fix devm vs. non-devm ordering")
---
 drivers/leds/leds-is31fl319x.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/leds/leds-is31fl319x.c +6 -1
index 52b59b62f437..6f94ad83e066 100644
@@ -494,6 +494,11 @@ static inline int is31fl3196_db_to_gain(u32 dezibel)
 	return dezibel / IS31FL3196_AUDIO_GAIN_DB_STEP;
 }
 
+static void is31f1319x_mutex_destroy(void *lock)
+{
+	mutex_destroy(lock);
+}
+
 static int is31fl319x_probe(struct i2c_client *client)
 {
 	struct is31fl319x_chip *is31;
@@ -510,7 +515,7 @@ static int is31fl319x_probe(struct i2c_client *client)
 		return -ENOMEM;
 
 	mutex_init(&is31->lock);
-	err = devm_add_action(dev, (void (*)(void *))mutex_destroy, &is31->lock);
+	err = devm_add_action_or_reset(dev, is31f1319x_mutex_destroy, &is31->lock);
 	if (err)
 		return err;
 
Signature · 1 line
2.35.1
Tested-by on v1 1/1
#1 lore raw

Le samedi 05 novembre 2022 à 01:59 +0200, Andy Shevchenko a écrit :

Quoted 42 lines

Clang complains that devm_add_action() takes a parameter with a wrong type:

warning: cast from 'void (*)(struct mutex *)' to 'void (*)(void *)' converts to incompatible function type [-Wcast- function-type-strict]
    err = devm_add_action(dev, (void (*)(void *))mutex_destroy, &is31->lock); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1 warning generated.

It appears that the commit e1af5c815586 ("leds: is31fl319x: Fix devm vs. non-devm ordering") missed two things:
- while mention devm_add_action_or_reset() the actual change got devm_add_action() call by unknown reason
- strictly speaking the parameter is not compatible by type

Fix both issues by switching to devm_add_action_or_reset() and adding a wrapper for mutex_destroy() call.

Fixes e1af5c815586 ("leds: is31fl319x: Fix devm vs. non-devm ordering")

---
 drivers/leds/leds-is31fl319x.c | 7 ++++++-

 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/leds/leds-is31fl319x.c +0 -0
index 52b59b62f437..6f94ad83e066 100644
@@ -494,6 +494,11 @@ static inline int is31fl3196_db_to_gain(u32 dezibel)
         return dezibel / IS31FL3196_AUDIO_GAIN_DB_STEP;
  }

drivers/leds/leds-is31fl319x.c +5 -0
+static void is31f1319x_mutex_destroy(void *lock)
+{
+       mutex_destroy(lock);
+}
+

 static int is31fl319x_probe(struct i2c_client *client) {
        struct is31fl319x_chip *is31;

drivers/leds/leds-is31fl319x.c +0 -0
@@ -510,7 +515,7 @@ static int is31fl319x_probe(struct i2c_client *client)
                 return -ENOMEM;
Quoted 7 lines


        mutex_init(&is31->lock);
-       err = devm_add_action(dev, (void (*)(void *))mutex_destroy, &is31->lock); +       err = devm_add_action_or_reset(dev, is31f1319x_mutex_destroy, &is31->lock); if (err)
                return err;

LED still works fine after applying this patch, also after rmmod'ing and modprobe'ing again. Please let me know if something else should be tested. Thank you !

#2 lore raw
Quoted 1 line · Vincent Knecht

Le samedi 05 novembre 2022 à 01:59 +0200, Andy Shevchenko a écrit :

...

Quoted 4 lines

LED still works fine after applying this patch, also after rmmod'ing and modprobe'ing again. Please let me know if something else should be tested. Thank you !

Thank you very much for testing, I believe it's comprehensive what you have done already.

Quoted 1 line
Signature · 2 lines
With Best Regards,
Andy Shevchenko