public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
From: Len Brown <lenb@kernel.org>
To: linux-acpi@vger.kernel.org
Cc: Alan Jenkins <alan-jenkins@tuffmail.co.uk>,
	Len Brown <len.brown@intel.com>
Subject: [PATCH 036/103] eeepc-laptop: simplify how the hwmon device reads values from the EC
Date: Wed, 16 Dec 2009 03:35:47 -0500	[thread overview]
Message-ID: <463b4e474ed0905ffc27ee347648739dbfb03acc.1260952472.git.len.brown@intel.com> (raw)
In-Reply-To: <1260952614-3152-1-git-send-email-lenb@kernel.org>
In-Reply-To: <5f46c2f25cfbb5faca7550738ac42c4d1491ddc8.1260952471.git.len.brown@intel.com>

From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>

The hwmon device uses ec_write() to write values to the EC.  So for
consistency it should use ec_read() to read values.  The extra layers
of indirection used did not add any value.

This may mean we no longer take the ACPI global lock for such reads
(if the EC operation region requires the lock and the EC does not).
But there is no point locking each one-byte read individually, when
write operations do not use the lock at all.

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Len Brown <len.brown@intel.com>
---
 drivers/platform/x86/eeepc-laptop.c |   43 +++++++++++++++++------------------
 1 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 50ceaaf..04a59d3 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -118,14 +118,14 @@ static const char *cm_setv[] = {
 	NULL, NULL, "PBPS", "TPDS"
 };
 
-#define EEEPC_EC	"\\_SB.PCI0.SBRG.EC0."
+#define EEEPC_EC_SC00      0x61
+#define EEEPC_EC_FAN_PWM   (EEEPC_EC_SC00 + 2) /* Fan PWM duty cycle (%) */
+#define EEEPC_EC_FAN_HRPM  (EEEPC_EC_SC00 + 5) /* High byte, fan speed (RPM) */
+#define EEEPC_EC_FAN_LRPM  (EEEPC_EC_SC00 + 6) /* Low byte, fan speed (RPM) */
+
+#define EEEPC_EC_SFB0      0xD0
+#define EEEPC_EC_FAN_CTRL  (EEEPC_EC_SFB0 + 3) /* Byte containing SF25  */
 
