kernel-ark/drivers/acpi
Yi Yang 6594d87ebd ACPI: fix acpi fan state set error
Under /proc/acpi, there is a fan control interface, a user can
set 0 or 3 to /proc/acpi/fan/*/state, 0 denotes D0 state, 3
denotes D3 state, but in current implementation, a user can
set a fan to D1 state by any char excluding '1', '2' and '3'.

For example:

[root@localhost acpi]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost acpi]# echo "" > /proc/acpi/fan/C31B/state
[root@localhost acpi]# cat /proc/acpi/fan/C31B/state
status:                  on
[root@localhost acpi]# echo "3" > /proc/acpi/fan/C31B/state
[root@localhost acpi]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost acpi]# echo "xxxxx" > /proc/acpi/fan/C31B/state
[root@localhost acpi]# cat /proc/acpi/fan/C31B/state
status:                  on

Obviously, such inputs as "" and "xxxxx" are invalid for fan state.

This patch fixes this issue, it strictly limits fan state only to
accept 0, 1, 2 and 3, any other inputs are invalid.

Before applying this patch, the test result is:

[root@localhost acpi]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost acpi]# echo "" > /proc/acpi/fan/C31B/state
[root@localhost acpi]# cat /proc/acpi/fan/C31B/state
status:                  on
[root@localhost acpi]# echo "3" > /proc/acpi/fan/C31B/state
[root@localhost acpi]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost acpi]# echo "xxxxx" > /proc/acpi/fan/C31B/state
[root@localhost acpi]# cat /proc/acpi/fan/C31B/state
status:                  on
[root@localhost acpi]# echo "3" > /proc/acpi/fan/C31B/state
[root@localhost acpi]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost acpi]# echo "3x" > /proc/acpi/fan/C31B/state
[root@localhost acpi]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost acpi]# echo "-1x" > /proc/acpi/fan/C31B/state
[root@localhost acpi]# cat /proc/acpi/fan/C31B/state
status:                  on
[root@localhost acpi]#

After applying this patch, the test result is:

[root@localhost ~]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost ~]# echo "" > /proc/acpi/fan/C31B/state
-bash: echo: write error: Invalid argument
[root@localhost ~]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost ~]# echo "3" > /proc/acpi/fan/C31B/state
[root@localhost ~]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost ~]# echo "xxxxx" > /proc/acpi/fan/C31B/state
-bash: echo: write error: Invalid argument
[root@localhost ~]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost ~]# echo "-1x" > /proc/acpi/fan/C31B/state
-bash: echo: write error: Invalid argument
[root@localhost ~]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost ~]# echo "0" > //proc/acpi/fan/C31B/state
[root@localhost ~]# cat /proc/acpi/fan/C31B/state
status:                  on
[root@localhost ~]# echo "4" > //proc/acpi/fan/C31B/state
-bash: echo: write error: Invalid argument
[root@localhost ~]# cat /proc/acpi/fan/C31B/state
status:                  on
[root@localhost ~]# echo "3" > //proc/acpi/fan/C31B/state
[root@localhost ~]# cat /proc/acpi/fan/C31B/state
status:                  off
[root@localhost ~]# echo "0" > //proc/acpi/fan/C31B/state
[root@localhost ~]# cat /proc/acpi/fan/C31B/state
status:                  on
[root@localhost ~]# echo "3x" > //proc/acpi/fan/C31B/state
-bash: echo: write error: Invalid argument
[root@localhost ~]#

Signed-off-by: Yi Yang <yi.y.yang@intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
2008-07-16 23:27:01 +02:00
..
dispatcher ACPICA: Fix to allow zero-length ASL field declarations 2008-06-11 19:13:47 -04:00
events Merge branches 'release', 'acpica', 'bugzilla-10224', 'bugzilla-9772', 'bugzilla-9916', 'ec', 'eeepc', 'idle', 'misc', 'pm-legacy', 'sysfs-links-2.6.26', 'thermal', 'thinkpad' and 'video' into release 2008-04-30 13:58:00 -04:00
executer ACPICA: Fix for Load operator, load table at the namespace root 2008-06-11 19:13:47 -04:00
hardware ACPICA: Fix to make _SST method optional 2008-06-11 19:13:47 -04:00
namespace ACPICA: update Intel copyright 2008-04-23 23:00:13 -04:00
parser ACPICA: Fix for access to deleted object <regression> 2008-06-11 19:13:47 -04:00
resources ACPICA: update Intel copyright 2008-04-23 23:00:13 -04:00
sleep x86 ACPI: normalize segment descriptor register on resume 2008-07-05 08:25:40 +02:00
tables ACPICA: Ignore ACPI table signature for Load() operator 2008-06-11 19:13:47 -04:00
utilities ACPICA: fix stray va_end() caused by mis-merge 2008-06-11 19:13:47 -04:00
ac.c ACPI: no AC status notification 2008-06-14 01:26:37 -04:00
acpi_memhotplug.c
asus_acpi.c asus_acpi: remove misleading mask 2008-03-18 02:31:34 -04:00
battery.c acpi: use non-racy method for proc entries creation 2008-04-29 08:06:22 -07:00
bay.c dock: bay: Don't call acpi_walk_namespace() when ACPI is disabled. 2008-06-26 01:55:27 -04:00
blacklist.c ACPI: DMI: quirk for FSC ESPRIMO Mobile V5505 2008-02-14 02:43:39 -05:00
bus.c x86: validate against acpi motherboard resources 2008-04-26 23:41:03 +02:00
button.c acpi: use non-racy method for proc entries creation 2008-04-29 08:06:22 -07:00
cm_sbs.c
container.c
debug.c
dock.c dock: bay: Don't call acpi_walk_namespace() when ACPI is disabled. 2008-06-26 01:55:27 -04:00
ec.c ACPI: EC: Use msleep instead of udelay while waiting for event. 2008-06-11 19:13:45 -04:00
event.c acpi: use non-racy method for proc entries creation 2008-04-29 08:06:22 -07:00
fan.c ACPI: fix acpi fan state set error 2008-07-16 23:27:01 +02:00
glue.c ACPI: don't walk tables if ACPI was disabled 2008-06-26 01:55:18 -04:00
Kconfig x86, VisWS: turn into generic arch, eliminate Kconfig specials 2008-07-10 18:55:47 +02:00
Makefile ACPI: SBS: Host controller must initialize before SBS. 2008-02-09 03:22:13 -05:00
numa.c ACPI: handle invalid ACPI SLIT table 2008-06-11 19:13:46 -04:00
osl.c flush kacpi_notify_wq before removing notify handler 2008-04-29 02:34:42 -04:00
pci_bind.c ACPI: misc cleanups 2008-02-07 03:33:23 -05:00
pci_irq.c Revert parts of "x86: update mptable" 2008-07-08 11:08:42 +02:00
pci_link.c ACPI: misc cleanups 2008-02-07 03:33:23 -05:00
pci_root.c ACPI: fix section mismatch in acpi_pci_root_add 2008-02-21 02:56:32 -05:00
power.c Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2008-04-30 11:52:52 -07:00
processor_core.c ACPI: change processors from array to per_cpu variable 2008-07-16 23:27:01 +02:00
processor_idle.c ACPI: change processors from array to per_cpu variable 2008-07-16 23:27:01 +02:00
processor_perflib.c ACPI: change processors from array to per_cpu variable 2008-07-16 23:27:01 +02:00
processor_thermal.c acpi: use non-racy method for proc entries creation 2008-04-29 08:06:22 -07:00
processor_throttling.c ACPI: change processors from array to per_cpu variable 2008-07-16 23:27:01 +02:00
sbs.c acpi: use non-racy method for proc entries creation 2008-04-29 08:06:22 -07:00
sbshc.c ACPI: SBS: remove typo from sbchc.c 2008-03-18 05:13:14 -04:00
sbshc.h
scan.c ACPI: fix checkpatch.pl complaints in scan.c 2008-07-16 23:27:01 +02:00
system.c ACPI: use memory_read_from_buffer() 2008-06-11 19:13:47 -04:00
tables.c
thermal.c ACPI: Reject below-freezing temperatures as invalid critical temperatures 2008-06-11 19:13:47 -04:00
toshiba_acpi.c toshiba_acpi: Enable autoloading 2008-03-11 13:35:08 -04:00
utils.c ACPICA: Fixes for external Reference Objects 2008-04-22 19:08:51 -04:00
video.c ACPI Exception (video-1721): UNKNOWN_STATUS_CODE, Cant attach device 2008-06-14 01:01:18 -04:00
wmi.c ACPI: WMI: Clean up handling of spec violating data blocks 2008-03-11 17:59:05 -04:00