All of lore.kernel.org
 help / color / mirror / Atom feed
From: Len Brown <len.brown@intel.com>
To: linux-acpi@vger.kernel.org
Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>,
	Len Brown <len.brown@intel.com>
Subject: [PATCH 075/105] ACPI: thinkpad-acpi: add sysfs support to the cmos command subdriver
Date: Sun, 29 Apr 2007 00:51:15 -0400	[thread overview]
Message-ID: <11778223733679-git-send-email-len.brown@intel.com> (raw)
Message-ID: <b616004c70dd7f60a1477c3e9d6fddd00ee1fa37.1177822058.git.len.brown@intel.com> (raw)
In-Reply-To: <11778223732286-git-send-email-len.brown@intel.com>
In-Reply-To: <ac122bb64b0d51f0512185d3522a75f3f3a80bc9.1177822058.git.len.brown@intel.com>

From: Henrique de Moraes Holschuh <hmh@hmh.eng.br>

Add sysfs attributes to send ThinkPad CMOS commands.

Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 Documentation/thinkpad-acpi.txt |   23 +++++++++++------------
 drivers/misc/thinkpad_acpi.c    |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index 339ce21..352e8ae 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -378,23 +378,19 @@ supported. Use "eject2" instead of "eject" for the second bay.
 Note: the UltraBay eject support on the 600e/x, A22p and A3x is
 EXPERIMENTAL and may not work as expected. USE WITH CAUTION!
 
-CMOS control -- /proc/acpi/ibm/cmos
------------------------------------
+CMOS control
+------------
+
+procfs: /proc/acpi/ibm/cmos
+sysfs device attribute: cmos_command
 
 This feature is used internally by the ACPI firmware to control the
 ThinkLight on most newer ThinkPad models. It may also control LCD
 brightness, sounds volume and more, but only on some models.
 
-The commands are non-negative integer numbers:
-
-	echo 0 >/proc/acpi/ibm/cmos
-	echo 1 >/proc/acpi/ibm/cmos
-	echo 2 >/proc/acpi/ibm/cmos
-	...
-
-The range of valid numbers is 0 to 21, but not all have an effect and
-the behavior varies from model to model. Here is the behavior on the
-X40 (tpb is the ThinkPad Buttons utility):
+The range of valid cmos command numbers is 0 to 21, but not all have an
+effect and the behavior varies from model to model.  Here is the behavior
+on the X40 (tpb is the ThinkPad Buttons utility):
 
 	0 - no effect but tpb reports "Volume down"
 	1 - no effect but tpb reports "Volume up"
@@ -407,6 +403,9 @@ X40 (tpb is the ThinkPad Buttons utility):
 	13 - ThinkLight off
 	14 - no effect but tpb reports ThinkLight status change
 
