From: Andrew Morton <akpm@linux-foundation.org>
To: Mike Rapoport <mike@compulab.co.il>
Cc: cbou@mail.ru, linux-kernel@vger.kernel.org, mike@compulab.co.il
Subject: Re: [PATCH] da9030_battery: fix race between event handler and monitor
Date: Wed, 13 May 2009 11:40:46 -0700 [thread overview]
Message-ID: <20090513114046.6557fc0e.akpm@linux-foundation.org> (raw)
In-Reply-To: <1242112809-10021-1-git-send-email-mike@compulab.co.il>
On Tue, 12 May 2009 10:20:09 +0300
Mike Rapoport <mike@compulab.co.il> wrote:
> Signed-off-by: Mike Rapoport <mike@compulab.co.il>
We seem to be missing a changelog.
>
> diff --git a/drivers/power/da9030_battery.c b/drivers/power/da9030_battery.c
> index 1662bb0..3364198 100644
> --- a/drivers/power/da9030_battery.c
> +++ b/drivers/power/da9030_battery.c
> @@ -22,8 +22,6 @@
> #include <linux/debugfs.h>
> #include <linux/seq_file.h>
>
> -#define DA9030_STATUS_CHDET (1 << 3)
> -
> #define DA9030_FAULT_LOG 0x0a
> #define DA9030_FAULT_LOG_OVER_TEMP (1 << 7)
> #define DA9030_FAULT_LOG_VBAT_OVER (1 << 4)
> @@ -244,6 +242,8 @@ static void da9030_set_charge(struct da9030_charger *charger, int on)
> }
>
> da903x_write(charger->master, DA9030_CHARGE_CONTROL, val);
> +
> + power_supply_changed(&charger->psy);
> }
>
> static void da9030_charger_check_state(struct da9030_charger *charger)
> @@ -258,6 +258,12 @@ static void da9030_charger_check_state(struct da9030_charger *charger)
> da9030_set_charge(charger, 1);
> }
> } else {
> + /* Charger has been pulled out */
> + if (!charger->chdet) {
> + da9030_set_charge(charger, 0);
> + return;
> + }
> +
> if (charger->adc.vbat_res >=
> charger->thresholds.vbat_charge_stop) {
> da9030_set_charge(charger, 0);
> @@ -395,13 +401,11 @@ static int da9030_battery_event(struct notifier_block *nb, unsigned long event,
> {
> struct da9030_charger *charger =
> container_of(nb, struct da9030_charger, nb);
> - int status;
>
> switch (event) {
> case DA9030_EVENT_CHDET:
> - status = da903x_query_status(charger->master,
> - DA9030_STATUS_CHDET);
> - da9030_set_charge(charger, status);
> + cancel_delayed_work_sync(&charger->work);
> + schedule_work(&charger->work.work);
> break;
> case DA9030_EVENT_VBATMON:
> da9030_battery_vbat_event(charger);
> @@ -565,7 +569,8 @@ static int da9030_battery_remove(struct platform_device *dev)
> da903x_unregister_notifier(charger->master, &charger->nb,
> DA9030_EVENT_CHDET | DA9030_EVENT_VBATMON |
> DA9030_EVENT_CHIOVER | DA9030_EVENT_TBAT);
> - cancel_delayed_work(&charger->work);
> + cancel_delayed_work_sync(&charger->work);
> + da9030_set_charge(charger, 0);
> power_supply_unregister(&charger->psy);
>
> kfree(charger);
What is this race? What are the user-visible effects when it occurs?
How does the patch fix the race?
next prev parent reply other threads:[~2009-05-13 18:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-12 7:20 [PATCH] da9030_battery: fix race between event handler and monitor Mike Rapoport
2009-05-13 18:40 ` Andrew Morton [this message]
2009-05-14 5:39 ` Mike Rapoport
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=20090513114046.6557fc0e.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=cbou@mail.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=mike@compulab.co.il \
/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.