All of lore.kernel.org
 help / color / mirror / Atom feed
From: Viresh Kumar <viresh.kumar@linaro.org>
To: Anton Vorontsov <anton@enomsg.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	David Woodhouse <dwmw2@infradead.org>,
	Arve Hjonnevag <arve@android.com>,
	Todd Poynor <toddpoynor@google.com>,
	John Stultz <john.stultz@linaro.org>,
	Zoran Markovic <zoran.markovic@linaro.org>
Subject: Re: [RFC PATCH] pm: prevent suspend until power supply events are processed
Date: Wed, 3 Sep 2014 10:09:58 +0530	[thread overview]
Message-ID: <CAOh2x==TSbtOKBn6KOL9Z_M-nkzQOiO+EqSTmEtQeRLXROC1rw@mail.gmail.com> (raw)
In-Reply-To: <1375475882-3660-1-git-send-email-zoran.markovic@linaro.org>

Don't have Zoran's new email address, but probably other might have
answers to my queries.

I have just started with the power-supply framework a day or two back
and so my understanding might not be good enough :)

On Sat, Aug 3, 2013 at 2:08 AM, Zoran Markovic
<zoran.markovic@linaro.org> wrote:
> diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
> index 3b2d5df..e68d598 100644
> --- a/drivers/power/power_supply_core.c
> +++ b/drivers/power/power_supply_core.c
> @@ -67,23 +67,41 @@ static int __power_supply_changed_work(struct device *dev, void *data)
>
>  static void power_supply_changed_work(struct work_struct *work)
>  {
> +       unsigned long flags;
>         struct power_supply *psy = container_of(work, struct power_supply,
>                                                 changed_work);
>
>         dev_dbg(psy->dev, "%s\n", __func__);
>
> -       class_for_each_device(power_supply_class, NULL, psy,
> -                             __power_supply_changed_work);
> -
> -       power_supply_update_leds(psy);
> -
> -       kobject_uevent(&psy->dev->kobj, KOBJ_CHANGE);
> +       spin_lock_irqsave(&psy->changed_lock, flags);
> +       if (psy->changed) {

Can this be false here? We have reached here as the work was
scheduled after setting it to true..

Maybe a WARN_ON(psy->changed) is more sensible here ?

> +               psy->changed = false;
> +               spin_unlock_irqrestore(&psy->changed_lock, flags);
> +               class_for_each_device(power_supply_class, NULL, psy,
> +                                     __power_supply_changed_work);
> +               power_supply_update_leds(psy);
> +               kobject_uevent(&psy->dev->kobj, KOBJ_CHANGE);
> +               spin_lock_irqsave(&psy->changed_lock, flags);
> +       }
> +       /* dependent power supplies (e.g. battery) may have changed
> +        * state as a result of this event, so poll again and hold
> +        * the wakeup_source until all events are processed.
> +        */
> +       if (!psy->changed)
> +               pm_relax(psy->dev);

I got a bit confused here. Does the above comment say this:

The supplies dependent on 'psy' may change states and that *may*
change the state of 'psy' again? And so psy->changed is set to true
again?

  parent reply	other threads:[~2014-09-03  4:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-02 20:38 [RFC PATCH] pm: prevent suspend until power supply events are processed Zoran Markovic
2013-08-22 17:10 ` Zoran Markovic
2013-08-28  1:43 ` Anton Vorontsov
2014-09-03  4:39 ` Viresh Kumar [this message]
2014-09-03  5:05   ` Viresh Kumar
     [not found]     ` <CA+B8BG5Hf8=ki0JDeRR13Mo7QRFDmsDuEpW8ozepvCp5KsY8ZA@mail.gmail.com>
2014-09-04  4:51       ` Viresh Kumar
2014-09-04  4:53         ` Viresh Kumar
2014-09-04 16:37           ` Tc, Jenny
2014-09-09 21:53             ` Todd Poynor
2014-09-09 21:55           ` Todd Poynor

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='CAOh2x==TSbtOKBn6KOL9Z_M-nkzQOiO+EqSTmEtQeRLXROC1rw@mail.gmail.com' \
    --to=viresh.kumar@linaro.org \
    --cc=anton@enomsg.org \
    --cc=arve@android.com \
    --cc=dwmw2@infradead.org \
    --cc=john.stultz@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=toddpoynor@google.com \
    --cc=zoran.markovic@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.