From: Chanwoo Choi <cw00.choi@samsung.com>
To: Hans de Goede <hdegoede@redhat.com>,
Sebastian Reichel <sre@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
MyungJoo Ham <myungjoo.ham@samsung.com>
Cc: "russianneuromancer @ ya . ru" <russianneuromancer@ya.ru>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 05/14] power: supply: axp288_charger: use devm extcon / supply register
Date: Mon, 19 Dec 2016 17:03:04 +0900 [thread overview]
Message-ID: <58579438.3050205@samsung.com> (raw)
In-Reply-To: <20161219000731.10188-6-hdegoede@redhat.com>
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",
> },
>
next prev parent reply other threads:[~2016-12-19 8:03 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-19 0:07 [PATCH 00/14] extcon api extension + axp288_charger fixes Hans de Goede
2016-12-19 0:07 ` [PATCH 01/14] extcon: Add extcon_get_extcon_dev_by_cable_id function Hans de Goede
2016-12-19 10:12 ` Chanwoo Choi
2016-12-19 11:42 ` Hans de Goede
2016-12-19 11:57 ` Chanwoo Choi
2016-12-19 0:07 ` [PATCH 02/14] extcon: Make extcon_register_notifier use extcon_get_extcon_dev_by_cable_id Hans de Goede
2016-12-19 0:07 ` [PATCH 03/14] power: supply: axp288_charger: Make charger_init_hw_regs propagate i2c errors Hans de Goede
2016-12-19 0:07 ` [PATCH 04/14] power: supply: axp288_charger: Drop platform_data dependency Hans de Goede
2016-12-19 0:07 ` [PATCH 05/14] power: supply: axp288_charger: use devm extcon / supply register Hans de Goede
2016-12-19 8:03 ` Chanwoo Choi [this message]
2016-12-19 8:42 ` Hans de Goede
2016-12-19 0:07 ` [PATCH 06/14] power: supply: axp288_charger: Register extcon notifers after power_supply Hans de Goede
2016-12-19 0:07 ` [PATCH 07/14] power: supply: axp288_charger: Move init_hw_regs call before supply registration Hans de Goede
2016-12-19 0:07 ` [PATCH 08/14] power: supply: axp288_charger: Actually get and use the USB_HOST extcon device Hans de Goede
2016-12-19 10:16 ` Chanwoo Choi
2016-12-19 0:07 ` [PATCH 09/14] power: supply: axp288_charger: Handle charger type changing without disconnect Hans de Goede
2016-12-19 0:07 ` [PATCH 10/14] power: supply: axp288_charger: Some minor cleanups Hans de Goede
2016-12-19 0:07 ` [PATCH 11/14] power: supply: axp288_charger: Get and process initial hardware-state Hans de Goede
2016-12-19 0:07 ` [PATCH 12/14] power: supply: axp288_charger: Fix wrong regmap_update_bits Hans de Goede
2016-12-19 0:07 ` [PATCH 13/14] power: supply: axp288_charger: Remove unnecessary irq?_en register writes Hans de Goede
2016-12-19 0:07 ` [PATCH 14/14] power: supply: axp288_charger: Fix the module not auto-loading Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58579438.3050205@samsung.com \
--to=cw00.choi@samsung.com \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@samsung.com \
--cc=russianneuromancer@ya.ru \
--cc=sre@kernel.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.