aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/eeepc-laptop.c
diff options
context:
space:
mode:
authorAlan Jenkins <alan-jenkins@tuffmail.co.uk>2009-12-03 02:45:03 -0500
committerLen Brown <len.brown@intel.com>2009-12-09 15:54:32 -0500
commit463b4e474ed0905ffc27ee347648739dbfb03acc (patch)
treea707fc29971b1217ce52810e69abe84375105ce1 /drivers/platform/x86/eeepc-laptop.c
parent6b188a7b218cb33d918e72f24995341f949297d2 (diff)
eeepc-laptop: simplify how the hwmon device reads values from the EC
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>
Diffstat (limited to 'drivers/platform/x86/eeepc-laptop.c')
-rw-r--r--drivers/platform/x86/eeepc-laptop.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 50ceaaf411c2..04a59d3bcad2 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -118,14 +118,14 @@ static const char *cm_setv[] = {
118 NULL, NULL, "PBPS", "TPDS" 118 NULL, NULL, "PBPS", "TPDS"
119}; 119};
120 120
121#define EEEPC_EC "\\_SB.PCI0.SBRG.EC0." 121#define EEEPC_EC_SC00 0x61
122#define EEEPC_EC_FAN_PWM (EEEPC_EC_SC00 + 2) /* Fan PWM duty cycle (%) */
123#define EEEPC_EC_FAN_HRPM (EEEPC_EC_SC00 + 5) /* High byte, fan speed (RPM) */
124#define EEEPC_EC_FAN_LRPM (EEEPC_EC_SC00 + 6) /* Low byte, fan speed (RPM) */
125
126#define EEEPC_EC_SFB0 0xD0
127#define EEEPC_EC_FAN_CTRL (EEEPC_EC_SFB0 + 3) /* Byte containing SF25 */
122 128
123#define EEEPC_EC_FAN_PWM EEEPC_EC "SC02" /* Fan PWM duty cycle (%) */
124#define EEEPC_EC_SC02 0x63
125#define EEEPC_EC_FAN_HRPM EEEPC_EC "SC05" /* High byte, fan speed (RPM) */
126#define EEEPC_EC_FAN_LRPM EEEPC_EC "SC06" /* Low byte, fan speed (RPM) */
127#define EEEPC_EC_FAN_CTRL EEEPC_EC "SFB3" /* Byte containing SF25 */
128#define EEEPC_EC_SFB3 0xD3
129 129
130/* 130/*
131 * This is the main structure, we can use it to store useful information 131 * 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)
903 */ 903 */
904static int eeepc_get_fan_pwm(void) 904static int eeepc_get_fan_pwm(void)
905{ 905{
906 int value = 0; 906 u8 value = 0;
907 907
908 read_acpi_int(NULL, EEEPC_EC_FAN_PWM, &value); 908 ec_read(EEEPC_EC_FAN_PWM, &value);
909 value = value * 255 / 100; 909 return value * 255 / 100;
910 return (value);
911} 910}
912 911
913static void eeepc_set_fan_pwm(int value) 912static void eeepc_set_fan_pwm(int value)
914{ 913{
915 value = SENSORS_LIMIT(value, 0, 255); 914 value = SENSORS_LIMIT(value, 0, 255);
916 value = value * 100 / 255; 915 value = value * 100 / 255;
917 ec_write(EEEPC_EC_SC02, value); 916 ec_write(EEEPC_EC_FAN_PWM, value);
918} 917}
919 918
920static int eeepc_get_fan_rpm(void) 919static int eeepc_get_fan_rpm(void)
921{ 920{
922 int high = 0; 921 u8 high = 0;
923 int low = 0; 922 u8 low = 0;
924 923
925 read_acpi_int(NULL, EEEPC_EC_FAN_HRPM, &high); 924 ec_read(EEEPC_EC_FAN_HRPM, &high);
926 read_acpi_int(NULL, EEEPC_EC_FAN_LRPM, &low); 925 ec_read(EEEPC_EC_FAN_LRPM, &low);
927 return (high << 8 | low); 926 return high << 8 | low;
928} 927}
929 928
930static int eeepc_get_fan_ctrl(void) 929static int eeepc_get_fan_ctrl(void)
931{ 930{
932 int value = 0; 931 u8 value = 0;
933 932
934 read_acpi_int(NULL, EEEPC_EC_FAN_CTRL, &value); 933 ec_read(EEEPC_EC_FAN_CTRL, &value);
935 if (value & 0x02) 934 if (value & 0x02)
936 return 1; /* manual */ 935 return 1; /* manual */
937 else 936 else
@@ -940,14 +939,14 @@ static int eeepc_get_fan_ctrl(void)
940 939
941static void eeepc_set_fan_ctrl(int manual) 940static void eeepc_set_fan_ctrl(int manual)
942{ 941{
943 int value = 0; 942 u8 value = 0;
944 943
945 read_acpi_int(NULL, EEEPC_EC_FAN_CTRL, &value); 944 ec_read(EEEPC_EC_FAN_CTRL, &value);
946 if (manual == 1) 945 if (manual == 1)
947 value |= 0x02; 946 value |= 0x02;
948 else 947 else
949 value &= ~0x02; 948 value &= ~0x02;
950 ec_write(EEEPC_EC_SFB3, value); 949 ec_write(EEEPC_EC_FAN_CTRL, value);
951} 950}
952 951
953static ssize_t store_sys_hwmon(void (*set)(int), const char *buf, size_t count) 952static ssize_t store_sys_hwmon(void (*set)(int), const char *buf, size_t count)