Skip to content

Commit 66f7d2c

Browse files
committed
Merge branches 'ib-leds-mips-sound-6.10' and 'ib-leds-locking-6.10' into ibs-for-leds-merged
2 parents ab2ab9e + c382e2e commit 66f7d2c

File tree

9 files changed

+123
-74
lines changed

9 files changed

+123
-74
lines changed

drivers/leds/leds-an30259a.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,10 @@ static int an30259a_probe(struct i2c_client *client)
283283
if (err < 0)
284284
return err;
285285

286-
mutex_init(&chip->mutex);
286+
err = devm_mutex_init(&client->dev, &chip->mutex);
287+
if (err)
288+
return err;
289+
287290
chip->client = client;
288291
i2c_set_clientdata(client, chip);
289292

@@ -317,17 +320,9 @@ static int an30259a_probe(struct i2c_client *client)
317320
return 0;
318321

319322
exit:
320-
mutex_destroy(&chip->mutex);
321323
return err;
322324
}
323325

324-
static void an30259a_remove(struct i2c_client *client)
325-
{
326-
struct an30259a *chip = i2c_get_clientdata(client);
327-
328-
mutex_destroy(&chip->mutex);
329-
}
330-
331326
static const struct of_device_id an30259a_match_table[] = {
332327
{ .compatible = "panasonic,an30259a", },
333328
{ /* sentinel */ },
@@ -347,7 +342,6 @@ static struct i2c_driver an30259a_driver = {
347342
.of_match_table = an30259a_match_table,
348343
},
349344
.probe = an30259a_probe,
350-
.remove = an30259a_remove,
351345
.id_table = an30259a_id,
352346
};
353347

drivers/leds/leds-aw200xx.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,16 @@ static const struct regmap_config aw200xx_regmap_config = {
530530
.disable_locking = true,
531531
};
532532

533+
static void aw200xx_chip_reset_action(void *data)
534+
{
535+
aw200xx_chip_reset(data);
536+
}
537+
538+
static void aw200xx_disable_action(void *data)
539+
{
540+
aw200xx_disable(data);
541+
}
542+
533543
static int aw200xx_probe(struct i2c_client *client)
534544
{
535545
const struct aw200xx_chipdef *cdef;
@@ -568,11 +578,17 @@ static int aw200xx_probe(struct i2c_client *client)
568578

569579
aw200xx_enable(chip);
570580

581+
ret = devm_add_action(&client->dev, aw200xx_disable_action, chip);
582+
if (ret)
583+
return ret;
584+
571585
ret = aw200xx_chip_check(chip);
572586
if (ret)
573587
return ret;
574588

575-
mutex_init(&chip->mutex);
589+
ret = devm_mutex_init(&client->dev, &chip->mutex);
590+
if (ret)
591+
return ret;
576592

577593
/* Need a lock now since after call aw200xx_probe_fw, sysfs nodes created */
578594
mutex_lock(&chip->mutex);
@@ -581,6 +597,10 @@ static int aw200xx_probe(struct i2c_client *client)
581597
if (ret)
582598
goto out_unlock;
583599

600+
ret = devm_add_action(&client->dev, aw200xx_chip_reset_action, chip);
601+
if (ret)
602+
goto out_unlock;
603+
584604
ret = aw200xx_probe_fw(&client->dev, chip);
585605
if (ret)
586606
goto out_unlock;
@@ -595,15 +615,6 @@ static int aw200xx_probe(struct i2c_client *client)
595615
return ret;
596616
}
597617

598-
static void aw200xx_remove(struct i2c_client *client)
599-
{
600-
struct aw200xx *chip = i2c_get_clientdata(client);
601-
602-
aw200xx_chip_reset(chip);
603-
aw200xx_disable(chip);
604-
mutex_destroy(&chip->mutex);
605-
}
606-
607618
static const struct aw200xx_chipdef aw20036_cdef = {
608619
.channels = 36,
609620
.display_size_rows_max = 3,
@@ -652,7 +663,6 @@ static struct i2c_driver aw200xx_driver = {
652663
.of_match_table = aw200xx_match_table,
653664
},
654665
.probe = aw200xx_probe,
655-
.remove = aw200xx_remove,
656666
.id_table = aw200xx_id,
657667
};
658668
module_i2c_driver(aw200xx_driver);

drivers/leds/leds-aw2013.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,11 @@ static int aw2013_probe_dt(struct aw2013 *chip)
320320
return 0;
321321
}
322322

323+
static void aw2013_chip_disable_action(void *data)
324+
{
325+
aw2013_chip_disable(data);
326+
}
327+
323328
static const struct regmap_config aw2013_regmap_config = {
324329
.reg_bits = 8,
325330
.val_bits = 8,
@@ -336,7 +341,10 @@ static int aw2013_probe(struct i2c_client *client)
336341
if (!chip)
337342
return -ENOMEM;
338343

339-
mutex_init(&chip->mutex);
344+
ret = devm_mutex_init(&client->dev, &chip->mutex);
345+
if (ret)
346+
return ret;
347+
340348
mutex_lock(&chip->mutex);
341349

342350
chip->client = client;
@@ -384,6 +392,10 @@ static int aw2013_probe(struct i2c_client *client)
384392
goto error_reg;
385393
}
386394

395+
ret = devm_add_action(&client->dev, aw2013_chip_disable_action, chip);
396+
if (ret)
397+
goto error_reg;
398+
387399
ret = aw2013_probe_dt(chip);
388400
if (ret < 0)
389401
goto error_reg;
@@ -406,19 +418,9 @@ static int aw2013_probe(struct i2c_client *client)
406418

407419
error:
408420
mutex_unlock(&chip->mutex);
409-
mutex_destroy(&chip->mutex);
410421
return ret;
411422
}
412423

413-
static void aw2013_remove(struct i2c_client *client)
414-
{
415-
struct aw2013 *chip = i2c_get_clientdata(client);
416-
417-
aw2013_chip_disable(chip);
418-
419-
mutex_destroy(&chip->mutex);
420-
}
421-
422424
static const struct of_device_id aw2013_match_table[] = {
423425
{ .compatible = "awinic,aw2013", },
424426
{ /* sentinel */ },
@@ -432,7 +434,6 @@ static struct i2c_driver aw2013_driver = {
432434
.of_match_table = aw2013_match_table,
433435
},
434436
.probe = aw2013_probe,
435-
.remove = aw2013_remove,
436437
};
437438

438439
module_i2c_driver(aw2013_driver);

drivers/leds/leds-lm3532.c

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,13 @@ static int lm3532_parse_als(struct lm3532_data *priv)
542542
return ret;
543543
}
544544

545+
static void gpio_set_low_action(void *data)
546+
{
547+
struct lm3532_data *priv = data;
548+
549+
gpiod_direction_output(priv->enable_gpio, 0);
550+
}
551+
545552
static int lm3532_parse_node(struct lm3532_data *priv)
546553
{
547554
struct fwnode_handle *child = NULL;
@@ -556,6 +563,12 @@ static int lm3532_parse_node(struct lm3532_data *priv)
556563
if (IS_ERR(priv->enable_gpio))
557564
priv->enable_gpio = NULL;
558565

566+
if (priv->enable_gpio) {
567+
ret = devm_add_action(&priv->client->dev, gpio_set_low_action, priv);
568+
if (ret)
569+
return ret;
570+
}
571+
559572
priv->regulator = devm_regulator_get(&priv->client->dev, "vin");
560573
if (IS_ERR(priv->regulator))
561574
priv->regulator = NULL;
@@ -691,7 +704,10 @@ static int lm3532_probe(struct i2c_client *client)
691704
return ret;
692705
}
693706

694-
mutex_init(&drvdata->lock);
707+
ret = devm_mutex_init(&client->dev, &drvdata->lock);
708+
if (ret)
709+
return ret;
710+
695711
i2c_set_clientdata(client, drvdata);
696712

697713
ret = lm3532_parse_node(drvdata);
@@ -703,16 +719,6 @@ static int lm3532_probe(struct i2c_client *client)
703719
return ret;
704720
}
705721

