From: Anton Vorontsov <cbouatmailru@gmail.com>
To: Dmitry Baryshkov <dbaryshkov@gmail.com>
Cc: linux-kernel@vger.kernel.org, cbou@mail.ru, dwmw2@infradead.org
Subject: Re: [PATCH] pda-power: only register available psu
Date: Fri, 4 Jan 2008 03:29:07 +0300 [thread overview]
Message-ID: <20080104002907.GA767@zarina> (raw)
In-Reply-To: <20080103005319.GA714@doriath.ww600.siemens.net>
Hi Dmitry,
On Thu, Jan 03, 2008 at 03:53:19AM +0300, Dmitry Baryshkov wrote:
> Currently pda-power adds both ac and usb power supply units.
> This patch fixes it so that psu are added only if they are enabled.
Thanks for the patch, this should be fixed of course. A comment
though...
> Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
>
> diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
> index c058f28..42eac09 100644
> --- a/drivers/power/pda_power.c
> +++ b/drivers/power/pda_power.c
[...]
> if (ac_irq) {
> + ret = power_supply_register(&pdev->dev, &pda_power_supplies[0]);
I don't think we should check for IRQs when determining which one
of power supplies to register. Better use is_{ac,usb}_online
callbacks, this will not produce an obstacle to implement polling --
when irqs aren't mandatory. I'll send my two pending patches to show
the idea.
For this particular issue, I think something like that should work.
If it works for you, I'll commit that version, preserving your
authorship, of course.
---
diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
index c058f28..d98622f 100644
--- a/drivers/power/pda_power.c
+++ b/drivers/power/pda_power.c
@@ -168,66 +168,74 @@ static int pda_power_probe(struct platform_device *pdev)
pda_power_supplies[1].num_supplicants = pdata->num_supplicants;
}
- ret = power_supply_register(&pdev->dev, &pda_power_supplies[0]);
- if (ret) {
- dev_err(dev, "failed to register %s power supply\n",
- pda_power_supplies[0].name);
- goto supply0_failed;
- }
+ if (pdata->is_ac_online) {
+ ret = power_supply_register(&pdev->dev, &pda_power_supplies[0]);
+ if (ret) {
+ dev_err(dev, "failed to register %s power supply\n",
+ pda_power_supplies[0].name);
+ goto ac_supply_failed;
+ }
- ret = power_supply_register(&pdev->dev, &pda_power_supplies[1]);
- if (ret) {
- dev_err(dev, "failed to register %s power supply\n",
- pda_power_supplies[1].name);
- goto supply1_failed;
+ if (ac_irq) {
+ ret = request_irq(ac_irq->start, power_changed_isr,
+ get_irq_flags(ac_irq), ac_irq->name,
+ &pda_power_supplies[0]);
+ if (ret) {
+ dev_err(dev, "request ac irq failed\n");
+ goto ac_irq_failed;
+ }
+ }
}
- if (ac_irq) {
- ret = request_irq(ac_irq->start, power_changed_isr,
- get_irq_flags(ac_irq), ac_irq->name,
- &pda_power_supplies[0]);
+ if (pdata->is_usb_online) {
+ ret = power_supply_register(&pdev->dev, &pda_power_supplies[1]);
if (ret) {
- dev_err(dev, "request ac irq failed\n");
- goto ac_irq_failed;
+ dev_err(dev, "failed to register %s power supply\n",
+ pda_power_supplies[1].name);
+ goto usb_supply_failed;
}
- }
- if (usb_irq) {
- ret = request_irq(usb_irq->start, power_changed_isr,
- get_irq_flags(usb_irq), usb_irq->name,
- &pda_power_supplies[1]);
- if (ret) {
- dev_err(dev, "request usb irq failed\n");
- goto usb_irq_failed;
+ if (usb_irq) {
+ ret = request_irq(usb_irq->start, power_changed_isr,
+ get_irq_flags(usb_irq),
+ usb_irq->name,
+ &pda_power_supplies[1]);
+ if (ret) {
+ dev_err(dev, "request usb irq failed\n");
+ goto usb_irq_failed;
+ }
}
}
- goto success;
+ return 0;
usb_irq_failed:
- if (ac_irq)
+ if (pdata->is_usb_online)
+ power_supply_unregister(&pda_power_supplies[1]);
+usb_supply_failed:
+ if (pdata->is_ac_online && ac_irq)
free_irq(ac_irq->start, &pda_power_supplies[0]);
ac_irq_failed:
- power_supply_unregister(&pda_power_supplies[1]);
-supply1_failed:
- power_supply_unregister(&pda_power_supplies[0]);
-supply0_failed:
+ if (pdata->is_ac_online)
+ power_supply_unregister(&pda_power_supplies[0]);
+ac_supply_failed:
noirqs:
wrongid:
-success:
return ret;
}
static int pda_power_remove(struct platform_device *pdev)
{
- if (usb_irq)
+ if (pdata->is_usb_online && usb_irq)
free_irq(usb_irq->start, &pda_power_supplies[1]);
- if (ac_irq)
+ if (pdata->is_ac_online && ac_irq)
free_irq(ac_irq->start, &pda_power_supplies[0]);
del_timer_sync(&charger_timer);
del_timer_sync(&supply_timer);
- power_supply_unregister(&pda_power_supplies[1]);
- power_supply_unregister(&pda_power_supplies[0]);
+ if (pdata->is_usb_online)
+ power_supply_unregister(&pda_power_supplies[1]);
+ if (pdata->is_ac_online)
+ power_supply_unregister(&pda_power_supplies[0]);
return 0;
}
next prev parent reply other threads:[~2008-01-04 0:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-03 0:53 [PATCH] pda-power: only register available psu Dmitry Baryshkov
2008-01-04 0:29 ` Anton Vorontsov [this message]
2008-01-04 0:32 ` [PATCH 1/2] pda_power: various cleanups Anton Vorontsov
2008-01-04 0:32 ` [PATCH 2/2] pda_power: implement polling Anton Vorontsov
2008-01-04 1:31 ` [PATCH] pda-power: only register available psu Dmitry
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=20080104002907.GA767@zarina \
--to=cbouatmailru@gmail.com \
--cc=cbou@mail.ru \
--cc=dbaryshkov@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.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 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.