From: Frans Klaver <fransklaver@gmail.com>
To: Corentin Chary <corentin.chary@gmail.com>
Cc: Frans Klaver <fransklaver@gmail.com>,
Matthew Garrett <matthew.garrett@nebula.com>,
Darren Hart <dvhart@infradead.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rafael Wysocki <rafael.j.wysocki@intel.com>,
acpi4asus-user@lists.sourceforge.net,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] eeepc-laptop: remove disp attribute show function
Date: Mon, 8 Sep 2014 23:12:42 +0200 [thread overview]
Message-ID: <1410210762-2487-1-git-send-email-fransklaver@gmail.com> (raw)
In-Reply-To: <7288841.ayNsq2yeGO@vostro.rjw.lan>
The disp attribute is write-only. This is enforced by mimicking sysfs
behavior store_sys_acpi() and show_sys_acpi(), but this is not ideal.
Behaving like sysfs is better left to sysfs.
Remove the show function from the disp attribute. This ensures userspace
can only write to disp at all times. While at it, propagate any errors
produced in store_sys_acpi() and show_sys_acpi(), instead of overriding
them with -EIO.
Signed-off-by: Frans Klaver <fransklaver@gmail.com>
---
This patch applies on top of Paul's "eeepc-laptop: simplify parse_arg()".
Tested both patches separately, as well as combined. As far as I can see the
system behaves exactly like before.
drivers/platform/x86/eeepc-laptop.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 78515b8..03bcbed 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -281,7 +281,7 @@ static ssize_t store_sys_acpi(struct device *dev, int cm,
return rv;
value = set_acpi(eeepc, cm, value);
if (value < 0)
- return -EIO;
+ return value;
return count;
}
@@ -291,7 +291,7 @@ static ssize_t show_sys_acpi(struct device *dev, int cm, char *buf)
int value = get_acpi(eeepc, cm);
if (value < 0)
- return -EIO;
+ return value;
return sprintf(buf, "%d\n", value);
}
@@ -318,7 +318,20 @@ static ssize_t show_sys_acpi(struct device *dev, int cm, char *buf)
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);
+
+static ssize_t store_disp(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ return store_sys_acpi(dev, CM_ASL_DISPLAYSWITCH, buf, count);
+}
+
+static struct device_attribute dev_attr_disp = {
+ .attr = {
+ .name = "disp",
+ .mode = 0200 },
+ .store = store_disp,
+};
struct eeepc_cpufv {
int num;
--
2.1.0
next prev parent reply other threads:[~2014-09-08 21:13 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-03 22:53 [PATCH] eeepc-laptop: remove possible use of uninitialized value Frans Klaver
2014-09-04 0:49 ` Darren Hart
2014-09-04 1:14 ` Greg Kroah-Hartman
2014-09-04 6:46 ` Frans Klaver
2014-09-04 14:10 ` Greg Kroah-Hartman
2014-09-04 14:40 ` Frans Klaver
2014-09-04 19:37 ` Paul Bolle
2014-09-04 7:08 ` Paul Bolle
2014-09-04 7:57 ` Frans Klaver
2014-09-06 2:17 ` Darren Hart
2014-09-06 21:17 ` Rafael J. Wysocki
2014-09-09 8:50 ` Paul Bolle
2014-09-10 3:33 ` Darren Hart
2014-09-10 14:42 ` Frans Klaver
2014-09-10 16:49 ` Darren Hart
2014-09-10 20:05 ` [PATCH v2] eeepc-laptop: simplify parse_arg() Paul Bolle
2014-09-11 22:37 ` Darren Hart
2014-09-16 23:45 ` Darren Hart
2014-09-17 19:02 ` [PATCH v3] " Paul Bolle
2014-09-17 20:14 ` Darren Hart
2014-09-17 20:35 ` Darren Hart
2014-09-17 20:36 ` Frans Klaver
2014-09-17 21:39 ` Frans Klaver
2014-09-08 21:12 ` Frans Klaver [this message]
2014-09-08 21:16 ` [PATCH] eeepc-laptop: remove disp attribute show function Greg Kroah-Hartman
[not found] ` <20140908212306.GA22145@gmail.com>
[not found] ` <20140908214438.GB22145@gmail.com>
2014-09-08 21:57 ` Greg Kroah-Hartman
2014-09-08 23:32 ` Darren Hart
2014-09-09 0:06 ` [PATCH] eeepc-laptop: remove possible use of uninitialized value Darren Hart
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=1410210762-2487-1-git-send-email-fransklaver@gmail.com \
--to=fransklaver@gmail.com \
--cc=acpi4asus-user@lists.sourceforge.net \
--cc=corentin.chary@gmail.com \
--cc=dvhart@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=matthew.garrett@nebula.com \
--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
all inboxes | Powered by JetHome®