platform-driver-x86.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Hans de Goede <hdegoede@redhat.com>
Cc: "Rafael J . Wysocki" <rjw@rjwysocki.net>,
	Mark Pearson <markpearson@lenovo.com>,
	Len Brown <lenb@kernel.org>, Andy Shevchenko <andy@kernel.org>,
	"Luke D . Jones" <luke@ljones.dev>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
	Platform Driver <platform-driver-x86@vger.kernel.org>
Subject: Re: [PATCH] ACPI: platform-profile: call sysfs_notify() from platform_profile_store()
Date: Mon, 16 Aug 2021 18:33:30 +0200	[thread overview]
Message-ID: <CAJZ5v0jArWOehWeO16fhnOrJGLqoVyX0tSNtBKcFuqv6=rMB2Q@mail.gmail.com> (raw)
In-Reply-To: <20210816113007.88902-1-hdegoede@redhat.com>

On Mon, Aug 16, 2021 at 1:30 PM Hans de Goede <hdegoede@redhat.com> wrote:
>
> Drivers like thinkpad_acpi and ideapad_laptop call the
> platform_profile_notify() helper when the profile is changed by hardware
> (the embedded-controller/EC) in response to an EC handled hotkey.
>
> This allows userspace to monitor for such changes by polling for POLLPRI
> on the platform_profile sysfs file. But the profile can also be changed
> underneath a userspace program monitoring it by anonther userspace program
> storing a new value.
>
> Add a sysfs_notify() call to platform_profile_store(), so that userspace
> programs monitoring for changes also get notified in this case.
>
> Also update the documentation to document that POLLPRI polling can be
> used to watch for changes.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  Documentation/ABI/testing/sysfs-platform_profile | 7 +++++++
>  drivers/acpi/platform_profile.c                  | 3 +++
>  2 files changed, 10 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-platform_profile b/Documentation/ABI/testing/sysfs-platform_profile
> index dae9c8941905..baf1d125f9f8 100644
> --- a/Documentation/ABI/testing/sysfs-platform_profile
> +++ b/Documentation/ABI/testing/sysfs-platform_profile
> @@ -26,3 +26,10 @@ Contact:     Hans de Goede <hdegoede@redhat.com>
>  Description:   Reading this file gives the current selected profile for this
>                 device. Writing this file with one of the strings from
>                 platform_profile_choices changes the profile to the new value.
> +
> +               This file can be monitored for changes by polling for POLLPRI,
> +               POLLPRI will be signalled on any changes, independent of those
> +               changes coming from a userspace write; or coming from another
> +               source such as e.g. a hotkey triggered profile change handled
> +               either directly by the embedded-controller or fully handled
> +               inside the kernel.
> diff --git a/drivers/acpi/platform_profile.c b/drivers/acpi/platform_profile.c
> index dd2fbf38e414..d418462ab791 100644
> --- a/drivers/acpi/platform_profile.c
> +++ b/drivers/acpi/platform_profile.c
> @@ -106,6 +106,9 @@ static ssize_t platform_profile_store(struct device *dev,
>         }
>
>         err = cur_profile->profile_set(cur_profile, i);
> +       if (!err)
> +               sysfs_notify(acpi_kobj, NULL, "platform_profile");
> +
>         mutex_unlock(&profile_lock);
>         if (err)
>                 return err;
> --

Applied as 5.15 material, thanks!

      reply	other threads:[~2021-08-16 16:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-16 11:30 [PATCH] ACPI: platform-profile: call sysfs_notify() from platform_profile_store() Hans de Goede
2021-08-16 16:33 ` Rafael J. Wysocki [this message]

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='CAJZ5v0jArWOehWeO16fhnOrJGLqoVyX0tSNtBKcFuqv6=rMB2Q@mail.gmail.com' \
    --to=rafael@kernel.org \
    --cc=andy@kernel.org \
    --cc=hdegoede@redhat.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=luke@ljones.dev \
    --cc=markpearson@lenovo.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).