From: Milo Kim <woogyom.kim@gmail.com>
To: Sebastian Reichel <sre@kernel.org>
Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Milo Kim <woogyom.kim@gmail.com>
Subject: [PATCH 1/5] power: supply: tps65217: Move IRQ related operation into single function
Date: Tue, 15 Nov 2016 22:18:51 +0900 [thread overview]
Message-ID: <20161115131855.4175-2-woogyom.kim@gmail.com> (raw)
In-Reply-To: <20161115131855.4175-1-woogyom.kim@gmail.com>
TPS65217 charger driver handles the charger interrupt through the IRQ or
polling. Both cases can be requested in single function.
Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Milo Kim <woogyom.kim@gmail.com>
---
drivers/power/supply/tps65217_charger.c | 70 ++++++++++++++++++---------------
1 file changed, 38 insertions(+), 32 deletions(-)
diff --git a/drivers/power/supply/tps65217_charger.c b/drivers/power/supply/tps65217_charger.c
index 9fd019f..04f8322 100644
--- a/drivers/power/supply/tps65217_charger.c
+++ b/drivers/power/supply/tps65217_charger.c
@@ -195,12 +195,48 @@ static const struct power_supply_desc tps65217_charger_desc = {
.num_properties = ARRAY_SIZE(tps65217_ac_props),
};
+static int tps65217_charger_request_interrupt(struct platform_device *pdev)
+{
+ struct tps65217_charger *charger = platform_get_drvdata(pdev);
+ int irq;
+ int ret;
+
+ irq = platform_get_irq_byname(pdev, "AC");
+ if (irq < 0)
+ irq = -ENXIO;
+
+ charger->irq = irq;
+
+ if (irq != -ENXIO) {
+ ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
+ tps65217_charger_irq, 0,
+ "tps65217-charger", charger);
+ if (ret) {
+ dev_err(charger->dev,
+ "Unable to register irq %d err %d\n", irq, ret);
+ return ret;
+ }
+
+ /* Check current state */
+ tps65217_charger_irq(irq, charger);
+ return 0;
+ }
+
+ charger->poll_task = kthread_run(tps65217_charger_poll_task, charger,
+ "ktps65217charger");
+ if (IS_ERR(charger->poll_task)) {
+ ret = PTR_ERR(charger->poll_task);
+ dev_err(charger->dev, "Unable to run kthread err %d\n", ret);
+ }
+
+ return 0;
+}
+
static int tps65217_charger_probe(struct platform_device *pdev)
{
struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
struct tps65217_charger *charger;
struct power_supply_config cfg = {};
- int irq;
int ret;
dev_dbg(&pdev->dev, "%s\n", __func__);
@@ -224,43 +260,13 @@ static int tps65217_charger_probe(struct platform_device *pdev)
return PTR_ERR(charger->ac);
}
- irq = platform_get_irq_byname(pdev, "AC");
- if (irq < 0)
- irq = -ENXIO;
- charger->irq = irq;
-
ret = tps65217_config_charger(charger);
if (ret < 0) {
dev_err(charger->dev, "charger config failed, err %d\n", ret);
return ret;
}
- if (irq != -ENXIO) {
- ret = devm_request_threaded_irq(&pdev->dev, irq, NULL,
- tps65217_charger_irq,
- 0, "tps65217-charger",
- charger);
- if (ret) {
- dev_err(charger->dev,
- "Unable to register irq %d err %d\n", irq,
- ret);
- return ret;
- }
-
- /* Check current state */
- tps65217_charger_irq(irq, charger);
- } else {
- charger->poll_task = kthread_run(tps65217_charger_poll_task,
- charger, "ktps65217charger");
- if (IS_ERR(charger->poll_task)) {
- ret = PTR_ERR(charger->poll_task);
- dev_err(charger->dev,
- "Unable to run kthread err %d\n", ret);
- return ret;
- }
- }
-
- return 0;
+ return tps65217_charger_request_interrupt(pdev);
}
static int tps65217_charger_remove(struct platform_device *pdev)
--
2.9.3
next prev parent reply other threads:[~2016-11-15 13:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-15 13:18 [PATCH 0/5] power: supply: tps65217: Support USB charger feature Milo Kim
2016-11-15 13:18 ` Milo Kim [this message]
2016-11-22 16:49 ` [PATCH 1/5] power: supply: tps65217: Move IRQ related operation into single function Sebastian Reichel
2016-11-22 16:56 ` Sebastian Reichel
2016-11-15 13:18 ` [PATCH 2/5] power: supply: tps65217: Remove IRQ data from driver data Milo Kim
2016-11-22 16:51 ` Sebastian Reichel
2016-11-22 16:58 ` Sebastian Reichel
2016-11-23 11:47 ` Milo Kim
2016-11-15 13:18 ` [PATCH 3/5] power: supply: tps65217: Support USB charger interrupt Milo Kim
2016-11-15 13:18 ` [PATCH 4/5] power: supply: tps65217: Use generic name for charger online Milo Kim
2016-11-15 13:18 ` [PATCH 5/5] power: supply: tps65217: Use generic name for power supply structures Milo Kim
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=20161115131855.4175-2-woogyom.kim@gmail.com \
--to=woogyom.kim@gmail.com \
--cc=enric.balletbo@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.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;
as well as URLs for NNTP newsgroup(s).