[PATCH] hwmon: Use attribute arrays in pc87360
Convert individual sensors to sensor-attr arrays by each sensor type, and initialize them in loops instead of long blocks of individual calls. Signed-off-by: Jim Cromie <jim.cromie@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
42d3b83fec
commit
dedc6a7803
1 changed files with 201 additions and 207 deletions
|
@ -305,18 +305,26 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *devattr,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define show_and_set_fan(offset) \
|
static struct sensor_device_attribute fan_input[] = {
|
||||||
static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
|
SENSOR_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0),
|
||||||
show_fan_input, NULL, offset-1); \
|
SENSOR_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1),
|
||||||
static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IWUSR | S_IRUGO, \
|
SENSOR_ATTR(fan3_input, S_IRUGO, show_fan_input, NULL, 2),
|
||||||
show_fan_min, set_fan_min, offset-1); \
|
};
|
||||||
static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO, \
|
static struct sensor_device_attribute fan_status[] = {
|
||||||
show_fan_div, NULL, offset-1); \
|
SENSOR_ATTR(fan1_status, S_IRUGO, show_fan_status, NULL, 0),
|
||||||
static SENSOR_DEVICE_ATTR(fan##offset##_status, S_IRUGO, \
|
SENSOR_ATTR(fan2_status, S_IRUGO, show_fan_status, NULL, 1),
|
||||||
show_fan_status, NULL, offset-1);
|
SENSOR_ATTR(fan3_status, S_IRUGO, show_fan_status, NULL, 2),
|
||||||
show_and_set_fan(1)
|
};
|
||||||
show_and_set_fan(2)
|
static struct sensor_device_attribute fan_div[] = {
|
||||||
show_and_set_fan(3)
|
SENSOR_ATTR(fan1_div, S_IRUGO, show_fan_div, NULL, 0),
|
||||||
|
SENSOR_ATTR(fan2_div, S_IRUGO, show_fan_div, NULL, 1),
|
||||||
|
SENSOR_ATTR(fan3_div, S_IRUGO, show_fan_div, NULL, 2),
|
||||||
|
};
|
||||||
|
static struct sensor_device_attribute fan_min[] = {
|
||||||
|
SENSOR_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 0),
|
||||||
|
SENSOR_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 1),
|
||||||
|
SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2),
|
||||||
|
};
|
||||||
|
|
||||||
static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf)
|
static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, char *buf)
|
||||||
{
|
{
|
||||||
|
@ -344,12 +352,11 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *devattr, con
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define show_and_set_pwm(offset) \
|
static struct sensor_device_attribute pwm[] = {
|
||||||
static SENSOR_DEVICE_ATTR(pwm##offset, S_IWUSR | S_IRUGO, \
|
SENSOR_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0),
|
||||||
show_pwm, set_pwm, offset-1);
|
SENSOR_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1),
|
||||||
show_and_set_pwm(1)
|
SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2),
|
||||||
show_and_set_pwm(2)
|
};
|
||||||
show_and_set_pwm(3)
|
|
||||||
|
|
||||||
static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf)
|
static ssize_t show_in_input(struct device *dev, struct device_attribute *devattr, char *buf)
|
||||||
{
|
{
|
||||||
|
@ -410,26 +417,58 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *devattr,
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define show_and_set_in(offset) \
|
static struct sensor_device_attribute in_input[] = {
|
||||||
static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
|
SENSOR_ATTR(in0_input, S_IRUGO, show_in_input, NULL, 0),
|
||||||
show_in_input, NULL, offset); \
|
SENSOR_ATTR(in1_input, S_IRUGO, show_in_input, NULL, 1),
|
||||||
static SENSOR_DEVICE_ATTR(in##offset##_min, S_IWUSR | S_IRUGO, \
|
SENSOR_ATTR(in2_input, S_IRUGO, show_in_input, NULL, 2),
|
||||||
show_in_min, set_in_min, offset); \
|
SENSOR_ATTR(in3_input, S_IRUGO, show_in_input, NULL, 3),
|
||||||
static SENSOR_DEVICE_ATTR(in##offset##_max, S_IWUSR | S_IRUGO, \
|
SENSOR_ATTR(in4_input, S_IRUGO, show_in_input, NULL, 4),
|
||||||
show_in_max, set_in_max, offset); \
|
SENSOR_ATTR(in5_input, S_IRUGO, show_in_input, NULL, 5),
|
||||||
static SENSOR_DEVICE_ATTR(in##offset##_status, S_IRUGO, \
|
SENSOR_ATTR(in6_input, S_IRUGO, show_in_input, NULL, 6),
|
||||||
show_in_status, NULL, offset);
|
SENSOR_ATTR(in7_input, S_IRUGO, show_in_input, NULL, 7),
|
||||||
show_and_set_in(0)
|
SENSOR_ATTR(in8_input, S_IRUGO, show_in_input, NULL, 8),
|
||||||
show_and_set_in(1)
|
SENSOR_ATTR(in9_input, S_IRUGO, show_in_input, NULL, 9),
|
||||||
show_and_set_in(2)
|
SENSOR_ATTR(in10_input, S_IRUGO, show_in_input, NULL, 10),
|
||||||
show_and_set_in(3)
|
};
|
||||||
show_and_set_in(4)
|
static struct sensor_device_attribute in_status[] = {
|
||||||
show_and_set_in(5)
|
SENSOR_ATTR(in0_status, S_IRUGO, show_in_status, NULL, 0),
|
||||||
show_and_set_in(6)
|
SENSOR_ATTR(in1_status, S_IRUGO, show_in_status, NULL, 1),
|
||||||
show_and_set_in(7)
|
SENSOR_ATTR(in2_status, S_IRUGO, show_in_status, NULL, 2),
|
||||||
show_and_set_in(8)
|
SENSOR_ATTR(in3_status, S_IRUGO, show_in_status, NULL, 3),
|
||||||
show_and_set_in(9)
|
SENSOR_ATTR(in4_status, S_IRUGO, show_in_status, NULL, 4),
|
||||||
show_and_set_in(10)
|
SENSOR_ATTR(in5_status, S_IRUGO, show_in_status, NULL, 5),
|
||||||
|
SENSOR_ATTR(in6_status, S_IRUGO, show_in_status, NULL, 6),
|
||||||
|
SENSOR_ATTR(in7_status, S_IRUGO, show_in_status, NULL, 7),
|
||||||
|
SENSOR_ATTR(in8_status, S_IRUGO, show_in_status, NULL, 8),
|
||||||
|
SENSOR_ATTR(in9_status, S_IRUGO, show_in_status, NULL, 9),
|
||||||
|
SENSOR_ATTR(in10_status, S_IRUGO, show_in_status, NULL, 10),
|
||||||
|
};
|
||||||
|
static struct sensor_device_attribute in_min[] = {
|
||||||
|
SENSOR_ATTR(in0_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 0),
|
||||||
|
SENSOR_ATTR(in1_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 1),
|
||||||
|
SENSOR_ATTR(in2_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 2),
|
||||||
|
SENSOR_ATTR(in3_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 3),
|
||||||
|
SENSOR_ATTR(in4_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 4),
|
||||||
|
SENSOR_ATTR(in5_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 5),
|
||||||
|
SENSOR_ATTR(in6_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 6),
|
||||||
|
SENSOR_ATTR(in7_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 7),
|
||||||
|
SENSOR_ATTR(in8_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 8),
|
||||||
|
SENSOR_ATTR(in9_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 9),
|
||||||
|
SENSOR_ATTR(in10_min, S_IWUSR | S_IRUGO, show_in_min, set_in_min, 10),
|
||||||
|
};
|
||||||
|
static struct sensor_device_attribute in_max[] = {
|
||||||
|
SENSOR_ATTR(in0_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 0),
|
||||||
|
SENSOR_ATTR(in1_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 1),
|
||||||
|
SENSOR_ATTR(in2_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 2),
|
||||||
|
SENSOR_ATTR(in3_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 3),
|
||||||
|
SENSOR_ATTR(in4_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 4),
|
||||||
|
SENSOR_ATTR(in5_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 5),
|
||||||
|
SENSOR_ATTR(in6_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 6),
|
||||||
|
SENSOR_ATTR(in7_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 7),
|
||||||
|
SENSOR_ATTR(in8_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 8),
|
||||||
|
SENSOR_ATTR(in9_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 9),
|
||||||
|
SENSOR_ATTR(in10_max, S_IWUSR | S_IRUGO, show_in_max, set_in_max, 10),
|
||||||
|
};
|
||||||
|
|
||||||
static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf)
|
static ssize_t show_therm_input(struct device *dev, struct device_attribute *devattr, char *buf)
|
||||||
{
|
{
|
||||||
|
@ -511,20 +550,43 @@ static ssize_t set_therm_crit(struct device *dev, struct device_attribute *devat
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define show_and_set_therm(offset) \
|
/* the +11 term below reflects the fact that VLM units 11,12,13 are
|
||||||
static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
|
used in the chip to measure voltage across the thermistors
|
||||||
show_therm_input, NULL, 11+offset-4); \
|
*/
|
||||||
static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
|
static struct sensor_device_attribute therm_input[] = {
|
||||||
show_therm_min, set_therm_min, 11+offset-4); \
|
SENSOR_ATTR(temp4_input, S_IRUGO, show_therm_input, NULL, 0+11),
|
||||||
static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
|
SENSOR_ATTR(temp5_input, S_IRUGO, show_therm_input, NULL, 1+11),
|
||||||
show_therm_max, set_therm_max, 11+offset-4); \
|
SENSOR_ATTR(temp6_input, S_IRUGO, show_therm_input, NULL, 2+11),
|
||||||
static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
|
};
|
||||||
show_therm_crit, set_therm_crit, 11+offset-4); \
|
static struct sensor_device_attribute therm_status[] = {
|
||||||
static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
|
SENSOR_ATTR(temp4_status, S_IRUGO, show_therm_status, NULL, 0+11),
|
||||||
show_therm_status, NULL, 11+offset-4);
|
SENSOR_ATTR(temp5_status, S_IRUGO, show_therm_status, NULL, 1+11),
|
||||||
show_and_set_therm(4)
|
SENSOR_ATTR(temp6_status, S_IRUGO, show_therm_status, NULL, 2+11),
|
||||||
show_and_set_therm(5)
|
};
|
||||||
show_and_set_therm(6)
|
static struct sensor_device_attribute therm_min[] = {
|
||||||
|
SENSOR_ATTR(temp4_min, S_IRUGO | S_IWUSR,
|
||||||
|
show_therm_min, set_therm_min, 0+11),
|
||||||
|
SENSOR_ATTR(temp5_min, S_IRUGO | S_IWUSR,
|
||||||
|
show_therm_min, set_therm_min, 1+11),
|
||||||
|
SENSOR_ATTR(temp6_min, S_IRUGO | S_IWUSR,
|
||||||
|
show_therm_min, set_therm_min, 2+11),
|
||||||
|
};
|
||||||
|
static struct sensor_device_attribute therm_max[] = {
|
||||||
|
SENSOR_ATTR(temp4_max, S_IRUGO | S_IWUSR,
|
||||||
|
show_therm_max, set_therm_max, 0+11),
|
||||||
|
SENSOR_ATTR(temp5_max, S_IRUGO | S_IWUSR,
|
||||||
|
show_therm_max, set_therm_max, 1+11),
|
||||||
|
SENSOR_ATTR(temp6_max, S_IRUGO | S_IWUSR,
|
||||||
|
show_therm_max, set_therm_max, 2+11),
|
||||||
|
};
|
||||||
|
static struct sensor_device_attribute therm_crit[] = {
|
||||||
|
SENSOR_ATTR(temp4_crit, S_IRUGO | S_IWUSR,
|
||||||
|
show_therm_crit, set_therm_crit, 0+11),
|
||||||
|
SENSOR_ATTR(temp5_crit, S_IRUGO | S_IWUSR,
|
||||||
|
show_therm_crit, set_therm_crit, 1+11),
|
||||||
|
SENSOR_ATTR(temp6_crit, S_IRUGO | S_IWUSR,
|
||||||
|
show_therm_crit, set_therm_crit, 2+11),
|
||||||
|
};
|
||||||
|
|
||||||
static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
|
static ssize_t show_vid(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
|
@ -630,20 +692,40 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *devatt
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define show_and_set_temp(offset) \
|
static struct sensor_device_attribute temp_input[] = {
|
||||||
static SENSOR_DEVICE_ATTR(temp##offset##_input, S_IRUGO, \
|
SENSOR_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0),
|
||||||
show_temp_input, NULL, offset-1); \
|
SENSOR_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1),
|
||||||
static SENSOR_DEVICE_ATTR(temp##offset##_min, S_IWUSR | S_IRUGO, \
|
SENSOR_ATTR(temp3_input, S_IRUGO, show_temp_input, NULL, 2),
|
||||||
show_temp_min, set_temp_min, offset-1); \
|
};
|
||||||
static SENSOR_DEVICE_ATTR(temp##offset##_max, S_IWUSR | S_IRUGO, \
|
static struct sensor_device_attribute temp_status[] = {
|
||||||
show_temp_max, set_temp_max, offset-1); \
|
SENSOR_ATTR(temp1_status, S_IRUGO, show_temp_status, NULL, 0),
|
||||||
static SENSOR_DEVICE_ATTR(temp##offset##_crit, S_IWUSR | S_IRUGO, \
|
SENSOR_ATTR(temp2_status, S_IRUGO, show_temp_status, NULL, 1),
|
||||||
show_temp_crit, set_temp_crit, offset-1); \
|
SENSOR_ATTR(temp3_status, S_IRUGO, show_temp_status, NULL, 2),
|
||||||
static SENSOR_DEVICE_ATTR(temp##offset##_status, S_IRUGO, \
|
};
|
||||||
show_temp_status, NULL, offset-1);
|
static struct sensor_device_attribute temp_min[] = {
|
||||||
show_and_set_temp(1)
|
SENSOR_ATTR(temp1_min, S_IRUGO | S_IWUSR,
|
||||||
show_and_set_temp(2)
|
show_temp_min, set_temp_min, 0),
|
||||||
show_and_set_temp(3)
|
SENSOR_ATTR(temp2_min, S_IRUGO | S_IWUSR,
|
||||||
|
show_temp_min, set_temp_min, 1),
|
||||||
|
SENSOR_ATTR(temp3_min, S_IRUGO | S_IWUSR,
|
||||||
|
show_temp_min, set_temp_min, 2),
|
||||||
|
};
|
||||||
|
static struct sensor_device_attribute temp_max[] = {
|
||||||
|
SENSOR_ATTR(temp1_max, S_IRUGO | S_IWUSR,
|
||||||
|
show_temp_max, set_temp_max, 0),
|
||||||
|
SENSOR_ATTR(temp2_max, S_IRUGO | S_IWUSR,
|
||||||
|
show_temp_max, set_temp_max, 1),
|
||||||
|
SENSOR_ATTR(temp3_max, S_IRUGO | S_IWUSR,
|
||||||
|
show_temp_max, set_temp_max, 2),
|
||||||
|
};
|
||||||
|
static struct sensor_device_attribute temp_crit[] = {
|
||||||
|
SENSOR_ATTR(temp1_crit, S_IRUGO | S_IWUSR,
|
||||||
|
show_temp_crit, set_temp_crit, 0),
|
||||||
|
SENSOR_ATTR(temp2_crit, S_IRUGO | S_IWUSR,
|
||||||
|
show_temp_crit, set_temp_crit, 1),
|
||||||
|
SENSOR_ATTR(temp3_crit, S_IRUGO | S_IWUSR,
|
||||||
|
show_temp_crit, set_temp_crit, 2),
|
||||||
|
};
|
||||||
|
|
||||||
static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf)
|
static ssize_t show_temp_alarms(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
|
@ -749,22 +831,24 @@ static int __init pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses
|
||||||
static int pc87360_detect(struct i2c_adapter *adapter)
|
static int pc87360_detect(struct i2c_adapter *adapter)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct i2c_client *new_client;
|
struct i2c_client *client;
|
||||||
struct pc87360_data *data;
|
struct pc87360_data *data;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
const char *name = "pc87360";
|
const char *name = "pc87360";
|
||||||
int use_thermistors = 0;
|
int use_thermistors = 0;
|
||||||
|
struct device *dev;
|
||||||
|
|
||||||
if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL)))
|
if (!(data = kzalloc(sizeof(struct pc87360_data), GFP_KERNEL)))
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
new_client = &data->client;
|
client = &data->client;
|
||||||
i2c_set_clientdata(new_client, data);
|
dev = &client->dev;
|
||||||
new_client->addr = address;
|
i2c_set_clientdata(client, data);
|
||||||
|
client->addr = address;
|
||||||
init_MUTEX(&data->lock);
|
init_MUTEX(&data->lock);
|
||||||
new_client->adapter = adapter;
|
client->adapter = adapter;
|
||||||
new_client->driver = &pc87360_driver;
|
client->driver = &pc87360_driver;
|
||||||
new_client->flags = 0;
|
client->flags = 0;
|
||||||
|
|
||||||
data->fannr = 2;
|
data->fannr = 2;
|
||||||
data->innr = 0;
|
data->innr = 0;
|
||||||
|
@ -792,7 +876,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(new_client->name, name);
|
strlcpy(client->name, name, sizeof(client->name));
|
||||||
data->valid = 0;
|
data->valid = 0;
|
||||||
init_MUTEX(&data->update_lock);
|
init_MUTEX(&data->update_lock);
|
||||||
|
|
||||||
|
@ -800,7 +884,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
|
||||||
if (((data->address[i] = extra_isa[i]))
|
if (((data->address[i] = extra_isa[i]))
|
||||||
&& !request_region(extra_isa[i], PC87360_EXTENT,
|
&& !request_region(extra_isa[i], PC87360_EXTENT,
|
||||||
pc87360_driver.driver.name)) {
|
pc87360_driver.driver.name)) {
|
||||||
dev_err(&new_client->dev, "Region 0x%x-0x%x already "
|
dev_err(&client->dev, "Region 0x%x-0x%x already "
|
||||||
"in use!\n", extra_isa[i],
|
"in use!\n", extra_isa[i],
|
||||||
extra_isa[i]+PC87360_EXTENT-1);
|
extra_isa[i]+PC87360_EXTENT-1);
|
||||||
for (i--; i >= 0; i--)
|
for (i--; i >= 0; i--)
|
||||||
|
@ -814,7 +898,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
|
||||||
if (data->fannr)
|
if (data->fannr)
|
||||||
data->fan_conf = confreg[0] | (confreg[1] << 8);
|
data->fan_conf = confreg[0] | (confreg[1] << 8);
|
||||||
|
|
||||||
if ((err = i2c_attach_client(new_client)))
|
if ((err = i2c_attach_client(client)))
|
||||||
goto ERROR2;
|
goto ERROR2;
|
||||||
|
|
||||||
/* Use the correct reference voltage
|
/* Use the correct reference voltage
|
||||||
|
@ -828,7 +912,7 @@ static int pc87360_detect(struct i2c_adapter *adapter)
|
||||||
PC87365_REG_TEMP_CONFIG);
|
PC87365_REG_TEMP_CONFIG);
|
||||||
}
|
}
|
||||||
data->in_vref = (i&0x02) ? 3025 : 2966;
|
data->in_vref = (i&0x02) ? 3025 : 2966;
|
||||||
dev_dbg(&new_client->dev, "Using %s reference voltage\n",
|
dev_dbg(&client->dev, "Using %s reference voltage\n",
|
||||||
(i&0x02) ? "external" : "internal");
|
(i&0x02) ? "external" : "internal");
|
||||||
|
|
||||||
data->vid_conf = confreg[3];
|
data->vid_conf = confreg[3];
|
||||||
|
@ -847,154 +931,64 @@ static int pc87360_detect(struct i2c_adapter *adapter)
|
||||||
if (devid == 0xe9 && data->address[1]) /* PC87366 */
|
if (devid == 0xe9 && data->address[1]) /* PC87366 */
|
||||||
use_thermistors = confreg[2] & 0x40;
|
use_thermistors = confreg[2] & 0x40;
|
||||||
|
|
||||||
pc87360_init_client(new_client, use_thermistors);
|
pc87360_init_client(client, use_thermistors);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register sysfs hooks */
|
/* Register sysfs hooks */
|
||||||
data->class_dev = hwmon_device_register(&new_client->dev);
|
data->class_dev = hwmon_device_register(&client->dev);
|
||||||
if (IS_ERR(data->class_dev)) {
|
if (IS_ERR(data->class_dev)) {
|
||||||
err = PTR_ERR(data->class_dev);
|
err = PTR_ERR(data->class_dev);
|
||||||
goto ERROR3;
|
goto ERROR3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->innr) {
|
if (data->innr) {
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in0_input.dev_attr);
|
for (i = 0; i < 11; i++) {
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in1_input.dev_attr);
|
device_create_file(dev, &in_input[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in2_input.dev_attr);
|
device_create_file(dev, &in_min[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in3_input.dev_attr);
|
device_create_file(dev, &in_max[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in4_input.dev_attr);
|
device_create_file(dev, &in_status[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in5_input.dev_attr);
|
}
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in6_input.dev_attr);
|
device_create_file(dev, &dev_attr_cpu0_vid);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in7_input.dev_attr);
|
device_create_file(dev, &dev_attr_vrm);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in8_input.dev_attr);
|
device_create_file(dev, &dev_attr_alarms_in);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in9_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in10_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in0_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in1_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in2_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in3_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in4_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in5_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in6_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in7_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in8_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in9_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in10_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in0_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in1_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in2_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in3_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in4_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in5_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in6_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in7_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in8_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in9_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in10_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in0_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in1_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in2_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in3_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in4_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in5_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in6_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in7_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in8_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in9_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_in10_status.dev_attr);
|
|
||||||
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_vrm);
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_alarms_in);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->tempnr) {
|
if (data->tempnr) {
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp1_input.dev_attr);
|
for (i = 0; i < data->tempnr; i++) {
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp2_input.dev_attr);
|
device_create_file(dev, &temp_input[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp1_min.dev_attr);
|
device_create_file(dev, &temp_min[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp2_min.dev_attr);
|
device_create_file(dev, &temp_max[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp1_max.dev_attr);
|
device_create_file(dev, &temp_crit[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp2_max.dev_attr);
|
device_create_file(dev, &temp_status[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp1_crit.dev_attr);
|
}
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp2_crit.dev_attr);
|
device_create_file(dev, &dev_attr_alarms_temp);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp1_status.dev_attr);
|
}
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp2_status.dev_attr);
|
|
||||||
|
|
||||||
device_create_file(&new_client->dev, &dev_attr_alarms_temp);
|
|
||||||
}
|
|
||||||
if (data->tempnr == 3) {
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp3_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp3_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp3_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp3_crit.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp3_status.dev_attr);
|
|
||||||
}
|
|
||||||
if (data->innr == 14) {
|
if (data->innr == 14) {
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp4_input.dev_attr);
|
for (i = 0; i < 3; i++) {
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp5_input.dev_attr);
|
device_create_file(dev, &therm_input[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp6_input.dev_attr);
|
device_create_file(dev, &therm_min[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp4_min.dev_attr);
|
device_create_file(dev, &therm_max[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp5_min.dev_attr);
|
device_create_file(dev, &therm_crit[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp6_min.dev_attr);
|
device_create_file(dev, &therm_status[i].dev_attr);
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp4_max.dev_attr);
|
}
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp5_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp6_max.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp4_crit.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp5_crit.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp6_crit.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp4_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp5_status.dev_attr);
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_temp6_status.dev_attr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->fannr) {
|
for (i = 0; i < data->fannr; i++) {
|
||||||
if (FAN_CONFIG_MONITOR(data->fan_conf, 0)) {
|
if (FAN_CONFIG_MONITOR(data->fan_conf, i)) {
|
||||||
device_create_file(&new_client->dev,
|
device_create_file(dev, &fan_input[i].dev_attr);
|
||||||
&sensor_dev_attr_fan1_input.dev_attr);
|
device_create_file(dev, &fan_min[i].dev_attr);
|
||||||
device_create_file(&new_client->dev,
|
device_create_file(dev, &fan_div[i].dev_attr);
|
||||||
&sensor_dev_attr_fan1_min.dev_attr);
|
device_create_file(dev, &fan_status[i].dev_attr);
|
||||||
device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan1_div.dev_attr);
|
|
||||||
device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan1_status.dev_attr);
|
|
||||||
}
|
}
|
||||||
|
if (FAN_CONFIG_CONTROL(data->fan_conf, i))
|
||||||
if (FAN_CONFIG_MONITOR(data->fan_conf, 1)) {
|
device_create_file(dev, &pwm[i].dev_attr);
|
||||||
device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan2_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan2_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan2_div.dev_attr);
|
|
||||||
device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan2_status.dev_attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FAN_CONFIG_CONTROL(data->fan_conf, 0))
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_pwm1.dev_attr);
|
|
||||||
if (FAN_CONFIG_CONTROL(data->fan_conf, 1))
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_pwm2.dev_attr);
|
|
||||||
}
|
|
||||||
if (data->fannr == 3) {
|
|
||||||
if (FAN_CONFIG_MONITOR(data->fan_conf, 2)) {
|
|
||||||
device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan3_input.dev_attr);
|
|
||||||
device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan3_min.dev_attr);
|
|
||||||
device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan3_div.dev_attr);
|
|
||||||
device_create_file(&new_client->dev,
|
|
||||||
&sensor_dev_attr_fan3_status.dev_attr);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FAN_CONFIG_CONTROL(data->fan_conf, 2))
|
|
||||||
device_create_file(&new_client->dev, &sensor_dev_attr_pwm3.dev_attr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ERROR3:
|
ERROR3:
|
||||||
i2c_detach_client(new_client);
|
i2c_detach_client(client);
|
||||||
ERROR2:
|
ERROR2:
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
if (data->address[i]) {
|
if (data->address[i]) {
|
||||||
|
@ -1071,7 +1065,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
|
||||||
}
|
}
|
||||||
|
|
||||||
nr = data->innr < 11 ? data->innr : 11;
|
nr = data->innr < 11 ? data->innr : 11;
|
||||||
for (i=0; i<nr; i++) {
|
for (i = 0; i < nr; i++) {
|
||||||
if (init >= init_in[i]) {
|
if (init >= init_in[i]) {
|
||||||
/* Forcibly enable voltage channel */
|
/* Forcibly enable voltage channel */
|
||||||
reg = pc87360_read_value(data, LD_IN, i,
|
reg = pc87360_read_value(data, LD_IN, i,
|
||||||
|
@ -1088,14 +1082,14 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
|
||||||
|
|
||||||
/* We can't blindly trust the Super-I/O space configuration bit,
|
/* We can't blindly trust the Super-I/O space configuration bit,
|
||||||
most BIOS won't set it properly */
|
most BIOS won't set it properly */
|
||||||
for (i=11; i<data->innr; i++) {
|
for (i = 11; i < data->innr; i++) {
|
||||||
reg = pc87360_read_value(data, LD_IN, i,
|
reg = pc87360_read_value(data, LD_IN, i,
|
||||||
PC87365_REG_TEMP_STATUS);
|
PC87365_REG_TEMP_STATUS);
|
||||||
use_thermistors = use_thermistors || (reg & 0x01);
|
use_thermistors = use_thermistors || (reg & 0x01);
|
||||||
}
|
}
|
||||||
|
|
||||||
i = use_thermistors ? 2 : 0;
|
i = use_thermistors ? 2 : 0;
|
||||||
for (; i<data->tempnr; i++) {
|
for (; i < data->tempnr; i++) {
|
||||||
if (init >= init_temp[i]) {
|
if (init >= init_temp[i]) {
|
||||||
/* Forcibly enable temperature channel */
|
/* Forcibly enable temperature channel */
|
||||||
reg = pc87360_read_value(data, LD_TEMP, i,
|
reg = pc87360_read_value(data, LD_TEMP, i,
|
||||||
|
@ -1111,7 +1105,7 @@ static void pc87360_init_client(struct i2c_client *client, int use_thermistors)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_thermistors) {
|
if (use_thermistors) {
|
||||||
for (i=11; i<data->innr; i++) {
|
for (i = 11; i < data->innr; i++) {
|
||||||
if (init >= init_in[i]) {
|
if (init >= init_in[i]) {
|
||||||
/* The pin may already be used by thermal
|
/* The pin may already be used by thermal
|
||||||
diodes */
|
diodes */
|
||||||
|
|
Loading…
Reference in a new issue