mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-19 11:19:31 +00:00
Use inline functions instead of macros. Macros evaluating their
arguments more than once are evil. Backport from Linux 2.6. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5372 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
a8acdd0d88
commit
f89d47e4f2
2 files changed
+21
-13
No files matched your search
@@ -14,6 +14,7 @@ SVN-HEAD
|
||||
Module i2c-viapro: Add VX800/VX820 support (2.6 backport)
|
||||
Module lm78: Prevent misdetection of Winbond chips
|
||||
Module lm90: Don't spam the kernel log (2.6 backport)
|
||||
Module max1619: Use inline functions instead of macros (2.6 backport)
|
||||
Program pwmconfig: Fix MINSTOP and MINSTART test functions (#2340)
|
||||
Change default for MINTEMP from 0 to 20 degrees C
|
||||
Program sensord: Add it8720 support
|
||||
|
||||
+20
-13
@@ -73,11 +73,18 @@ SENSORS_INSMOD_1(max1619);
|
||||
#define MAX1619_REG_R_CHIP_ID 0xFF
|
||||
|
||||
/*
|
||||
* Conversions and various macros
|
||||
* Conversions
|
||||
*/
|
||||
|
||||
#define TEMP_FROM_REG(val) ((val) & 0x80 ? (val)-0x100 : (val))
|
||||
#define TEMP_TO_REG(val) ((val) < 0 ? (val)+0x100 : (val))
|
||||
static int temp_from_reg(int val)
|
||||
{
|
||||
return val & 0x80 ? val-0x100 : val;
|
||||
}
|
||||
|
||||
static int temp_to_reg(int val)
|
||||
{
|
||||
return val < 0 ? val+0x100 : val;
|
||||
}
|
||||
|
||||
/*
|
||||
* Functions declaration
|
||||
@@ -397,7 +404,7 @@ static void max1619_local_temp(struct i2c_client *client, int operation,
|
||||
*nrels_mag = 0; /* magnitude */
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
max1619_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->local_temp);
|
||||
results[0] = temp_from_reg(data->local_temp);
|
||||
*nrels_mag = 1;
|
||||
}
|
||||
|
||||
@@ -412,18 +419,18 @@ static void max1619_remote_temp(struct i2c_client *client, int operation,
|
||||
*nrels_mag = 0; /* magnitude */
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
max1619_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->remote_high);
|
||||
results[1] = TEMP_FROM_REG(data->remote_low);
|
||||
results[2] = TEMP_FROM_REG(data->remote_temp);
|
||||
results[0] = temp_from_reg(data->remote_high);
|
||||
results[1] = temp_from_reg(data->remote_low);
|
||||
results[2] = temp_from_reg(data->remote_temp);
|
||||
*nrels_mag = 3;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->remote_high = TEMP_TO_REG(results[0]);
|
||||
data->remote_high = temp_to_reg(results[0]);
|
||||
i2c_smbus_write_byte_data(client,
|
||||
MAX1619_REG_W_REMOTE_THIGH, data->remote_high);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->remote_low = TEMP_TO_REG(results[1]);
|
||||
data->remote_low = temp_to_reg(results[1]);
|
||||
i2c_smbus_write_byte_data(client,
|
||||
MAX1619_REG_W_REMOTE_TLOW, data->remote_low);
|
||||
|
||||
@@ -440,17 +447,17 @@ static void max1619_remote_crit(struct i2c_client *client, int operation,
|
||||
*nrels_mag = 0; /* magnitude */
|
||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||
max1619_update_client(client);
|
||||
results[0] = TEMP_FROM_REG(data->remote_max);
|
||||
results[1] = TEMP_FROM_REG(data->remote_hyst);
|
||||
results[0] = temp_from_reg(data->remote_max);
|
||||
results[1] = temp_from_reg(data->remote_hyst);
|
||||
*nrels_mag = 2;
|
||||
} else if (operation == SENSORS_PROC_REAL_WRITE) {
|
||||
if (*nrels_mag >= 1) {
|
||||
data->remote_max = TEMP_TO_REG(results[0]);
|
||||
data->remote_max = temp_to_reg(results[0]);
|
||||
i2c_smbus_write_byte_data(client,
|
||||
MAX1619_REG_W_REMOTE_TMAX, data->remote_max);
|
||||
}
|
||||
if (*nrels_mag >= 2) {
|
||||
data->remote_hyst = TEMP_TO_REG(results[1]);
|
||||
data->remote_hyst = temp_to_reg(results[1]);
|
||||
i2c_smbus_write_byte_data(client,
|
||||
MAX1619_REG_W_REMOTE_THYST, data->remote_hyst);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user