706-
static void lm3532_remove(struct i2c_client *client)
707-
{
708-
struct lm3532_data *drvdata = i2c_get_clientdata(client);
709-
710-
mutex_destroy(&drvdata->lock);
711-
712-
if (drvdata->enable_gpio)
713-
gpiod_direction_output(drvdata->enable_gpio, 0);
714-
}
715-
716722
static const struct of_device_id of_lm3532_leds_match[] = {
717723
{ .compatible = "ti,lm3532", },
718724
{},
@@ -727,7 +733,6 @@ MODULE_DEVICE_TABLE(i2c, lm3532_id);
727733

728734
static struct i2c_driver lm3532_i2c_driver = {
729735
.probe = lm3532_probe,
730-
.remove = lm3532_remove,
731736
.id_table = lm3532_id,
732737
.driver = {
733738
.name = LM3532_NAME,

drivers/leds/leds-lp3952.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,13 @@ static const struct regmap_config lp3952_regmap = {
207207
.cache_type = REGCACHE_MAPLE,
208208
};
209209

210+
static void gpio_set_low_action(void *data)
211+
{
212+
struct lp3952_led_array *priv = data;
213+
214+
gpiod_set_value(priv->enable_gpio, 0);
215+
}
216+
210217
static int lp3952_probe(struct i2c_client *client)
211218
{
212219
int status;
@@ -226,6 +233,10 @@ static int lp3952_probe(struct i2c_client *client)
226233
return status;
227234
}
228235

236+
status = devm_add_action(&client->dev, gpio_set_low_action, priv);
237+
if (status)
238+
return status;
239+
229240
priv->regmap = devm_regmap_init_i2c(client, &lp3952_regmap);
230241
if (IS_ERR(priv->regmap)) {
231242
int err = PTR_ERR(priv->regmap);
@@ -254,15 +265,6 @@ static int lp3952_probe(struct i2c_client *client)
254265
return 0;
255266
}
256267

257-
static void lp3952_remove(struct i2c_client *client)
258-
{
259-
struct lp3952_led_array *priv;
260-
261-
priv = i2c_get_clientdata(client);
262-
lp3952_on_off(priv, LP3952_LED_ALL, false);
263-
gpiod_set_value(priv->enable_gpio, 0);
264-
}
265-
266268
static const struct i2c_device_id lp3952_id[] = {
267269
{LP3952_NAME, 0},
268270
{}
@@ -274,7 +276,6 @@ static struct i2c_driver lp3952_i2c_driver = {
274276
.name = LP3952_NAME,
275277
},
276278
.probe = lp3952_probe,
277-
.remove = lp3952_remove,
278279
.id_table = lp3952_id,
279280
};
280281

drivers/leds/leds-mlxreg.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ static int mlxreg_led_probe(struct platform_device *pdev)
256256
{
257257
struct mlxreg_core_platform_data *led_pdata;
258258
struct mlxreg_led_priv_data *priv;
259+
int err;
259260

260261
led_pdata = dev_get_platdata(&pdev->dev);
261262
if (!led_pdata) {
@@ -267,26 +268,21 @@ static int mlxreg_led_probe(struct platform_device *pdev)
267268
if (!priv)
268269
return -ENOMEM;
269270

270-
mutex_init(&priv->access_lock);
271+
err = devm_mutex_init(&pdev->dev, &priv->access_lock);
272+
if (err)
273+
return err;
274+
271275
priv->pdev = pdev;
272276
priv->pdata = led_pdata;
273277

274278
return mlxreg_led_config(priv);
275279
}
276280

277-
static void mlxreg_led_remove(struct platform_device *pdev)
278-
{
279-
struct mlxreg_led_priv_data *priv = dev_get_drvdata(&pdev->dev);
280-
281-
mutex_destroy(&priv->access_lock);
282-
}
283-
284281
static struct platform_driver mlxreg_led_driver = {
285282
.driver = {
286283
.name = "leds-mlxreg",
287284
},
288285
.probe = mlxreg_led_probe,
289-
.remove_new = mlxreg_led_remove,
290286
};
291287

292288
module_platform_driver(mlxreg_led_driver);

drivers/leds/leds-nic78bx.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ static struct nic78bx_led nic78bx_leds[] = {
118118
}
119119
};
120120

121+
static void lock_led_reg_action(void *data)
122+
{
123+
struct nic78bx_led_data *led_data = data;
124+
125+
/* Lock LED register */
126+
outb(NIC78BX_LOCK_VALUE,
127+
led_data->io_base + NIC78BX_LOCK_REG_OFFSET);
128+
}
129+
121130
static int nic78bx_probe(struct platform_device *pdev)
122131
{
123132
struct device *dev = &pdev->dev;
@@ -152,6 +161,10 @@ static int nic78bx_probe(struct platform_device *pdev)
152161
led_data->io_base = io_rc->start;
153162
spin_lock_init(&led_data->lock);
154163

164+
ret = devm_add_action(dev, lock_led_reg_action, led_data);
165+
if (ret)
166+
return ret;
167+
155168
for (i = 0; i < ARRAY_SIZE(nic78bx_leds); i++) {
156169
nic78bx_leds[i].data = led_data;
157170

@@ -167,15 +180,6 @@ static int nic78bx_probe(struct platform_device *pdev)
167180
return ret;
168181
}
169182

170-
static void nic78bx_remove(struct platform_device *pdev)
171-
{
172-
struct nic78bx_led_data *led_data = platform_get_drvdata(pdev);
173-
174-
/* Lock LED register */
175-
outb(NIC78BX_LOCK_VALUE,
176-
led_data->io_base + NIC78BX_LOCK_REG_OFFSET);
177-
}
178-
179183
static const struct acpi_device_id led_device_ids[] = {
180184
{"NIC78B3", 0},
181185
{"", 0},
@@ -184,7 +188,6 @@ MODULE_DEVICE_TABLE(acpi, led_device_ids);
184188

185189
static struct platform_driver led_driver = {
186190
.probe = nic78bx_probe,
187-
.remove_new = nic78bx_remove,
188191
.driver = {
189192
.name = KBUILD_MODNAME,
190193
.acpi_match_table = ACPI_PTR(led_device_ids),

0 commit comments

Comments
 (0)