Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branches 'ib-leds-mips-sound-6.10' and 'ib-leds-locking-6.10' into ibs-for-leds-merged

+123 -74
+4 -10
drivers/leds/leds-an30259a.c
··· 283 283 if (err < 0) 284 284 return err; 285 285 286 - mutex_init(&chip->mutex); 286 + err = devm_mutex_init(&client->dev, &chip->mutex); 287 + if (err) 288 + return err; 289 + 287 290 chip->client = client; 288 291 i2c_set_clientdata(client, chip); 289 292 ··· 320 317 return 0; 321 318 322 319 exit: 323 - mutex_destroy(&chip->mutex); 324 320 return err; 325 - } 326 - 327 - static void an30259a_remove(struct i2c_client *client) 328 - { 329 - struct an30259a *chip = i2c_get_clientdata(client); 330 - 331 - mutex_destroy(&chip->mutex); 332 321 } 333 322 334 323 static const struct of_device_id an30259a_match_table[] = { ··· 342 347 .of_match_table = an30259a_match_table, 343 348 }, 344 349 .probe = an30259a_probe, 345 - .remove = an30259a_remove, 346 350 .id_table = an30259a_id, 347 351 }; 348 352
+21 -11
drivers/leds/leds-aw200xx.c
··· 530 530 .disable_locking = true, 531 531 }; 532 532 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 + 533 543 static int aw200xx_probe(struct i2c_client *client) 534 544 { 535 545 const struct aw200xx_chipdef *cdef; ··· 578 568 579 569 aw200xx_enable(chip); 580 570 571 + ret = devm_add_action(&client->dev, aw200xx_disable_action, chip); 572 + if (ret) 573 + return ret; 574 + 581 575 ret = aw200xx_chip_check(chip); 582 576 if (ret) 583 577 return ret; 584 578 585 - mutex_init(&chip->mutex); 579 + ret = devm_mutex_init(&client->dev, &chip->mutex); 580 + if (ret) 581 + return ret; 586 582 587 583 /* Need a lock now since after call aw200xx_probe_fw, sysfs nodes created */ 588 584 mutex_lock(&chip->mutex); 589 585 590 586 ret = aw200xx_chip_reset(chip); 587 + if (ret) 588 + goto out_unlock; 589 + 590 + ret = devm_add_action(&client->dev, aw200xx_chip_reset_action, chip); 591 591 if (ret) 592 592 goto out_unlock; 593 593 ··· 613 593 614 594 mutex_unlock(&chip->mutex); 615 595 return ret; 616 - } 617 - 618 - static void aw200xx_remove(struct i2c_client *client) 619 - { 620 - struct aw200xx *chip = i2c_get_clientdata(client); 621 - 622 - aw200xx_chip_reset(chip); 623 - aw200xx_disable(chip); 624 - mutex_destroy(&chip->mutex); 625 596 } 626 597 627 598 static const struct aw200xx_chipdef aw20036_cdef = { ··· 663 652 .of_match_table = aw200xx_match_table, 664 653 }, 665 654 .probe = aw200xx_probe, 666 - .remove = aw200xx_remove, 667 655 .id_table = aw200xx_id, 668 656 }; 669 657 module_i2c_driver(aw200xx_driver);
+13 -12
drivers/leds/leds-aw2013.c
··· 320 320 return 0; 321 321 } 322 322 323 + static void aw2013_chip_disable_action(void *data) 324 + { 325 + aw2013_chip_disable(data); 326 + } 327 + 323 328 static const struct regmap_config aw2013_regmap_config = { 324 329 .reg_bits = 8, 325 330 .val_bits = 8, ··· 341 336 if (!chip) 342 337 return -ENOMEM; 343 338 344 - mutex_init(&chip->mutex); 339 + ret = devm_mutex_init(&client->dev, &chip->mutex); 340 + if (ret) 341 + return ret; 342 + 345 343 mutex_lock(&chip->mutex); 346 344 347 345 chip->client = client; ··· 392 384 goto error_reg; 393 385 } 394 386 387 + ret = devm_add_action(&client->dev, aw2013_chip_disable_action, chip); 388 + if (ret) 389 + goto error_reg; 390 + 395 391 ret = aw2013_probe_dt(chip); 396 392 if (ret < 0) 397 393 goto error_reg; ··· 418 406 419 407 error: 420 408 mutex_unlock(&chip->mutex); 421 - mutex_destroy(&chip->mutex); 422 409 return ret; 423 - } 424 - 425 - static void aw2013_remove(struct i2c_client *client) 426 - { 427 - struct aw2013 *chip = i2c_get_clientdata(client); 428 - 429 - aw2013_chip_disable(chip); 430 - 431 - mutex_destroy(&chip->mutex); 432 410 } 433 411 434 412 static const struct of_device_id aw2013_match_table[] = { ··· 434 432 .of_match_table = aw2013_match_table, 435 433 }, 436 434 .probe = aw2013_probe, 437 - .remove = aw2013_remove, 438 435 }; 439 436 440 437 module_i2c_driver(aw2013_driver);
+17 -12
drivers/leds/leds-lm3532.c
··· 542 542 return ret; 543 543 } 544 544 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 + 545 552 static int lm3532_parse_node(struct lm3532_data *priv) 546 553 { 547 554 struct fwnode_handle *child = NULL; ··· 562 555 "enable", GPIOD_OUT_LOW); 563 556 if (IS_ERR(priv->enable_gpio)) 564 557 priv->enable_gpio = NULL; 558 + 559 + if (priv->enable_gpio) { 560 + ret = devm_add_action(&priv->client->dev, gpio_set_low_action, priv); 561 + if (ret) 562 + return ret; 563 + } 565 564 566 565 priv->regulator = devm_regulator_get(&priv->client->dev, "vin"); 567 566 if (IS_ERR(priv->regulator)) ··· 704 691 return ret; 705 692 } 706 693 707 - mutex_init(&drvdata->lock); 694 + ret = devm_mutex_init(&client->dev, &drvdata->lock); 695 + if (ret) 696 + return ret; 697 + 708 698 i2c_set_clientdata(client, drvdata); 709 699 710 700 ret = lm3532_parse_node(drvdata); ··· 717 701 } 718 702 719 703 return ret; 720 - } 721 - 722 - static void lm3532_remove(struct i2c_client *client) 723 - { 724 - struct lm3532_data *drvdata = i2c_get_clientdata(client); 725 - 726 - mutex_destroy(&drvdata->lock); 727 - 728 - if (drvdata->enable_gpio) 729 - gpiod_direction_output(drvdata->enable_gpio, 0); 730 704 } 731 705 732 706 static const struct of_device_id of_lm3532_leds_match[] = { ··· 733 727 734 728 static struct i2c_driver lm3532_i2c_driver = { 735 729 .probe = lm3532_probe, 736 - .remove = lm3532_remove, 737 730 .id_table = lm3532_id, 738 731 .driver = { 739 732 .name = LM3532_NAME,
+11 -10
drivers/leds/leds-lp3952.c
··· 207 207 .cache_type = REGCACHE_MAPLE, 208 208 }; 209 209 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 + 210 217 static int lp3952_probe(struct i2c_client *client) 211 218 { 212 219 int status; ··· 232 225 dev_err(&client->dev, "Failed to enable gpio: %d\n", status); 233 226 return status; 234 227 } 228 + 229 + status = devm_add_action(&client->dev, gpio_set_low_action, priv); 230 + if (status) 231 + return status; 235 232 236 233 priv->regmap = devm_regmap_init_i2c(client, &lp3952_regmap); 237 234 if (IS_ERR(priv->regmap)) { ··· 265 254 return 0; 266 255 } 267 256 268 - static void lp3952_remove(struct i2c_client *client) 269 - { 270 - struct lp3952_led_array *priv; 271 - 272 - priv = i2c_get_clientdata(client); 273 - lp3952_on_off(priv, LP3952_LED_ALL, false); 274 - gpiod_set_value(priv->enable_gpio, 0); 275 - } 276 - 277 257 static const struct i2c_device_id lp3952_id[] = { 278 258 {LP3952_NAME, 0}, 279 259 {} ··· 276 274 .name = LP3952_NAME, 277 275 }, 278 276 .probe = lp3952_probe, 279 - .remove = lp3952_remove, 280 277 .id_table = lp3952_id, 281 278 }; 282 279
+5 -9
drivers/leds/leds-mlxreg.c
··· 256 256 { 257 257 struct mlxreg_core_platform_data *led_pdata; 258 258 struct mlxreg_led_priv_data *priv; 259 + int err; 259 260 260 261 led_pdata = dev_get_platdata(&pdev->dev); 261 262 if (!led_pdata) { ··· 268 267 if (!priv) 269 268 return -ENOMEM; 270 269 271 - mutex_init(&priv->access_lock); 270 + err = devm_mutex_init(&pdev->dev, &priv->access_lock); 271 + if (err) 272 + return err; 273 + 272 274 priv->pdev = pdev; 273 275 priv->pdata = led_pdata; 274 276 275 277 return mlxreg_led_config(priv); 276 - } 277 - 278 - static void mlxreg_led_remove(struct platform_device *pdev) 279 - { 280 - struct mlxreg_led_priv_data *priv = dev_get_drvdata(&pdev->dev); 281 - 282 - mutex_destroy(&priv->access_lock); 283 278 } 284 279 285 280 static struct platform_driver mlxreg_led_driver = { ··· 283 286 .name = "leds-mlxreg", 284 287 }, 285 288 .probe = mlxreg_led_probe, 286 - .remove_new = mlxreg_led_remove, 287 289 }; 288 290 289 291 module_platform_driver(mlxreg_led_driver);
+13 -10
drivers/leds/leds-nic78bx.c
··· 118 118 } 119 119 }; 120 120 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 + 121 130 static int nic78bx_probe(struct platform_device *pdev) 122 131 { 123 132 struct device *dev = &pdev->dev; ··· 161 152 led_data->io_base = io_rc->start; 162 153 spin_lock_init(&led_data->lock); 163 154 155 + ret = devm_add_action(dev, lock_led_reg_action, led_data); 156 + if (ret) 157 + return ret; 158 + 164 159 for (i = 0; i < ARRAY_SIZE(nic78bx_leds); i++) { 165 160 nic78bx_leds[i].data = led_data; 166 161 ··· 180 167 return ret; 181 168 } 182 169 183 - static void nic78bx_remove(struct platform_device *pdev) 184 - { 185 - struct nic78bx_led_data *led_data = platform_get_drvdata(pdev); 186 - 187 - /* Lock LED register */ 188 - outb(NIC78BX_LOCK_VALUE, 189 - led_data->io_base + NIC78BX_LOCK_REG_OFFSET); 190 - } 191 - 192 170 static const struct acpi_device_id led_device_ids[] = { 193 171 {"NIC78B3", 0}, 194 172 {"", 0}, ··· 188 184 189 185 static struct platform_driver led_driver = { 190 186 .probe = nic78bx_probe, 191 - .remove_new = nic78bx_remove, 192 187 .driver = { 193 188 .name = KBUILD_MODNAME, 194 189 .acpi_match_table = ACPI_PTR(led_device_ids),
+27
include/linux/mutex.h
··· 22 22 #include <linux/cleanup.h> 23 23 #include <linux/mutex_types.h> 24 24 25 + struct device; 26 + 25 27 #ifdef CONFIG_DEBUG_LOCK_ALLOC 26 28 # define __DEP_MAP_MUTEX_INITIALIZER(lockname) \ 27 29 , .dep_map = { \ ··· 118 116 __mutex_init((mutex), #mutex, &__key); \ 119 117 } while (0) 120 118 #endif /* CONFIG_PREEMPT_RT */ 119 + 120 + #ifdef CONFIG_DEBUG_MUTEXES 121 + 122 + int __devm_mutex_init(struct device *dev, struct mutex *lock); 123 + 124 + #else 125 + 126 + static inline int __devm_mutex_init(struct device *dev, struct mutex *lock) 127 + { 128 + /* 129 + * When CONFIG_DEBUG_MUTEXES is off mutex_destroy() is just a nop so 130 + * no really need to register it in the devm subsystem. 131 + */ 132 + return 0; 133 + } 134 + 135 + #endif 136 + 137 + #define devm_mutex_init(dev, mutex) \ 138 + ({ \ 139 + typeof(mutex) mutex_ = (mutex); \ 140 + \ 141 + mutex_init(mutex_); \ 142 + __devm_mutex_init(dev, mutex_); \ 143 + }) 121 144 122 145 /* 123 146 * See kernel/locking/mutex.c for detailed documentation of these APIs.
+12
kernel/locking/mutex-debug.c
··· 12 12 */ 13 13 #include <linux/mutex.h> 14 14 #include <linux/delay.h> 15 + #include <linux/device.h> 15 16 #include <linux/export.h> 16 17 #include <linux/poison.h> 17 18 #include <linux/sched.h> ··· 89 88 #endif 90 89 lock->magic = lock; 91 90 } 91 + 92 + static void devm_mutex_release(void *res) 93 + { 94 + mutex_destroy(res); 95 + } 96 + 97 + int __devm_mutex_init(struct device *dev, struct mutex *lock) 98 + { 99 + return devm_add_action_or_reset(dev, devm_mutex_release, lock); 100 + } 101 + EXPORT_SYMBOL_GPL(__devm_mutex_init); 92 102 93 103 /*** 94 104 * mutex_destroy - mark a mutex unusable