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

mfd: sec: Use devm_mfd_add_devices and devm_regmap_add_irq_chip

Use devm_mfd_add_devices() for adding MFD child devices and
devm_regmap_add_irq_chip() for IRQ chip registration.

This reduces the error code path and .remove callback for removing
MFD child devices and deleting IRQ chip data.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Laxman Dewangan and committed by
Lee Jones
3dc6f4aa b36c8272

+8 -26
+3 -17
drivers/mfd/sec-core.c
··· 481 481 /* If this happens the probe function is problem */ 482 482 BUG(); 483 483 } 484 - ret = mfd_add_devices(sec_pmic->dev, -1, sec_devs, num_sec_devs, NULL, 485 - 0, NULL); 484 + ret = devm_mfd_add_devices(sec_pmic->dev, -1, sec_devs, num_sec_devs, 485 + NULL, 0, NULL); 486 486 if (ret) 487 - goto err_mfd; 487 + return ret; 488 488 489 489 device_init_wakeup(sec_pmic->dev, sec_pmic->wakeup); 490 490 sec_pmic_configure(sec_pmic); 491 491 sec_pmic_dump_rev(sec_pmic); 492 492 493 493 return ret; 494 - 495 - err_mfd: 496 - sec_irq_exit(sec_pmic); 497 - return ret; 498 - } 499 - 500 - static int sec_pmic_remove(struct i2c_client *i2c) 501 - { 502 - struct sec_pmic_dev *sec_pmic = i2c_get_clientdata(i2c); 503 - 504 - mfd_remove_devices(sec_pmic->dev); 505 - sec_irq_exit(sec_pmic); 506 - return 0; 507 494 } 508 495 509 496 static void sec_pmic_shutdown(struct i2c_client *i2c) ··· 570 583 .of_match_table = of_match_ptr(sec_dt_match), 571 584 }, 572 585 .probe = sec_pmic_probe, 573 - .remove = sec_pmic_remove, 574 586 .shutdown = sec_pmic_shutdown, 575 587 .id_table = sec_pmic_id, 576 588 };
+5 -9
drivers/mfd/sec-irq.c
··· 483 483 return -EINVAL; 484 484 } 485 485 486 - ret = regmap_add_irq_chip(sec_pmic->regmap_pmic, sec_pmic->irq, 487 - IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 488 - sec_pmic->irq_base, sec_irq_chip, 489 - &sec_pmic->irq_data); 486 + ret = devm_regmap_add_irq_chip(sec_pmic->dev, sec_pmic->regmap_pmic, 487 + sec_pmic->irq, 488 + IRQF_TRIGGER_FALLING | IRQF_ONESHOT, 489 + sec_pmic->irq_base, sec_irq_chip, 490 + &sec_pmic->irq_data); 490 491 if (ret != 0) { 491 492 dev_err(sec_pmic->dev, "Failed to register IRQ chip: %d\n", ret); 492 493 return ret; ··· 500 499 BUILD_BUG_ON(((enum s2mps14_irq)S2MPS11_IRQ_RTCA0) != S2MPS14_IRQ_RTCA0); 501 500 502 501 return 0; 503 - } 504 - 505 - void sec_irq_exit(struct sec_pmic_dev *sec_pmic) 506 - { 507 - regmap_del_irq_chip(sec_pmic->irq, sec_pmic->irq_data); 508 502 }