All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Zhang Rui <rui.zhang@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
	Christoph Hellwig <hch@lst.de>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux PM <linux-pm@vger.kernel.org>
Subject: Re: driver notification when switching between battery vs AC power?
Date: Mon, 8 Mar 2021 08:50:48 +0100	[thread overview]
Message-ID: <20210308075048.GA983@lst.de> (raw)
In-Reply-To: <357ec08b83bef385162c23f37b4efa439a120947.camel@intel.com>

On Sun, Mar 07, 2021 at 09:53:06PM +0800, Zhang Rui wrote:
> Thanks for adding me in the loop.
> 
> Yes, an ACPI notifier callback should be sufficient for this purpose.
> 
> Usually, we get an ACPI notification upon AC plug/unplug, so what we
> need in the NVMe driver is to get the notification and then get the
> status of AC adapter. As ACPI AC driver always sends the AC events to
> acpi notifier chain, what we need is 
> a) define a notifier callback, and in the notifier callback
>    1. ignore non-AC devices,
>    2. get AC status, you can refer to acpi_ac_get_state()
> b) register the notifier cb to ACPI notifier chain, by invoking
>    register_acpi_notifier()

Not my direct priority now, but would there be any objections to
wire up a power_source_notifier method in struct dev_pm_ops to
avoid boilerplate code and ACPI dependencies in drivers?

  reply	other threads:[~2021-03-08  7:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05  8:07 driver notification when switching between battery vs AC power? Christoph Hellwig
2021-03-05 15:18 ` Rafael J. Wysocki
2021-03-07 13:53   ` Zhang Rui
2021-03-08  7:50     ` Christoph Hellwig [this message]
2021-03-08 15:29       ` Rafael J. Wysocki
2021-03-08 17:30         ` Rafael J. Wysocki
2021-03-08 18:13         ` Sebastian Reichel

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=20210308075048.GA983@lst.de \
    --to=hch@lst.de \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=rui.zhang@intel.com \
    /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.