aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrans Klaver <fransklaver@gmail.com>2014-09-17 17:47:23 -0400
committerDarren Hart <dvhart@linux.intel.com>2014-09-19 12:42:11 -0400
commit6fe3a77f6296a6c995eb08d564bafec028c15a18 (patch)
tree932e9dfe9edbbb6784e703c243ff0f4f21c96967
parent9797132577aa53734f4e980f9008f617947fddc9 (diff)
eeepc-laptop: tell sysfs that the disp attribute is write-only
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> Signed-off-by: Darren Hart <dvhart@linux.intel.com>
-rw-r--r--drivers/platform/x86/eeepc-laptop.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index c6d765fec8e9..a85da4f837e6 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)
311 return store_sys_acpi(dev, _cm, buf, count); \ 311 return store_sys_acpi(dev, _cm, buf, count); \
312 } 312 }
313 313
314#define EEEPC_CREATE_DEVICE_ATTR(_name, _mode, _cm) \ 314#define EEEPC_CREATE_DEVICE_ATTR_RW(_name, _cm) \
315 EEEPC_ACPI_SHOW_FUNC(_name, _cm) \ 315 EEEPC_ACPI_SHOW_FUNC(_name, _cm) \
316 EEEPC_ACPI_STORE_FUNC(_name, _cm) \ 316 EEEPC_ACPI_STORE_FUNC(_name, _cm) \
317 static DEVICE_ATTR(_name, _mode, _name##_show, _name##_store) 317 static DEVICE_ATTR_RW(_name)
318 318
319EEEPC_CREATE_DEVICE_ATTR(camera, 0644, CM_ASL_CAMERA); 319#define EEEPC_CREATE_DEVICE_ATTR_WO(_name, _cm) \
320EEEPC_CREATE_DEVICE_ATTR(cardr, 0644, CM_ASL_CARDREADER); 320 EEEPC_ACPI_STORE_FUNC(_name, _cm) \
321EEEPC_CREATE_DEVICE_ATTR(disp, 0200, CM_ASL_DISPLAYSWITCH); 321 static DEVICE_ATTR_WO(_name)
322
323EEEPC_CREATE_DEVICE_ATTR_RW(camera, CM_ASL_CAMERA);
324EEEPC_CREATE_DEVICE_ATTR_RW(cardr, CM_ASL_CARDREADER);
325EEEPC_CREATE_DEVICE_ATTR_WO(disp, CM_ASL_DISPLAYSWITCH);
322 326
323struct eeepc_cpufv { 327struct eeepc_cpufv {
324 int num; 328 int num;