+The cmos command interface is prone to firmware split-brain problems, as
+in newer ThinkPads it is just a compatibility layer.
+
 LED control -- /proc/acpi/ibm/led
 ---------------------------------
 
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 79abc68..ba749df 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -1743,8 +1743,30 @@ static struct ibm_struct bay_driver_data = {
  * CMOS subdriver
  */
 
+/* sysfs cmos_command -------------------------------------------------- */
+static ssize_t cmos_command_store(struct device *dev,
+			    struct device_attribute *attr,
+			    const char *buf, size_t count)
+{
+	unsigned long cmos_cmd;
+	int res;
+
+	if (parse_strtoul(buf, 21, &cmos_cmd))
+		return -EINVAL;
+
+	res = issue_thinkpad_cmos_command(cmos_cmd);
+	return (res)? res : count;
+}
+
+static struct device_attribute dev_attr_cmos_command =
+	__ATTR(cmos_command, S_IWUSR, NULL, cmos_command_store);
+
+/* --------------------------------------------------------------------- */
+
 static int __init cmos_init(struct ibm_init_struct *iibm)
 {
+	int res;
+
 	vdbg_printk(TPACPI_DBG_INIT,
 		"initializing cmos commands subdriver\n");
 
@@ -1752,9 +1774,19 @@ static int __init cmos_init(struct ibm_init_struct *iibm)
 
 	vdbg_printk(TPACPI_DBG_INIT, "cmos commands are %s\n",
 		str_supported(cmos_handle != NULL));
+
+	res = device_create_file(&tpacpi_pdev->dev, &dev_attr_cmos_command);
+	if (res)
+		return res;
+
 	return (cmos_handle)? 0 : 1;
 }
 
+static void cmos_exit(void)
+{
+	device_remove_file(&tpacpi_pdev->dev, &dev_attr_cmos_command);
+}
+
 static int cmos_read(char *p)
 {
 	int len = 0;
@@ -1795,6 +1827,7 @@ static struct ibm_struct cmos_driver_data = {
 	.name = "cmos",
 	.read = cmos_read,
 	.write = cmos_write,
+	.exit = cmos_exit,
 };
 
 /*************************************************************************
-- 
1.5.2.rc0.34.gda94

  parent reply	other threads:[~2007-04-29  4:52 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-29  4:50 ACPI patches for 2.6.22 merge window Len Brown
     [not found] ` <11778223068-git-send-email-len.brown@intel.com>
     [not found]   ` <ac122bb64b0d51f0512185d3522a75f3f3a80bc9.1177822058.git.len.brown@intel.com>
2007-04-29  4:50     ` [PATCH 002/105] ACPI: EC: Don't use Global Lock if not asked to do so Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 003/105] ACPI: EC: Make EC to initialize first in ACPI Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 004/105] ACPI: EC: "Fake ECDT" workaround is not needed any longer Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 005/105] ACPI: EC: enable burst functionality in EC Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 006/105] ACPI: EC: Remove casts to/from void* from ec.c Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 007/105] ACPI: EC: Put install handlers into separate function Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 008/105] ACPI: EC: Clean ECDT and namespace parsing Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 009/105] ACPI: EC: Rename ec_ecdt to more informative boot_ec Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 010/105] ACPI: EC: first_ec is better to be acpi_ec than acpi_device Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 011/105] ACPI: EC: Cleanup of EC initialization Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 012/105] ACPI: EC: Block queries until EC is fully initialized Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 013/105] asus-laptop: use acpi_evaluate_integer instead of read_acpi_int Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 014/105] asus-laptop: clean write_status Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 015/105] asus-laptop: add GLED Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 016/105] asus-laptop: add wapf param Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 017/105] asus-laptop: version bump Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 018/105] ACPI: sbs: use EC rather than I2C Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 019/105] ACPI: sbs: remove I2C Kconfig dependency Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 020/105] ACPI: sbs: remove I2C Makefile hooks Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 021/105] ACPI: sbs: Debug messages correction/improvement Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 022/105] ACPI: sbs: Common interface with CM battery Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 023/105] ACPI: sbs: remove i2c_ec.[ch] Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 024/105] ACPI: ibm-acpi: kill trailing whitespace Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 025/105] ACPI: ibm-acpi: rename some identifiers Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 026/105] ACPI: ibm-acpi: add header file Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 027/105] ACPI: ibm-acpi: organize code Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 028/105] ACPI: ibm-acpi: update copyright notice Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 029/105] ACPI: ibm-acpi: update documentation Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 031/105] ACPI: dock: use NULL for pointer Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 033/105] ACPI: thinkpad-acpi: cleanup Kconfig for thinkpad-acpi Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 034/105] ACPI: thinkpad-acpi: add compatibility MODULE_ALIAS entry Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 035/105] ACPI: thinkpad-acpi: cleanup after rename Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 036/105] ACPI: thinkpad-acpi: update MAINTAINERS Len Brown
2007-04-29  4:50       ` Len Brown
     [not found]         ` <11778223411658-git-send-email-len.brown@intel.com>
     [not found]           ` <11778223412672-git-send-email-len.brown@intel.com>
     [not found]             ` <11778223423-git-send-email-len.brown@intel.com>
     [not found]               ` <1177822343712-git-send-email-len.brown@intel.com>
     [not found]                 ` <11778223442065-git-send-email-len.brown@intel.com>
     [not found]                   ` <11778223452843-git-send-email-len.brown@intel.com>
     [not found]                     ` <11778223461282-git-send-email-len.brown@intel.com>
     [not found]                       ` <11778223472316-git-send-email-len.brown@intel.com>
2007-04-29  4:50     ` [PATCH 046/105] ACPI: thinkpad-acpi: rename register_ibmacpi_subdriver Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 047/105] ACPI: thinkpad-acpi: rename one stray use of ibm-acpi in a comment Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 048/105] ACPI: thinkpad-acpi: rename module glue Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 049/105] ACPI: thinkpad-acpi: rename thinkpad constants Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 050/105] ACPI: thinkpad-acpi: update fan firmware documentation Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 051/105] ACPI: thinkpad-acpi: add debug mode Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 052/105] ACPI: thinkpad-acpi: clean up probing and move init to subdrivers Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 053/105] ACPI: thinkpad-acpi: add subdriver debug statements Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 054/105] ACPI: thinkpad-acpi: uncouple subdriver init from ibms struct Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 055/105] ACPI: thinkpad-acpi: improve thinkpad detection Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 056/105] ACPI: thinkpad-acpi: use bitfields to hold subdriver flags Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 057/105] ACPI: thinkpad-acpi: use bitfields for module flags Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 058/105] ACPI: thinkpad-acpi: prepare for device model conversion Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:50     ` [PATCH 059/105] ACPI: thinkpad-acpi: mark acpi helper functions __must_check Len Brown
2007-04-29  4:50       ` Len Brown
2007-04-29  4:51     ` [PATCH 060/105] ACPI: thinkpad-acpi: clean up hotkey subdriver Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 061/105] ACPI: thinkpad-acpi: cleanup bluetooth and wan for sysfs conversion Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 062/105] ACPI: thinkpad-acpi: cleanup video subdriver Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 063/105] ACPI: thinkpad-acpi: clean up CMOS commands subdriver Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 064/105] ACPI: thinkpad-acpi: cleanup thermal subdriver for sysfs conversion Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 065/105] ACPI: thinkpad-acpi: improve fan watchdog messages Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 066/105] ACPI: Disable MSI on request of FADT Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 067/105] ACPI: Improve acpi debug documentation Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 068/105] ACPI: thinkpad-acpi: register with the device model Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 069/105] ACPI: thinkpad-acpi: driver sysfs conversion Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 070/105] ACPI: thinkpad-acpi: add infrastructure for the sysfs device attributes Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 071/105] ACPI: thinkpad-acpi: protect fan and hotkey data structures Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 072/105] ACPI: thinkpad-acpi: add sysfs support to the thermal subdriver Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 073/105] ACPI: thinkpad-acpi: add sysfs support to fan subdriver Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 074/105] ACPI: thinkpad-acpi: add a safety net for TPEC fan control mode Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` Len Brown [this message]
2007-04-29  4:51       ` [PATCH 075/105] ACPI: thinkpad-acpi: add sysfs support to the cmos command subdriver Len Brown
2007-04-29  4:51     ` [PATCH 076/105] ACPI: thinkpad-acpi: update brightness sysfs interface support Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 077/105] ACPI: remove duplicate include Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 078/105] ACPI: Remove duplicate definitions for _STA bits Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 079/105] ACPI: use _STA bit names rather than 0x0F Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 080/105] ACPI: correct pathname in comment Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 081/105] ACPI: word-smith kconfig help Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 082/105] ACPI: make /proc/acpi/wakeup more useful Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 083/105] ACPI: prevent ACPI quirk warning mass spamming in logs Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  9:58         ` Andi Kleen
2007-04-29  4:51     ` [PATCH 084/105] ACPI: Remove a warning about unused variable in !CONFIG_ACPI compilation Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  9:59         ` Andi Kleen
2007-04-29  4:51     ` [PATCH 085/105] ACPICA: clear fields reserved before FADT r3 Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 086/105] ACPI: thinkpad-acpi: add a fan-control feature master toggle Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 087/105] ACPI: thinkpad-acpi: do not arm fan watchdog if it would not work Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 088/105] ACPI: thinkpad-acpi: fix a fan watchdog invocation Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 089/105] ACPI: thinkpad-acpi: map ENXIO to EINVAL for fan sysfs Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 090/105] ACPI: thinkpad-acpi: improve fan control documentation Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 091/105] ACPI: thinkpad-acpi: improve debugging for acpi helpers Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 092/105] ACPI: thinkpad-acpi: improve dock subdriver initialization Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 093/105] ACPI: thinkpad-acpi: add sysfs support to hotkey subdriver Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 094/105] ACPI: thinkpad-acpi: add sysfs support to wan and bluetooth subdrivers Len Brown
2007-04-29  4:51       ` Len Brown
2007-04-29  4:51     ` [PATCH 095/105] thinkpad-acpi: make drivers/misc/thinkpad_acpi:fan_mutex static Len Brown
2007-04-29  4:51       ` Len Brown
     [not found]         ` <11778223931192-git-send-email-len.brown@intel.com>
     [not found]           ` <11778223942367-git-send-email-len.brown@intel.com>
     [not found]             ` <11778223942377-git-send-email-len.brown@intel.com>
     [not found]               ` <1177822395384-git-send-email-len.brown@intel.com>
     [not found]                 ` <11778223963095-git-send-email-len.brown@intel.com>
     [not found]                   ` <11778223972558-git-send-email-len.brown@intel.com>
     [not found]                     ` <11778223981263-git-send-email-len.brown@intel.com>
     [not found]                       ` <117782239917-git-send-email-len.brown@intel.com>
2007-04-29  4:51     ` [PATCH 105/105] sonypi: use mutex instead of semaphore Len Brown
2007-04-29  4:51       ` Len Brown
2007-05-01  2:19 ` ACPI patches for 2.6.22 merge window Mattia Dongili
2007-05-10  6:44   ` Len Brown

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=11778223733679-git-send-email-len.brown@intel.com \
    --to=len.brown@intel.com \
    --cc=hmh@hmh.eng.br \
    --cc=linux-acpi@vger.kernel.org \
    /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.