Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1544352
| From | Chanwoo Choi <cw00.choi@samsung.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 05/14] power: supply: axp288_charger: use devm extcon / supply register |
| Date | 2016-12-19 09:10 +0100 |
| Message-ID | <sQ1bb-5bq-1@gated-at.bofh.it> (permalink) |
| References | <sPTGF-pT-3@gated-at.bofh.it> <sQ1bb-5bq-3@gated-at.bofh.it> <sPTGH-pT-45@gated-at.bofh.it> |
| Organization | Samsung Electronics |
Hi Hans,
For the extcon part, I sent the patch[1].
[1]https://git.kernel.org/cgit/linux/kernel/git/sre/linux-power-supply.git/commit/?h=for-next-next&id=3164eef74088d9603a16b97e574a4e0067da083a
Regards,
Chanwoo Choi
On 2016년 12월 19일 09:07, Hans de Goede wrote:
> Use devm_extcon_register_notifier and devm_power_supply_register
> instead of their non devm counterparts, this avoids the need to do
> manual cleanup and results in quite a nice code cleanup.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
> drivers/power/supply/axp288_charger.c | 71 ++++++++---------------------------
> 1 file changed, 15 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c
> index 76f7d29..e435b1e 100644
> --- a/drivers/power/supply/axp288_charger.c
> +++ b/drivers/power/supply/axp288_charger.c
> @@ -812,6 +812,7 @@ static int axp288_charger_probe(struct platform_device *pdev)
> {
> int ret, i, pirq;
> struct axp288_chrg_info *info;
> + struct device *dev = &pdev->dev;
> struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
> struct power_supply_config charger_cfg = {};
>
> @@ -833,33 +834,27 @@ static int axp288_charger_probe(struct platform_device *pdev)
> /* Register for extcon notification */
> INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker);
> info->cable.nb.notifier_call = axp288_charger_handle_cable_evt;
> - ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_SDP,
> - &info->cable.nb);
> + ret = devm_extcon_register_notifier(dev, info->cable.edev,
> + EXTCON_CHG_USB_SDP, &info->cable.nb);
> if (ret) {
> dev_err(&info->pdev->dev,
> "failed to register extcon notifier for SDP %d\n", ret);
> return ret;
> }
>
> - ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_CDP,
> - &info->cable.nb);
> + ret = devm_extcon_register_notifier(dev, info->cable.edev,
> + EXTCON_CHG_USB_CDP, &info->cable.nb);
> if (ret) {
> dev_err(&info->pdev->dev,
> "failed to register extcon notifier for CDP %d\n", ret);
> - extcon_unregister_notifier(info->cable.edev,
> - EXTCON_CHG_USB_SDP, &info->cable.nb);
> return ret;
> }
>
> - ret = extcon_register_notifier(info->cable.edev, EXTCON_CHG_USB_DCP,
> - &info->cable.nb);
> + ret = devm_extcon_register_notifier(dev, info->cable.edev,
> + EXTCON_CHG_USB_DCP, &info->cable.nb);
> if (ret) {
> dev_err(&info->pdev->dev,
> "failed to register extcon notifier for DCP %d\n", ret);
> - extcon_unregister_notifier(info->cable.edev,
> - EXTCON_CHG_USB_SDP, &info->cable.nb);
> - extcon_unregister_notifier(info->cable.edev,
> - EXTCON_CHG_USB_CDP, &info->cable.nb);
> return ret;
> }
>
> @@ -868,19 +863,18 @@ static int axp288_charger_probe(struct platform_device *pdev)
>
> /* Register with power supply class */
> charger_cfg.drv_data = info;
> - info->psy_usb = power_supply_register(&pdev->dev, &axp288_charger_desc,
> - &charger_cfg);
> + info->psy_usb = devm_power_supply_register(dev, &axp288_charger_desc,
> + &charger_cfg);
> if (IS_ERR(info->psy_usb)) {
> dev_err(&pdev->dev, "failed to register power supply charger\n");
> - ret = PTR_ERR(info->psy_usb);
> - goto psy_reg_failed;
> + return PTR_ERR(info->psy_usb);
> }
>
> /* Register for OTG notification */
> INIT_WORK(&info->otg.work, axp288_charger_otg_evt_worker);
> info->otg.id_nb.notifier_call = axp288_charger_handle_otg_evt;
> - ret = extcon_register_notifier(info->otg.cable, EXTCON_USB_HOST,
> - &info->otg.id_nb);
> + ret = devm_extcon_register_notifier(dev, info->otg.cable,
> + EXTCON_USB_HOST, &info->otg.id_nb);
> if (ret)
> dev_warn(&pdev->dev, "failed to register otg notifier\n");
>
> @@ -895,8 +889,7 @@ static int axp288_charger_probe(struct platform_device *pdev)
> if (info->irq[i] < 0) {
> dev_warn(&info->pdev->dev,
> "failed to get virtual interrupt=%d\n", pirq);
> - ret = info->irq[i];
> - goto intr_reg_failed;
> + return info->irq[i];
> }
> ret = devm_request_threaded_irq(&info->pdev->dev, info->irq[i],
> NULL, axp288_charger_irq_thread_handler,
> @@ -904,53 +897,19 @@ static int axp288_charger_probe(struct platform_device *pdev)
> if (ret) {
> dev_err(&pdev->dev, "failed to request interrupt=%d\n",
> info->irq[i]);
> - goto intr_reg_failed;
> + return ret;
> }
> }
>
> ret = charger_init_hw_regs(info);
> if (ret)
> - goto intr_reg_failed;
> -
> - return 0;
> -
> -intr_reg_failed:
> - if (info->otg.cable)
> - extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST,
> - &info->otg.id_nb);
> - power_supply_unregister(info->psy_usb);
> -psy_reg_failed:
> - extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_SDP,
> - &info->cable.nb);
> - extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_CDP,
> - &info->cable.nb);
> - extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_DCP,
> - &info->cable.nb);
> - return ret;
> -}
> -
> -static int axp288_charger_remove(struct platform_device *pdev)
> -{
> - struct axp288_chrg_info *info = dev_get_drvdata(&pdev->dev);
> -
> - if (info->otg.cable)
> - extcon_unregister_notifier(info->otg.cable, EXTCON_USB_HOST,
> - &info->otg.id_nb);
> -
> - extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_SDP,
> - &info->cable.nb);
> - extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_CDP,
> - &info->cable.nb);
> - extcon_unregister_notifier(info->cable.edev, EXTCON_CHG_USB_DCP,
> - &info->cable.nb);
> - power_supply_unregister(info->psy_usb);
> + return ret;
>
> return 0;
> }
>
> static struct platform_driver axp288_charger_driver = {
> .probe = axp288_charger_probe,
> - .remove = axp288_charger_remove,
> .driver = {
> .name = "axp288_charger",
> },
>
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/14] extcon api extension + axp288_charger fixes Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:10 +0100
[PATCH 12/14] power: supply: axp288_charger: Fix wrong regmap_update_bits Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:10 +0100
[PATCH 13/14] power: supply: axp288_charger: Remove unnecessary irq?_en register writes Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:10 +0100
[PATCH 08/14] power: supply: axp288_charger: Actually get and use the USB_HOST extcon device Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:10 +0100
Re: [PATCH 08/14] power: supply: axp288_charger: Actually get and use the USB_HOST extcon device Chanwoo Choi <cw00.choi@samsung.com> - 2016-12-19 11:20 +0100
[PATCH 14/14] power: supply: axp288_charger: Fix the module not auto-loading Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:10 +0100
[PATCH 09/14] power: supply: axp288_charger: Handle charger type changing without disconnect Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:10 +0100
[PATCH 11/14] power: supply: axp288_charger: Get and process initial hardware-state Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:10 +0100
[PATCH 01/14] extcon: Add extcon_get_extcon_dev_by_cable_id function Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:10 +0100
Re: [PATCH 01/14] extcon: Add extcon_get_extcon_dev_by_cable_id function Chanwoo Choi <cw00.choi@samsung.com> - 2016-12-19 11:20 +0100
Re: [PATCH 01/14] extcon: Add extcon_get_extcon_dev_by_cable_id function Hans de Goede <hdegoede@redhat.com> - 2016-12-19 12:50 +0100
Re: [PATCH 01/14] extcon: Add extcon_get_extcon_dev_by_cable_id function Chanwoo Choi <cw00.choi@samsung.com> - 2016-12-19 13:00 +0100
[PATCH 07/14] power: supply: axp288_charger: Move init_hw_regs call before supply registration Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:10 +0100
[PATCH 03/14] power: supply: axp288_charger: Make charger_init_hw_regs propagate i2c errors Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:10 +0100
[PATCH 05/14] power: supply: axp288_charger: use devm extcon / supply register Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:10 +0100
Re: [PATCH 05/14] power: supply: axp288_charger: use devm extcon / supply register Chanwoo Choi <cw00.choi@samsung.com> - 2016-12-19 09:10 +0100
Re: [PATCH 05/14] power: supply: axp288_charger: use devm extcon / supply register Hans de Goede <hdegoede@redhat.com> - 2016-12-19 09:50 +0100
[PATCH 04/14] power: supply: axp288_charger: Drop platform_data dependency Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:20 +0100
[PATCH 06/14] power: supply: axp288_charger: Register extcon notifers after power_supply Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:20 +0100
[PATCH 02/14] extcon: Make extcon_register_notifier use extcon_get_extcon_dev_by_cable_id Hans de Goede <hdegoede@redhat.com> - 2016-12-19 01:20 +0100
csiph-web