Skip to contentSkip to conversation

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

PATCH Applied Andy Shevchenko 2 participants 5 messages Dec 28, 2022 – Jan 10, 2023 LED

v1 of 2 Applied Latest is v2 →

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")

---

v2: added tag (Vincent), Cc'ed to Lee

 drivers/leds/leds-is31fl319x.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/leds/leds-is31fl319x.c +6 -1
index b2f4c4ec7c56..7c908414ac7e 100644
@@ -495,6 +495,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;
@@ -511,7 +516,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
#1 lore raw
Quoted 7 lines · Andy Shevchenko

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.
Quoted 8 lines

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.

This should be read as v2 actually (but code wise the v1 and v2 has no difference).

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer Applied
#2 lore raw
In reply to Andy Shevchenko
Quoted 7 lines · Andy Shevchenko

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.
Quoted 5 lines

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

I fixed-up the wording above a little.

Quoted 7 lines

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")
Quoted 6 lines

---

v2: added tag (Vincent), Cc'ed to Lee

 drivers/leds/leds-is31fl319x.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Applied, thanks

Signature · 1 line
Lee Jones [李琼斯]
#3 lore raw
Quoted 1 line · Lee Jones

On Wed, 28 Dec 2022, Andy Shevchenko wrote:

...

Quoted 1 line

Applied, thanks

Thank you and HNY!

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#4 lore raw
Quoted 8 lines · Andy Shevchenko
Quoted 1 line · Lee Jones

On Wed, 28 Dec 2022, Andy Shevchenko wrote:

...

Quoted 1 line

Applied, thanks

Thank you and HNY!

HNYTYT!

Signature · 1 line
Lee Jones [李琼斯]