From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Frans Klaver <fransklaver@gmail.com>
Cc: Darren Hart <dvhart@infradead.org>,
Corentin Chary <corentin.chary@gmail.com>,
Rafael Wysocki <rafael.j.wysocki@intel.com>,
acpi4asus-user@lists.sourceforge.net,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/9] eeepc-laptop: tell sysfs that the disp attribute is write-only
Date: Wed, 17 Sep 2014 15:07:53 -0700 [thread overview]
Message-ID: <20140917220753.GB20915@kroah.com> (raw)
In-Reply-To: <1410990447-3210-6-git-send-email-fransklaver@gmail.com>
On Wed, Sep 17, 2014 at 11:47:23PM +0200, Frans Klaver wrote:
> The disp attribute is write-only, but sysfs doesn't know this. Currently
> show_sys_acpi() is mimicking sysfs behavior, if the underlying acpi call
> should fail. This was introduced in 6dff29b63a5bf2eaf3 "eeepc-laptop:
> disp attribute should be write-only". This is not ideal; behaving like
> sysfs is better left to sysfs.
>
> Introduce EEEPC_CREATE_DEVICE_ATTR_WO() to instantiate a write-only
> attribute, and declare the disp attribute with it. Sysfs makes sure
> userspace can only write to disp at all times. This removes the need for
> mimicking the sysfs behavior in show_sys_acpi() and store_sys_acpi(),
> but we'll stick with -EIO, as changing sysfs return values should not be
> taken lightly.
>
> This change also causes EEEPC_CREATE_DEVICE_ATTR() to be used only for
> R/W attributes. This enables us to drop the _mode argument from the
> macro and use DEVICE_ATTR_RW() internally while we're at it. Append _RW
> to the name for readability.
>
> Signed-off-by: Frans Klaver <fransklaver@gmail.com>
> ---
> Here we're sticking with -EIO as return values. It should be said that the
> commit mentioned above did change the error value from -ENODEV to -EIO. I'm
> still in two minds about whether the show_sys_acpi and store_sys_acpi should go
> back to returning ENODEV. We'll probably stick with -EIO, though, as there is
> no strong reason other than "it was like that before".
>
> drivers/platform/x86/eeepc-laptop.c | 14 +++++++++-----
> 1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
> index c6d765f..a85da4f 100644
> --- a/drivers/platform/x86/eeepc-laptop.c
> +++ b/drivers/platform/x86/eeepc-laptop.c
> @@ -311,14 +311,18 @@ static ssize_t show_sys_acpi(struct device *dev, int cm, char *buf)
> return store_sys_acpi(dev, _cm, buf, count); \
> }
>
> -#define EEEPC_CREATE_DEVICE_ATTR(_name, _mode, _cm) \
> +#define EEEPC_CREATE_DEVICE_ATTR_RW(_name, _cm) \
> EEEPC_ACPI_SHOW_FUNC(_name, _cm) \
> EEEPC_ACPI_STORE_FUNC(_name, _cm) \
> - static DEVICE_ATTR(_name, _mode, _name##_show, _name##_store)
> + static DEVICE_ATTR_RW(_name)
>
> -EEEPC_CREATE_DEVICE_ATTR(camera, 0644, CM_ASL_CAMERA);
> -EEEPC_CREATE_DEVICE_ATTR(cardr, 0644, CM_ASL_CARDREADER);
> -EEEPC_CREATE_DEVICE_ATTR(disp, 0200, CM_ASL_DISPLAYSWITCH);
> +#define EEEPC_CREATE_DEVICE_ATTR_WO(_name, _cm) \
> + EEEPC_ACPI_STORE_FUNC(_name, _cm) \
> + static DEVICE_ATTR_WO(_name)
> +
> +EEEPC_CREATE_DEVICE_ATTR_RW(camera, CM_ASL_CAMERA);
> +EEEPC_CREATE_DEVICE_ATTR_RW(cardr, CM_ASL_CARDREADER);
> +EEEPC_CREATE_DEVICE_ATTR_WO(disp, CM_ASL_DISPLAYSWITCH);
>
> struct eeepc_cpufv {
> int num;
Ah, you did what I asked on a previous patch here, nevermind :)
greg k-h
next prev parent reply other threads:[~2014-09-17 22:07 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-17 21:47 [PATCH v2 0/9] eeepc cleanup Frans Klaver
2014-09-17 21:47 ` [PATCH 1/9] eeepc-laptop: clean up coding style Frans Klaver
2014-09-17 22:06 ` Joe Perches
2014-09-18 5:01 ` Frans Klaver
2014-09-19 16:46 ` Darren Hart
2014-09-19 17:17 ` Frans Klaver
2014-09-19 16:43 ` Darren Hart
2014-09-17 21:47 ` [PATCH 2/9] eeepc-laptop: change sysfs function names to API expectations Frans Klaver
2014-09-17 21:47 ` [PATCH 3/9] eeepc-laptop: use DEVICE_ATTR* to instantiate device_attributes Frans Klaver
2014-09-17 22:06 ` Greg Kroah-Hartman
2014-09-17 21:47 ` [PATCH 4/9] eeepc-laptop: pull out ACPI_STORE_FUNC and ACPI_SHOW_FUNC macros Frans Klaver
2014-09-17 21:47 ` [PATCH 5/9] eeepc-laptop: tell sysfs that the disp attribute is write-only Frans Klaver
2014-09-17 22:07 ` Greg Kroah-Hartman [this message]
2014-09-18 5:04 ` Frans Klaver
2014-09-17 21:47 ` [PATCH 6/9] eeepc-laptop: pull out SENSOR_STORE_FUNC and SENSOR_SHOW_FUNC macros Frans Klaver
2014-09-17 21:47 ` [PATCH 7/9] eeepc-laptop: make fan1_input really read-only Frans Klaver
2014-09-17 21:47 ` [PATCH 8/9] eeepc-laptop: check proper return values in get_cpufv Frans Klaver
2014-09-17 21:47 ` [PATCH 9/9] eeepc-laptop: store_cpufv: return error if set_acpi fails Frans Klaver
2014-09-19 17:25 ` [PATCH v2 0/9] eeepc cleanup Darren Hart
2014-09-19 17:33 ` Frans Klaver
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=20140917220753.GB20915@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=acpi4asus-user@lists.sourceforge.net \
--cc=corentin.chary@gmail.com \
--cc=dvhart@infradead.org \
--cc=fransklaver@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael.j.wysocki@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox