diff mbox series

[resent,v2,1/1] leds: is31fl319x: Wrap mutex_destroy() for devm_add_action_or_rest()

Message ID 20230103131553.34124-1-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [resent,v2,1/1] leds: is31fl319x: Wrap mutex_destroy() for devm_add_action_or_rest() | expand

Commit Message

Andy Shevchenko Jan. 3, 2023, 1:15 p.m. UTC
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.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: e1af5c815586 ("leds: is31fl319x: Fix devm vs. non-devm ordering")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Tested-by: Vincent Knecht <vincent.knecht@mailoo.org>
---

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

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

Comments

Lee Jones Jan. 19, 2023, 4:05 p.m. UTC | #1
On Tue, 03 Jan 2023, Andy Shevchenko wrote:

> 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.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Fixes: e1af5c815586 ("leds: is31fl319x: Fix devm vs. non-devm ordering")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Tested-by: Vincent Knecht <vincent.knecht@mailoo.org>
> ---
> 
> v2 resent: resent as v2
> v2: added tag (Vincent), Cc'ed to Lee                                                                            
> 
>  drivers/leds/leds-is31fl319x.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

Not sure what the differences were, but looks like I already applied v1.
Andy Shevchenko Jan. 19, 2023, 4:13 p.m. UTC | #2
On Thu, Jan 19, 2023 at 04:05:26PM +0000, Lee Jones wrote:
> On Tue, 03 Jan 2023, Andy Shevchenko wrote:

...

> > v2 resent: resent as v2
> > v2: added tag (Vincent), Cc'ed to Lee
> > 
> >  drivers/leds/leds-is31fl319x.c | 7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> Not sure what the differences were, but looks like I already applied v1.

Codewise there is none. Thank you!
diff mbox series

Patch

diff --git a/drivers/leds/leds-is31fl319x.c b/drivers/leds/leds-is31fl319x.c
index b2f4c4ec7c56..7c908414ac7e 100644
--- a/drivers/leds/leds-is31fl319x.c
+++ b/drivers/leds/leds-is31fl319x.c
@@ -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;