From: David Heidelberg <david@ixit.cz>
To: Sebastian Reichel <sre@kernel.org>,
Jonghwa Lee <jonghwa3.lee@samsung.com>,
Chanwoo Choi <cw00.choi@samsung.com>,
Myungjoo Ham <myungjoo.ham@samsung.com>,
Sumit Semwal <sumit.semwal@linaro.org>,
John Stultz <john.stultz@linaro.org>,
Vinay Simha BN <simhavcs@gmail.com>,
mika.westerberg@linux.intel.com, ramakrishna.pallala@intel.com,
Dmitry Osipenko <digetx@gmail.com>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: David Heidelberg <david@ixit.cz>
Subject: [PATCH 3/9] power: supply: smb347-charger: Use resource-managed API
Date: Sun, 29 Mar 2020 18:15:46 +0200 [thread overview]
Message-ID: <20200329161552.215075-4-david@ixit.cz> (raw)
In-Reply-To: <20200329161552.215075-1-david@ixit.cz>
Simplify code, more convenient to use with Device Tree.
Reviewed-by: Dmitry Osipenko <digetx@gmail.com>
Signed-off-by: David Heidelberg <david@ixit.cz>
---
drivers/power/supply/smb347-charger.c | 45 +++++++++++++--------------
1 file changed, 21 insertions(+), 24 deletions(-)
diff --git a/drivers/power/supply/smb347-charger.c b/drivers/power/supply/smb347-charger.c
index f99026d81f2a..4add9f64ba90 100644
--- a/drivers/power/supply/smb347-charger.c
+++ b/drivers/power/supply/smb347-charger.c
@@ -836,21 +836,31 @@ static int smb347_irq_init(struct smb347_charger *smb,
struct i2c_client *client)
{
const struct smb347_charger_platform_data *pdata = smb->pdata;
- int ret, irq = gpio_to_irq(pdata->irq_gpio);
+ unsigned long irqflags = IRQF_ONESHOT;
+ int ret;
- ret = gpio_request_one(pdata->irq_gpio, GPIOF_IN, client->name);
- if (ret < 0)
- goto fail;
+ /* Requesting GPIO for IRQ is only needed in non-DT way */
+ if (!client->irq) {
+ int irq = gpio_to_irq(pdata->irq_gpio);
+
+ ret = devm_gpio_request_one(smb->dev, pdata->irq_gpio,
+ GPIOF_IN, client->name);
+ if (ret < 0)
+ return ret;
+
+ irqflags |= IRQF_TRIGGER_FALLING;
+ client->irq = irq;
+ }
- ret = request_threaded_irq(irq, NULL, smb347_interrupt,
- IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
- client->name, smb);
+ ret = devm_request_threaded_irq(smb->dev, client->irq, NULL,
+ smb347_interrupt, irqflags,
+ client->name, smb);
if (ret < 0)
- goto fail_gpio;
+ return ret;
ret = smb347_set_writable(smb, true);
if (ret < 0)
- goto fail_irq;
+ return ret;
/*
* Configure the STAT output to be suitable for interrupts: disable
@@ -860,20 +870,10 @@ static int smb347_irq_init(struct smb347_charger *smb,
CFG_STAT_ACTIVE_HIGH | CFG_STAT_DISABLED,
CFG_STAT_DISABLED);
if (ret < 0)
- goto fail_readonly;
+ client->irq = 0;
smb347_set_writable(smb, false);
- client->irq = irq;
- return 0;
-fail_readonly:
- smb347_set_writable(smb, false);
-fail_irq:
- free_irq(irq, smb);
-fail_gpio:
- gpio_free(pdata->irq_gpio);
-fail:
- client->irq = 0;
return ret;
}
@@ -1299,11 +1299,8 @@ static int smb347_remove(struct i2c_client *client)
{
struct smb347_charger *smb = i2c_get_clientdata(client);
- if (client->irq) {
+ if (client->irq)
smb347_irq_disable(smb);
- free_irq(client->irq, smb);
- gpio_free(smb->pdata->irq_gpio);
- }
power_supply_unregister(smb->battery);
if (smb->pdata->use_usb)
--
2.25.0
next prev parent reply other threads:[~2020-03-29 16:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-29 16:15 [PATCH 0/9] Summit SMB3xx driver & device-tree David Heidelberg
2020-03-29 16:15 ` [PATCH 1/9] power: supply: smb347-charger: IRQSTAT_D is volatile David Heidelberg
2020-05-10 16:28 ` Sebastian Reichel
2020-03-29 16:15 ` [PATCH 2/9] power: supply: smb347-charger: Add delay before getting IRQSTAT David Heidelberg
2020-05-10 16:28 ` Sebastian Reichel
2020-03-29 16:15 ` David Heidelberg [this message]
2020-05-10 16:33 ` [PATCH 3/9] power: supply: smb347-charger: Use resource-managed API Sebastian Reichel
2020-03-29 16:21 ` [PATCH 4/9] dt-bindings: power: supply: Add device-tree binding for Summit SMB3xx David Heidelberg
2020-04-10 16:49 ` Rob Herring
2020-04-10 19:02 ` Dmitry Osipenko
2020-04-15 14:27 ` Rob Herring
2020-04-15 15:30 ` Dmitry Osipenko
2020-05-09 1:14 ` Sebastian Reichel
2020-05-14 19:34 ` Dmitry Osipenko
2020-03-29 16:21 ` [PATCH 5/9] power: supply: smb347-charger: Implement device-tree support David Heidelberg
2020-03-31 0:25 ` Jonghwa Lee
2020-03-31 17:20 ` Dmitry Osipenko
2020-03-29 16:21 ` [PATCH 6/9] power: supply: smb347-charger: Support SMB345 and SMB358 David Heidelberg
2020-05-10 16:40 ` Sebastian Reichel
2020-03-29 16:21 ` [PATCH 7/9] power: supply: smb347-charger: Remove virtual smb347-battery David Heidelberg
2020-03-29 16:21 ` [PATCH 8/9] power: supply: smb347-charger: Replace mutex with IRQ disable/enable David Heidelberg
2020-03-29 16:21 ` [PATCH 9/9] arm: dts: qcom: apq8064-nexus7: Add smb345 charger node David Heidelberg
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=20200329161552.215075-4-david@ixit.cz \
--to=david@ixit.cz \
--cc=cw00.choi@samsung.com \
--cc=digetx@gmail.com \
--cc=john.stultz@linaro.org \
--cc=jonghwa3.lee@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=myungjoo.ham@samsung.com \
--cc=ramakrishna.pallala@intel.com \
--cc=simhavcs@gmail.com \
--cc=sre@kernel.org \
--cc=sumit.semwal@linaro.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.