power: supply: Use devm_mutex_init()

Use devm_mutex_init() instead of hand-writing it.

This saves some LoC, improves readability and saves some space in the
generated .o file.

As an example:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  35803	   9352	    384	  45539	   b1e3	drivers/power/supply/rt9467-charger.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  34792	   9008	    384	  44184	   ac98	drivers/power/supply/rt9467-charger.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
Christophe JAILLET
2025-09-08 21:35:28 +02:00
committed by Sebastian Reichel
parent 3ec6002108
commit 7d715345a8
3 changed files with 5 additions and 50 deletions

View File

@@ -2224,13 +2224,6 @@ static void bq27xxx_external_power_changed(struct power_supply *psy)
mod_delayed_work(system_wq, &di->work, HZ / 2);
}
static void bq27xxx_battery_mutex_destroy(void *data)
{
struct mutex *lock = data;
mutex_destroy(lock);
}
int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
{
struct power_supply_desc *psy_desc;
@@ -2242,9 +2235,7 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
int ret;
INIT_DELAYED_WORK(&di->work, bq27xxx_battery_poll);
mutex_init(&di->lock);
ret = devm_add_action_or_reset(di->dev, bq27xxx_battery_mutex_destroy,
&di->lock);
ret = devm_mutex_init(di->dev, &di->lock);
if (ret)
return ret;

View File

@@ -761,13 +761,6 @@ static int mt6370_chg_init_psy(struct mt6370_priv *priv)
return PTR_ERR_OR_ZERO(priv->psy);
}
static void mt6370_chg_destroy_attach_lock(void *data)
{
struct mutex *attach_lock = data;
mutex_destroy(attach_lock);
}
static void mt6370_chg_destroy_wq(void *data)
{
struct workqueue_struct *wq = data;
@@ -894,9 +887,7 @@ static int mt6370_chg_probe(struct platform_device *pdev)
if (ret)
return dev_err_probe(dev, ret, "Failed to init psy\n");
mutex_init(&priv->attach_lock);
ret = devm_add_action_or_reset(dev, mt6370_chg_destroy_attach_lock,
&priv->attach_lock);
ret = devm_mutex_init(dev, &priv->attach_lock);
if (ret)
return ret;

View File

@@ -1147,27 +1147,6 @@ static int rt9467_reset_chip(struct rt9467_chg_data *data)
return regmap_field_write(data->rm_field[F_RST], 1);
}
static void rt9467_chg_destroy_adc_lock(void *data)
{
struct mutex *adc_lock = data;
mutex_destroy(adc_lock);
}
static void rt9467_chg_destroy_attach_lock(void *data)
{
struct mutex *attach_lock = data;
mutex_destroy(attach_lock);
}
static void rt9467_chg_destroy_ichg_ieoc_lock(void *data)
{
struct mutex *ichg_ieoc_lock = data;
mutex_destroy(ichg_ieoc_lock);
}
static void rt9467_chg_complete_aicl_done(void *data)
{
struct completion *aicl_done = data;
@@ -1220,21 +1199,15 @@ static int rt9467_charger_probe(struct i2c_client *i2c)
if (ret)
return dev_err_probe(dev, ret, "Failed to add irq chip\n");
mutex_init(&data->adc_lock);
ret = devm_add_action_or_reset(dev, rt9467_chg_destroy_adc_lock,
&data->adc_lock);
ret = devm_mutex_init(dev, &data->adc_lock);
if (ret)
return ret;
mutex_init(&data->attach_lock);
ret = devm_add_action_or_reset(dev, rt9467_chg_destroy_attach_lock,
&data->attach_lock);
ret = devm_mutex_init(dev, &data->attach_lock);
if (ret)
return ret;
mutex_init(&data->ichg_ieoc_lock);
ret = devm_add_action_or_reset(dev, rt9467_chg_destroy_ichg_ieoc_lock,
&data->ichg_ieoc_lock);
ret = devm_mutex_init(dev, &data->ichg_ieoc_lock);
if (ret)
return ret;