From: Hans de Goede <hdegoede@redhat.com>
To: Sebastian Reichel <sre@kernel.org>, Chen-Yu Tsai <wens@csie.org>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>
Cc: "russianneuromancer @ ya . ru" <russianneuromancer@ya.ru>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Hans de Goede <hdegoede@redhat.com>
Subject: [PATCH 06/14] power: supply: axp288_charger: Register extcon notifers after power_supply
Date: Mon, 19 Dec 2016 01:07:23 +0100 [thread overview]
Message-ID: <20161219000731.10188-7-hdegoede@redhat.com> (raw)
In-Reply-To: <20161219000731.10188-1-hdegoede@redhat.com>
The extcon notifier work calls power_supply_changed on the power_supply
we register, so the extcon notifiers should be registered after we
register the power_supply.
While touching this code anyways, refactor the code for the 3 cable types
into a loop to avoid code repetition.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/power/supply/axp288_charger.c | 42 +++++++++++++----------------------
1 file changed, 15 insertions(+), 27 deletions(-)
diff --git a/drivers/power/supply/axp288_charger.c b/drivers/power/supply/axp288_charger.c
index e435b1e..5ed0a45 100644
--- a/drivers/power/supply/axp288_charger.c
+++ b/drivers/power/supply/axp288_charger.c
@@ -815,6 +815,8 @@ static int axp288_charger_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
struct power_supply_config charger_cfg = {};
+ unsigned int cable_ids[] = { EXTCON_CHG_USB_SDP, EXTCON_CHG_USB_CDP,
+ EXTCON_CHG_USB_DCP };
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
if (!info)
@@ -831,33 +833,6 @@ static int axp288_charger_probe(struct platform_device *pdev)
return -EPROBE_DEFER;
}
- /* 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 = 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 = 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);
- return ret;
- }
-
- 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);
- return ret;
- }
-
platform_set_drvdata(pdev, info);
mutex_init(&info->lock);
@@ -870,6 +845,19 @@ static int axp288_charger_probe(struct platform_device *pdev)
return PTR_ERR(info->psy_usb);
}
+ /* Register for extcon notification */
+ INIT_WORK(&info->cable.work, axp288_charger_extcon_evt_worker);
+ info->cable.nb.notifier_call = axp288_charger_handle_cable_evt;
+ for (i = 0; i < ARRAY_SIZE(cable_ids); i++) {
+ ret = devm_extcon_register_notifier(dev, info->cable.edev,
+ cable_ids[i], &info->cable.nb);
+ if (ret) {
+ dev_err(dev, "failed to register extcon notifier for %u: %d\n",
+ cable_ids[i], ret);
+ return ret;
+ }
+ }
+
/* 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;
--
2.9.3
next prev parent reply other threads:[~2016-12-19 0:10 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
2016-12-19 8:42 ` Hans de Goede
2016-12-19 0:07 ` Hans de Goede [this message]
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=20161219000731.10188-7-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=cw00.choi@samsung.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®