-#define EEEPC_EC_FAN_PWM	EEEPC_EC "SC02" /* Fan PWM duty cycle (%) */
-#define EEEPC_EC_SC02		0x63
-#define EEEPC_EC_FAN_HRPM	EEEPC_EC "SC05" /* High byte, fan speed (RPM) */
-#define EEEPC_EC_FAN_LRPM	EEEPC_EC "SC06" /* Low byte, fan speed (RPM) */
-#define EEEPC_EC_FAN_CTRL	EEEPC_EC "SFB3" /* Byte containing SF25  */
-#define EEEPC_EC_SFB3		0xD3
 
 /*
  * This is the main structure, we can use it to store useful information
@@ -903,35 +903,34 @@ static int eeepc_hotk_restore(struct device *device)
  */
 static int eeepc_get_fan_pwm(void)
 {
-	int value = 0;
+	u8 value = 0;
 
-	read_acpi_int(NULL, EEEPC_EC_FAN_PWM, &value);
-	value = value * 255 / 100;
-	return (value);
+	ec_read(EEEPC_EC_FAN_PWM, &value);
+	return value * 255 / 100;
 }
 
 static void eeepc_set_fan_pwm(int value)
 {
 	value = SENSORS_LIMIT(value, 0, 255);
 	value = value * 100 / 255;
-	ec_write(EEEPC_EC_SC02, value);
+	ec_write(EEEPC_EC_FAN_PWM, value);
 }
 
 static int eeepc_get_fan_rpm(void)
 {
-	int high = 0;
-	int low = 0;
+	u8 high = 0;
+	u8 low = 0;
 
-	read_acpi_int(NULL, EEEPC_EC_FAN_HRPM, &high);
-	read_acpi_int(NULL, EEEPC_EC_FAN_LRPM, &low);
-	return (high << 8 | low);
+	ec_read(EEEPC_EC_FAN_HRPM, &high);
+	ec_read(EEEPC_EC_FAN_LRPM, &low);
+	return high << 8 | low;
 }
 
 static int eeepc_get_fan_ctrl(void)
 {
-	int value = 0;
+	u8 value = 0;
 
-	read_acpi_int(NULL, EEEPC_EC_FAN_CTRL, &value);
+	ec_read(EEEPC_EC_FAN_CTRL, &value);
 	if (value & 0x02)
 		return 1; /* manual */
 	else
@@ -940,14 +939,14 @@ static int eeepc_get_fan_ctrl(void)
 
 static void eeepc_set_fan_ctrl(int manual)
 {
-	int value = 0;
+	u8 value = 0;
 
-	read_acpi_int(NULL, EEEPC_EC_FAN_CTRL, &value);
+	ec_read(EEEPC_EC_FAN_CTRL, &value);
 	if (manual == 1)
 		value |= 0x02;
 	else
 		value &= ~0x02;
-	ec_write(EEEPC_EC_SFB3, value);
+	ec_write(EEEPC_EC_FAN_CTRL, value);
 }
 
 static ssize_t store_sys_hwmon(void (*set)(int), const char *buf, size_t count)
-- 
1.6.0.6


  parent reply	other threads:[~2009-12-16 10:06 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-16  8:35 ACPI & platform driver patches for 2.6.33.merge Len Brown
2009-12-16  8:35 ` [PATCH 001/103] ACPI: dock: convert sysfs attributes to an attribute_group Len Brown
2009-12-16  8:35   ` [PATCH 002/103] wmi: Add support for module autoloading Len Brown
2009-12-16  8:35   ` [PATCH 003/103] acpi: thermal: display forced passive trip points in proc Len Brown
2009-12-16  8:35   ` [PATCH 004/103] thermal: add sanity check for the passive attribute Len Brown
2009-12-16  8:35   ` [PATCH 005/103] thermal: Only set passive_delay for forced_passive cooling Len Brown
2009-12-16  8:35   ` [PATCH 006/103] thermal: disable polling if passive_delay and polling_delay are both unset Len Brown
2009-12-16  8:35   ` [PATCH 007/103] ACPI: Notify the _PPC evaluation status to the platform Len Brown
2009-12-16  8:35   ` [PATCH 008/103] ACPI: add const to acpi_check_resource_conflict() Len Brown
2009-12-16  8:35   ` [PATCH 009/103] thinkpad-acpi: fix default brightness_mode for R50e/R51 Len Brown
2009-12-16  8:35   ` [PATCH 010/103] thinkpad-acpi: preserve rfkill state across suspend/resume Len Brown
2009-12-16  8:35   ` [PATCH 011/103] thinkpad-acpi: fix some version quirks Len Brown
2009-12-16  8:35   ` [PATCH 012/103] thinkpad-acpi: issue backlight class events Len Brown
2009-12-16  8:35   ` [PATCH 013/103] thinkpad-acpi: silence bogus complain during rmmod Len Brown
2009-12-16  8:35   ` [PATCH 014/103] thinkpad-acpi: adopt input device Len Brown
2009-12-16  8:35   ` [PATCH 015/103] thinkpad-acpi: expose module parameters Len Brown
2009-12-16  8:35   ` [PATCH 016/103] thinkpad-acpi: log temperatures on termal alarm (v2) Len Brown
2009-12-16  8:35   ` [PATCH 017/103] thinkpad-acpi: use input_set_capability Len Brown
2009-12-16  8:35   ` [PATCH 018/103] eeepc-laptop: disp attribute should be write-only Len Brown
2009-12-16  8:35   ` [PATCH 019/103] asus-laptop: Remove redundant NULL checks Len Brown
2009-12-16  8:35   ` [PATCH 020/103] asus-acpi: " Len Brown
2009-12-16  8:35   ` [PATCH 021/103] asus-laptop: Remove uneccesary acpi_disabled check Len Brown
2009-12-16  8:35   ` [PATCH 022/103] asus-acpi: Remove uneccesary acpi_disabled checks Len Brown
2009-12-16  8:35   ` [PATCH 023/103] asus-acpi: set acpi_driver.owner Len Brown
2009-12-16  8:35   ` [PATCH 024/103] asus-laptop: " Len Brown
2009-12-16  8:35   ` [PATCH 025/103] eeepc-laptop: add touchpad led Len Brown
2009-12-16  8:35   ` [PATCH 026/103] eeepc-laptop: Remove redundant NULL checks Len Brown
2009-12-16  8:35   ` [PATCH 027/103] eeepc-laptop: Remove uneccesary acpi_disabled check Len Brown
2009-12-16  8:35   ` [PATCH 028/103] eeepc-laptop: set acpi_driver.owner Len Brown
2009-12-16  8:35   ` [PATCH 029/103] eeepc-laptop: fix value of pwm1_enable to match documentation Len Brown
2009-12-16  8:35   ` [PATCH 030/103] eeepc-laptop: fix led initialization order Len Brown
2009-12-16  8:35   ` [PATCH 031/103] eeepc-laptop: fix potential leak (led_init() failure) Len Brown
2009-12-16  8:35   ` [PATCH 032/103] eeepc-laptop: fix set_acpi() to return non-zero on failure Len Brown
2009-12-16  8:35   ` [PATCH 033/103] eeepc-laptop: remove redundant NULL checks Len Brown
2009-12-16  8:35   ` [PATCH 034/103] eeepc-laptop: no need to check argument of set_brightness() Len Brown
2009-12-16  8:35   ` [PATCH 035/103] eeepc-laptop: simplify acpi initialization Len Brown
2009-12-16  8:35   ` Len Brown [this message]
2009-12-16  8:35   ` [PATCH 037/103] eeepc-laptop: refactor notifications Len Brown
2009-12-16  8:35   ` [PATCH 038/103] eeepc-laptop: move platform driver registration out of eeepc_hotk_add() Len Brown
2009-12-16  8:35   ` [PATCH 039/103] eeepc-laptop: move platform device initialisation to a separate function Len Brown
2009-12-16  8:35   ` [PATCH 040/103] eeepc-laptop: code movement Len Brown
2009-12-16  8:35   ` [PATCH 041/103] eeepc-laptop: revise names Len Brown
2009-12-16  8:35   ` [PATCH 042/103] eeepc-laptop: callbacks should use "driver data" parameter or field Len Brown
2009-12-16  8:35   ` [PATCH 043/103] asus-laptop: use KEY_F13 to map "Disable Touchpad" event Len Brown
2009-12-16  8:35   ` [PATCH 044/103] asus-laptop: add Lenovo SL hotkey support Len Brown
2009-12-16  8:35   ` [PATCH 045/103] asus-laptop: Add wlan switch found on V6V Len Brown
2009-12-16  8:35   ` [PATCH 046/103] eeepc-laptop: map keys found on newer eeepc Len Brown
2009-12-16  8:35   ` [PATCH 047/103] eeepc-laptop: fix coding style Len Brown
2009-12-16  8:35   ` [PATCH 048/103] eeepc-laptop: re-add check for eeepc->backlight == NULL Len Brown
2009-12-16  8:36   ` [PATCH 049/103] asus-laptop: schedule display_get and lcd_switch for removal Len Brown
2009-12-16  8:36   ` [PATCH 050/103] hp-wmi: improve rfkill support Len Brown
2009-12-16  8:36   ` [PATCH 051/103] dell-laptop: Fix rfkill state queries Len Brown
2009-12-16  8:36   ` [PATCH 052/103] dell-laptop: fix a use-after-free error on the failure path Len Brown
2009-12-16  8:36   ` [PATCH 053/103] dell-laptop: fix rfkill memory leak on unload and failure paths Len Brown
2009-12-16  8:36   ` [PATCH 054/103] dell-laptop: create a platform device as a parent for the rfkill devices etc Len Brown
2009-12-16  8:36   ` [PATCH 055/103] dell-laptop: add __init to init functions Len Brown
2009-12-16  8:36   ` [PATCH 056/103] dell-laptop: remove duplicate Kconfig entry under drivers/misc Len Brown
2009-12-16  8:36   ` [PATCH 057/103] dell-wmi: Add support for new Dell systems Len Brown
2009-12-16  8:36   ` [PATCH 058/103] PNPACPI: save struct acpi_device, not just acpi_handle Len Brown
2009-12-16  8:36   ` [PATCH 059/103] ACPI: support customizing ACPI control methods at runtime Len Brown
2009-12-16  8:36   ` [PATCH 060/103] ACPI: Use the ARB_DISABLE for the CPU which model id is less than 0x0f Len Brown
2009-12-16  8:36   ` [PATCH 061/103] ACPICA: Fix possible memory leak for module-level code execution Len Brown
2009-12-16  8:36   ` [PATCH 062/103] ACPICA: Fix two Scope type error messages Len Brown
2009-12-16  8:36   ` [PATCH 063/103] ACPICA: Fix two additional Scope override " Len Brown
2009-12-16  8:36   ` [PATCH 064/103] ACPICA: Add repair for bad _FDE/_GTM buffers Len Brown
2009-12-16  8:36   ` [PATCH 065/103] ACPICA: Update internal namespace node/handle interfaces Len Brown
2009-12-16  8:36   ` [PATCH 066/103] ACPICA: Add more conversions to predefined name repair module Len Brown
2009-12-16  8:36   ` [PATCH 067/103] ACPICA: Update function headers, no functional change Len Brown
2009-12-16  8:36   ` [PATCH 068/103] ACPICA: Fix mutex errors when running _REG methods Len Brown
2009-12-16  8:36   ` [PATCH 069/103] ACPICA: Move Package-to-Buffer repair code into common ToBuffer function Len Brown
2009-12-16  8:36   ` [PATCH 070/103] ACPICA: Remove messages if predefined repair(s) are successful Len Brown
2009-12-16  8:36   ` [PATCH 071/103] ACPICA: Update function headers and comments, no functional change Len Brown
2009-12-16  8:36   ` [PATCH 072/103] ACPICA: Conditionally perform complex per-predefined-name repairs Len Brown
2009-12-16  8:36   ` [PATCH 073/103] ACPICA: Module-level code: enable _REG execution in same scope Len Brown
2009-12-16  8:36   ` [PATCH 074/103] ACPICA: Predefined name repair: automatically remove null package elements Len Brown
2009-12-16  8:36   ` [PATCH 075/103] ACPICA: Move check for valid Thread ID structure Len Brown
2009-12-16  8:36   ` [PATCH 076/103] ACPICA: Update version to 20091214 Len Brown
2009-12-16  8:36   ` [PATCH 077/103] PNP: add interface to retrieve ACPI device from a PNPACPI device Len Brown
2009-12-16  8:36   ` [PATCH 078/103] ipmi: remove unused PCI probe code Len Brown
2009-12-16  8:36   ` [PATCH 079/103] ipmi: refer to table as "SPMI", not "ACPI" Len Brown
2009-12-16  8:36   ` [PATCH 080/103] ipmi: add PNP discovery (ACPI namespace via PNPACPI) Len Brown
2009-12-16  8:36   ` [PATCH 081/103] asus-laptop: change light sens default values Len Brown
2009-12-16  8:36   ` [PATCH 082/103] ACPI: add kernel tainting after overriding an ACPI control method Len Brown
2009-12-16  8:36   ` [PATCH 083/103] thinkpad-acpi: sync input device EV_SW initial state Len Brown
2009-12-16  8:36   ` [PATCH 084/103] thinkpad-acpi: log initial state of rfkill switches Len Brown
2009-12-16  8:36   ` [PATCH 085/103] thinkpad-acpi: volume subdriver rewrite Len Brown
2009-12-16  8:36   ` [PATCH 086/103] thinkpad-acpi: support MUTE-only ThinkPads Len Brown
2009-12-16  8:36   ` [PATCH 087/103] thinkpad-acpi: disable volume control Len Brown
2009-12-16  8:36   ` [PATCH 088/103] thinkpad-acpi: basic ALSA mixer support (v2) Len Brown
2009-12-16  8:36   ` [PATCH 089/103] thinkpad-acpi: convert to seq_file Len Brown
2009-12-16  8:36   ` [PATCH 090/103] thinkpad-acpi: bump version to 0.24 Len Brown
2009-12-16  8:36   ` [PATCH 091/103] ACPI: Remove repeated registered as cooling_device messages Len Brown
2009-12-16  8:36   ` [PATCH 092/103] thermal: Fix test of unsigned in thermal_cooling_device_cur_state_store() Len Brown
2009-12-16  8:36   ` [PATCH 093/103] battery: fix typo in comment Len Brown
2009-12-16  8:36   ` [PATCH 094/103] ACPI: Use the return result of ACPI lid notifier chain correctly Len Brown
2009-12-16  8:36   ` [PATCH 095/103] ACPI: remove NID_INVAL Len Brown
2009-12-16  8:36   ` [PATCH 096/103] acpi: thermal: display forced passive trip points in proc Len Brown
2009-12-16  8:36   ` [PATCH 097/103] acerhdf: add new BIOS versions Len Brown
2009-12-16  8:36   ` [PATCH 098/103] ACPI: dock: combine add|alloc_dock_dependent_device (v2) Len Brown
2009-12-16  8:36   ` [PATCH 099/103] ACPI: dock: remove global 'dock_device_name' Len Brown
2009-12-16  8:36   ` [PATCH 100/103] ACPI: dock: dock_add - hoist up platform_device_register_simple() Len Brown
2009-12-16  8:36   ` [PATCH 101/103] ACPI: dock: add struct dock_station * directly to platform device data Len Brown
2009-12-16  8:36   ` [PATCH 102/103] ACPI: dock: minor whitespace and style cleanups Len Brown
2009-12-16  8:36   ` [PATCH 103/103] acpi_pad: squish warning Len Brown
2009-12-16 14:20 ` ACPI & platform driver patches for 2.6.33.merge Mattia Dongili

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=463b4e474ed0905ffc27ee347648739dbfb03acc.1260952472.git.len.brown@intel.com \
    --to=lenb@kernel.org \
    --cc=alan-jenkins@tuffmail.co.uk \
    --cc=len.brown@intel.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox