mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 08:31:55 +00:00
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>
This commit is contained in:
parent
6b188a7b21
commit
463b4e474e
@ -118,14 +118,14 @@ static const char *cm_setv[] = {
|
|||||||
NULL, NULL, "PBPS", "TPDS"
|
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
|
* 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)
|
static int eeepc_get_fan_pwm(void)
|
||||||
{
|
{
|
||||||
int value = 0;
|
u8 value = 0;
|
||||||
|
|
||||||
read_acpi_int(NULL, EEEPC_EC_FAN_PWM, &value);
|
ec_read(EEEPC_EC_FAN_PWM, &value);
|
||||||
value = value * 255 / 100;
|
return value * 255 / 100;
|
||||||
return (value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void eeepc_set_fan_pwm(int value)
|
static void eeepc_set_fan_pwm(int value)
|
||||||
{
|
{
|
||||||
value = SENSORS_LIMIT(value, 0, 255);
|
value = SENSORS_LIMIT(value, 0, 255);
|
||||||
value = value * 100 / 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)
|
static int eeepc_get_fan_rpm(void)
|
||||||
{
|
{
|
||||||
int high = 0;
|
u8 high = 0;
|
||||||
int low = 0;
|
u8 low = 0;
|
||||||
|
|
||||||
read_acpi_int(NULL, EEEPC_EC_FAN_HRPM, &high);
|
ec_read(EEEPC_EC_FAN_HRPM, &high);
|
||||||
read_acpi_int(NULL, EEEPC_EC_FAN_LRPM, &low);
|
ec_read(EEEPC_EC_FAN_LRPM, &low);
|
||||||
return (high << 8 | low);
|
return high << 8 | low;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int eeepc_get_fan_ctrl(void)
|
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)
|
if (value & 0x02)
|
||||||
return 1; /* manual */
|
return 1; /* manual */
|
||||||
else
|
else
|
||||||
@ -940,14 +939,14 @@ static int eeepc_get_fan_ctrl(void)
|
|||||||
|
|
||||||
static void eeepc_set_fan_ctrl(int manual)
|
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)
|
if (manual == 1)
|
||||||
value |= 0x02;
|
value |= 0x02;
|
||||||
else
|
else
|
||||||
value &= ~0x02;
|
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)
|
static ssize_t store_sys_hwmon(void (*set)(int), const char *buf, size_t count)
|
||||||
|
Loading…
Reference in New Issue
Block a user