Commit 439b1408 authored by Mark M. Hoffman's avatar Mark M. Hoffman Committed by Greg Kroah-Hartman

[PATCH] i2c: sensors chip driver updates

This patch modifies some sysfs file names for sensors chip drivers in
accordance with the standard interface proposed here [1] and refined
here [2].  The lm_sensors userspace tools have been modified to accept
both the new and old names.  This patch was tested for some drivers,
and at least compile tested for the rest.

[1] http://archives.andrew.net.au/lm-sensors/msg08477.html

[2] http://archives.andrew.net.au/lm-sensors/msg18391.htmlSigned-off-by: default avatarMark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent eb20210c
...@@ -135,12 +135,15 @@ fan[1-3]_div Fan divisor. ...@@ -135,12 +135,15 @@ fan[1-3]_div Fan divisor.
Note that this is actually an internal clock divisor, which Note that this is actually an internal clock divisor, which
affects the measurable speed range, not the read value. affects the measurable speed range, not the read value.
fan[1-3]_pwm Pulse width modulation fan control. *******
* PWM *
*******
pwm[1-3] Pulse width modulation fan control.
Integer value in the range 0 to 255 Integer value in the range 0 to 255
Read/Write Read/Write
255 is max or 100%. 255 is max or 100%.
fan[1-3]_pwm_enable pwm[1-3]_enable
Switch PWM on and off. Switch PWM on and off.
Not always present even if fan*_pwm is. Not always present even if fan*_pwm is.
0 to turn off 0 to turn off
......
...@@ -436,7 +436,7 @@ static ssize_t set_pwm_##offset (struct device *dev, \ ...@@ -436,7 +436,7 @@ static ssize_t set_pwm_##offset (struct device *dev, \
{ \ { \
return set_pwm(dev, buf, count, 0x##offset - 1); \ return set_pwm(dev, buf, count, 0x##offset - 1); \
} \ } \
static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, \ static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
show_pwm_##offset, set_pwm_##offset) show_pwm_##offset, set_pwm_##offset)
pwm_reg(1); pwm_reg(1);
...@@ -799,7 +799,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -799,7 +799,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
device_create_file(&new_client->dev, &dev_attr_fan1_input); device_create_file(&new_client->dev, &dev_attr_fan1_input);
device_create_file(&new_client->dev, &dev_attr_fan1_div); device_create_file(&new_client->dev, &dev_attr_fan1_div);
device_create_file(&new_client->dev, &dev_attr_fan1_min); device_create_file(&new_client->dev, &dev_attr_fan1_min);
device_create_file(&new_client->dev, &dev_attr_fan1_pwm); device_create_file(&new_client->dev, &dev_attr_pwm1);
device_create_file(&new_client->dev, &dev_attr_auto_fan1_channel); device_create_file(&new_client->dev, &dev_attr_auto_fan1_channel);
device_create_file(&new_client->dev, &dev_attr_temp1_input); device_create_file(&new_client->dev, &dev_attr_temp1_input);
device_create_file(&new_client->dev, &dev_attr_temp1_min); device_create_file(&new_client->dev, &dev_attr_temp1_min);
...@@ -826,7 +826,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -826,7 +826,7 @@ static int adm1031_detect(struct i2c_adapter *adapter, int address, int kind)
device_create_file(&new_client->dev, &dev_attr_fan2_input); device_create_file(&new_client->dev, &dev_attr_fan2_input);
device_create_file(&new_client->dev, &dev_attr_fan2_div); device_create_file(&new_client->dev, &dev_attr_fan2_div);
device_create_file(&new_client->dev, &dev_attr_fan2_min); device_create_file(&new_client->dev, &dev_attr_fan2_min);
device_create_file(&new_client->dev, &dev_attr_fan2_pwm); device_create_file(&new_client->dev, &dev_attr_pwm2);
device_create_file(&new_client->dev, device_create_file(&new_client->dev,
&dev_attr_auto_fan2_channel); &dev_attr_auto_fan2_channel);
device_create_file(&new_client->dev, &dev_attr_temp3_input); device_create_file(&new_client->dev, &dev_attr_temp3_input);
......
...@@ -591,12 +591,12 @@ static ssize_t set_pwm_enable1(struct device *dev, const char *buf, ...@@ -591,12 +591,12 @@ static ssize_t set_pwm_enable1(struct device *dev, const char *buf,
return count; return count;
} }
static DEVICE_ATTR(fan1_pwm, S_IRUGO | S_IWUSR, show_pwm1, set_pwm1); static DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, show_pwm1, set_pwm1);
static DEVICE_ATTR(fan1_pwm_enable, S_IRUGO | S_IWUSR, static DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR,
show_pwm_enable1, set_pwm_enable1); show_pwm_enable1, set_pwm_enable1);
#define device_create_file_pwm1(client) do { \ #define device_create_file_pwm1(client) do { \
device_create_file(&new_client->dev, &dev_attr_fan1_pwm); \ device_create_file(&new_client->dev, &dev_attr_pwm1); \
device_create_file(&new_client->dev, &dev_attr_fan1_pwm_enable); \ device_create_file(&new_client->dev, &dev_attr_pwm1_enable); \
} while (0) } while (0)
/* This function is called when: /* This function is called when:
......
...@@ -538,9 +538,10 @@ static ssize_t show_pwm_enable##offset (struct device *dev, char *buf) \ ...@@ -538,9 +538,10 @@ static ssize_t show_pwm_enable##offset (struct device *dev, char *buf) \
{ \ { \
return show_pwm_enable(dev, buf, 0x##offset - 1); \ return show_pwm_enable(dev, buf, 0x##offset - 1); \
} \ } \
static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, \ static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
show_pwm_##offset, set_pwm_##offset); \ show_pwm_##offset, set_pwm_##offset); \
static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO, show_pwm_enable##offset, NULL); static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO, \
show_pwm_enable##offset, NULL);
show_pwm_reg(1); show_pwm_reg(1);
show_pwm_reg(2); show_pwm_reg(2);
...@@ -845,12 +846,12 @@ int lm85_detect(struct i2c_adapter *adapter, int address, ...@@ -845,12 +846,12 @@ int lm85_detect(struct i2c_adapter *adapter, int address,
device_create_file(&new_client->dev, &dev_attr_fan2_min); device_create_file(&new_client->dev, &dev_attr_fan2_min);
device_create_file(&new_client->dev, &dev_attr_fan3_min); device_create_file(&new_client->dev, &dev_attr_fan3_min);
device_create_file(&new_client->dev, &dev_attr_fan4_min); device_create_file(&new_client->dev, &dev_attr_fan4_min);
device_create_file(&new_client->dev, &dev_attr_fan1_pwm); device_create_file(&new_client->dev, &dev_attr_pwm1);
device_create_file(&new_client->dev, &dev_attr_fan2_pwm); device_create_file(&new_client->dev, &dev_attr_pwm2);
device_create_file(&new_client->dev, &dev_attr_fan3_pwm); device_create_file(&new_client->dev, &dev_attr_pwm3);
device_create_file(&new_client->dev, &dev_attr_fan1_pwm_enable); device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
device_create_file(&new_client->dev, &dev_attr_fan2_pwm_enable); device_create_file(&new_client->dev, &dev_attr_pwm2_enable);
device_create_file(&new_client->dev, &dev_attr_fan3_pwm_enable); device_create_file(&new_client->dev, &dev_attr_pwm3_enable);
device_create_file(&new_client->dev, &dev_attr_in0_input); device_create_file(&new_client->dev, &dev_attr_in0_input);
device_create_file(&new_client->dev, &dev_attr_in1_input); device_create_file(&new_client->dev, &dev_attr_in1_input);
device_create_file(&new_client->dev, &dev_attr_in2_input); device_create_file(&new_client->dev, &dev_attr_in2_input);
......
...@@ -182,13 +182,13 @@ static ssize_t get_fan_div(struct device *dev, char *buf, int nr) ...@@ -182,13 +182,13 @@ static ssize_t get_fan_div(struct device *dev, char *buf, int nr)
return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr])); return sprintf(buf, "%d\n", DIV_FROM_REG(data->fan_div[nr]));
} }
static ssize_t get_fan_pwm(struct device *dev, char *buf, int nr) static ssize_t get_pwm(struct device *dev, char *buf, int nr)
{ {
struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); struct smsc47m1_data *data = smsc47m1_update_device(dev, 0);
return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr])); return sprintf(buf, "%d\n", PWM_FROM_REG(data->pwm[nr]));
} }
static ssize_t get_fan_pwm_en(struct device *dev, char *buf, int nr) static ssize_t get_pwm_en(struct device *dev, char *buf, int nr)
{ {
struct smsc47m1_data *data = smsc47m1_update_device(dev, 0); struct smsc47m1_data *data = smsc47m1_update_device(dev, 0);
return sprintf(buf, "%d\n", PWM_EN_FROM_REG(data->pwm[nr])); return sprintf(buf, "%d\n", PWM_EN_FROM_REG(data->pwm[nr]));
...@@ -256,7 +256,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf, ...@@ -256,7 +256,7 @@ static ssize_t set_fan_div(struct device *dev, const char *buf,
return count; return count;
} }
static ssize_t set_fan_pwm(struct device *dev, const char *buf, static ssize_t set_pwm(struct device *dev, const char *buf,
size_t count, int nr) size_t count, int nr)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
...@@ -275,7 +275,7 @@ static ssize_t set_fan_pwm(struct device *dev, const char *buf, ...@@ -275,7 +275,7 @@ static ssize_t set_fan_pwm(struct device *dev, const char *buf,
return count; return count;
} }
static ssize_t set_fan_pwm_en(struct device *dev, const char *buf, static ssize_t set_pwm_en(struct device *dev, const char *buf,
size_t count, int nr) size_t count, int nr)
{ {
struct i2c_client *client = to_i2c_client(dev); struct i2c_client *client = to_i2c_client(dev);
...@@ -318,23 +318,23 @@ static ssize_t set_fan##offset##_div (struct device *dev, \ ...@@ -318,23 +318,23 @@ static ssize_t set_fan##offset##_div (struct device *dev, \
{ \ { \
return set_fan_div(dev, buf, count, 0x##offset - 1); \ return set_fan_div(dev, buf, count, 0x##offset - 1); \
} \ } \
static ssize_t get_fan##offset##_pwm (struct device *dev, char *buf) \ static ssize_t get_pwm##offset (struct device *dev, char *buf) \
{ \ { \
return get_fan_pwm(dev, buf, 0x##offset - 1); \ return get_pwm(dev, buf, 0x##offset - 1); \
} \ } \
static ssize_t set_fan##offset##_pwm (struct device *dev, \ static ssize_t set_pwm##offset (struct device *dev, \
const char *buf, size_t count) \ const char *buf, size_t count) \
{ \ { \
return set_fan_pwm(dev, buf, count, 0x##offset - 1); \ return set_pwm(dev, buf, count, 0x##offset - 1); \
} \ } \
static ssize_t get_fan##offset##_pwm_en (struct device *dev, char *buf) \ static ssize_t get_pwm##offset##_en (struct device *dev, char *buf) \
{ \ { \
return get_fan_pwm_en(dev, buf, 0x##offset - 1); \ return get_pwm_en(dev, buf, 0x##offset - 1); \
} \ } \
static ssize_t set_fan##offset##_pwm_en (struct device *dev, \ static ssize_t set_pwm##offset##_en (struct device *dev, \
const char *buf, size_t count) \ const char *buf, size_t count) \
{ \ { \
return set_fan_pwm_en(dev, buf, count, 0x##offset - 1); \ return set_pwm_en(dev, buf, count, 0x##offset - 1); \
} \ } \
static DEVICE_ATTR(fan##offset##_input, S_IRUGO, get_fan##offset, \ static DEVICE_ATTR(fan##offset##_input, S_IRUGO, get_fan##offset, \
NULL); \ NULL); \
...@@ -342,10 +342,10 @@ static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \ ...@@ -342,10 +342,10 @@ static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
get_fan##offset##_min, set_fan##offset##_min); \ get_fan##offset##_min, set_fan##offset##_min); \
static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \ static DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
get_fan##offset##_div, set_fan##offset##_div); \ get_fan##offset##_div, set_fan##offset##_div); \
static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, \ static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
get_fan##offset##_pwm, set_fan##offset##_pwm); \ get_pwm##offset, set_pwm##offset); \
static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO | S_IWUSR, \ static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
get_fan##offset##_pwm_en, set_fan##offset##_pwm_en); get_pwm##offset##_en, set_pwm##offset##_en);
fan_present(1); fan_present(1);
fan_present(2); fan_present(2);
...@@ -462,15 +462,15 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -462,15 +462,15 @@ static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind)
if ((smsc47m1_read_value(new_client, SMSC47M1_REG_PPIN(0)) & 0x05) if ((smsc47m1_read_value(new_client, SMSC47M1_REG_PPIN(0)) & 0x05)
== 0x04) { == 0x04) {
device_create_file(&new_client->dev, &dev_attr_fan1_pwm); device_create_file(&new_client->dev, &dev_attr_pwm1);
device_create_file(&new_client->dev, &dev_attr_fan1_pwm_enable); device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
} else } else
dev_dbg(&new_client->dev, "PWM 1 not enabled by hardware, " dev_dbg(&new_client->dev, "PWM 1 not enabled by hardware, "
"skipping\n"); "skipping\n");
if ((smsc47m1_read_value(new_client, SMSC47M1_REG_PPIN(1)) & 0x05) if ((smsc47m1_read_value(new_client, SMSC47M1_REG_PPIN(1)) & 0x05)
== 0x04) { == 0x04) {
device_create_file(&new_client->dev, &dev_attr_fan2_pwm); device_create_file(&new_client->dev, &dev_attr_pwm2);
device_create_file(&new_client->dev, &dev_attr_fan2_pwm_enable); device_create_file(&new_client->dev, &dev_attr_pwm2_enable);
} else } else
dev_dbg(&new_client->dev, "PWM 2 not enabled by hardware, " dev_dbg(&new_client->dev, "PWM 2 not enabled by hardware, "
"skipping\n"); "skipping\n");
......
...@@ -845,7 +845,7 @@ store_regs_pwm_##offset (struct device *dev, const char *buf, size_t count) \ ...@@ -845,7 +845,7 @@ store_regs_pwm_##offset (struct device *dev, const char *buf, size_t count) \
{ \ { \
return store_pwm_reg(dev, buf, count, offset); \ return store_pwm_reg(dev, buf, count, offset); \
} \ } \
static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, \ static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
show_regs_pwm_##offset, store_regs_pwm_##offset); show_regs_pwm_##offset, store_regs_pwm_##offset);
sysfs_pwm(1); sysfs_pwm(1);
...@@ -854,7 +854,7 @@ sysfs_pwm(3); ...@@ -854,7 +854,7 @@ sysfs_pwm(3);
#define device_create_file_pwm(client, offset) \ #define device_create_file_pwm(client, offset) \
do { \ do { \
device_create_file(&client->dev, &dev_attr_fan##offset##_pwm); \ device_create_file(&client->dev, &dev_attr_pwm##offset); \
} while (0) } while (0)
static ssize_t static ssize_t
......
...@@ -740,22 +740,26 @@ static ssize_t show_regs_pwm_##offset (struct device *dev, char *buf) \ ...@@ -740,22 +740,26 @@ static ssize_t show_regs_pwm_##offset (struct device *dev, char *buf) \
{ \ { \
return show_pwm_reg(dev, buf, offset); \ return show_pwm_reg(dev, buf, offset); \
} \ } \
static ssize_t store_regs_pwm_##offset (struct device *dev, const char *buf, size_t count) \ static ssize_t store_regs_pwm_##offset (struct device *dev, \
const char *buf, size_t count) \
{ \ { \
return store_pwm_reg(dev, buf, count, offset); \ return store_pwm_reg(dev, buf, count, offset); \
} \ } \
static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, show_regs_pwm_##offset, store_regs_pwm_##offset); static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
show_regs_pwm_##offset, store_regs_pwm_##offset);
#define sysfs_pwmenable(offset) \ #define sysfs_pwmenable(offset) \
static ssize_t show_regs_pwmenable_##offset (struct device *dev, char *buf) \ static ssize_t show_regs_pwmenable_##offset (struct device *dev, char *buf) \
{ \ { \
return show_pwmenable_reg(dev, buf, offset); \ return show_pwmenable_reg(dev, buf, offset); \
} \ } \
static ssize_t store_regs_pwmenable_##offset (struct device *dev, const char *buf, size_t count) \ static ssize_t store_regs_pwmenable_##offset (struct device *dev, \
const char *buf, size_t count) \
{ \ { \
return store_pwmenable_reg(dev, buf, count, offset); \ return store_pwmenable_reg(dev, buf, count, offset); \
} \ } \
static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO | S_IWUSR, show_regs_pwmenable_##offset, store_regs_pwmenable_##offset); static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO | S_IWUSR, \
show_regs_pwmenable_##offset, store_regs_pwmenable_##offset);
sysfs_pwm(1); sysfs_pwm(1);
sysfs_pwm(2); sysfs_pwm(2);
...@@ -765,12 +769,12 @@ sysfs_pwm(4); ...@@ -765,12 +769,12 @@ sysfs_pwm(4);
#define device_create_file_pwm(client, offset) \ #define device_create_file_pwm(client, offset) \
do { \ do { \
device_create_file(&client->dev, &dev_attr_fan##offset##_pwm); \ device_create_file(&client->dev, &dev_attr_pwm##offset); \
} while (0) } while (0)
#define device_create_file_pwmenable(client, offset) \ #define device_create_file_pwmenable(client, offset) \
do { \ do { \
device_create_file(&client->dev, &dev_attr_fan##offset##_pwm_enable); \ device_create_file(&client->dev, &dev_attr_pwm##offset##_enable); \
} while (0) } while (0)
static ssize_t static ssize_t
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment