mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-30 22:05:11 +00:00
Correctly handle the case where some of the logical devices are
disabled. Add KERN constants to printks. Reindent. Fix error path in detect function. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2474 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
@@ -101,7 +101,8 @@ static inline void superio_exit(void)
|
|||||||
#define FAN_TO_REG(val,div) ((val)<=0?255: \
|
#define FAN_TO_REG(val,div) ((val)<=0?255: \
|
||||||
480000/((val)*(div)))
|
480000/((val)*(div)))
|
||||||
#define FAN_DIV_FROM_REG(val) (1 << ((val >> 5) & 0x03))
|
#define FAN_DIV_FROM_REG(val) (1 << ((val >> 5) & 0x03))
|
||||||
#define FAN_DIV_TO_REG(val) ((val)==8?0x60:(val)==4?0x40:(val)==1?0x00:0x20)
|
#define FAN_DIV_TO_REG(val) ((val)==8?0x60:(val)==4?0x40: \
|
||||||
|
(val)==1?0x00:0x20)
|
||||||
#define FAN_STATUS_FROM_REG(val) ((val) & 0x07)
|
#define FAN_STATUS_FROM_REG(val) ((val) & 0x07)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -452,14 +453,17 @@ int pc87360_detect(struct i2c_adapter *adapter, int address,
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
const char *type_name = "pc87360";
|
const char *type_name = "pc87360";
|
||||||
const char *client_name = "PC8736x chip";
|
const char *client_name = "PC8736x chip";
|
||||||
|
const ctl_table *template = pc87360_dir_table_template;
|
||||||
|
|
||||||
if (!i2c_is_isa_adapter(adapter)) {
|
if (!i2c_is_isa_adapter(adapter)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
if (extra_isa[i] && check_region(extra_isa[i], PC87360_EXTENT)) {
|
if (extra_isa[i]
|
||||||
printk("pc87360.o: region 0x%x already in use!\n", address);
|
&& check_region(extra_isa[i], PC87360_EXTENT)) {
|
||||||
|
printk(KERN_ERR "pc87360.o: region 0x%x already in "
|
||||||
|
"use!\n", address);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -490,15 +494,17 @@ int pc87360_detect(struct i2c_adapter *adapter, int address,
|
|||||||
break;
|
break;
|
||||||
case 0xe5:
|
case 0xe5:
|
||||||
type_name = "pc87365";
|
type_name = "pc87365";
|
||||||
data->fannr = 3;
|
template = pc87365_dir_table_template;
|
||||||
data->innr = 11;
|
data->fannr = extra_isa[0] ? 3 : 0;
|
||||||
data->tempnr = 2;
|
data->innr = extra_isa[1] ? 11 : 0;
|
||||||
|
data->tempnr = extra_isa[2] ? 2 : 0;
|
||||||
break;
|
break;
|
||||||
case 0xe9:
|
case 0xe9:
|
||||||
type_name = "pc87366";
|
type_name = "pc87366";
|
||||||
data->fannr = 3;
|
template = pc87365_dir_table_template;
|
||||||
data->innr = 11;
|
data->fannr = extra_isa[0] ? 3 : 0;
|
||||||
data->tempnr = 3;
|
data->innr = extra_isa[1] ? 11 : 0;
|
||||||
|
data->tempnr = extra_isa[2] ? 3 : 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,9 +523,7 @@ int pc87360_detect(struct i2c_adapter *adapter, int address,
|
|||||||
goto ERROR1;
|
goto ERROR1;
|
||||||
|
|
||||||
if ((i = i2c_register_entry((struct i2c_client *) new_client,
|
if ((i = i2c_register_entry((struct i2c_client *) new_client,
|
||||||
type_name, data->innr ?
|
type_name, template)) < 0) {
|
||||||
pc87365_dir_table_template :
|
|
||||||
pc87360_dir_table_template)) < 0) {
|
|
||||||
err = i;
|
err = i;
|
||||||
goto ERROR2;
|
goto ERROR2;
|
||||||
}
|
}
|
||||||
@@ -527,10 +531,14 @@ int pc87360_detect(struct i2c_adapter *adapter, int address,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ERROR2:
|
ERROR2:
|
||||||
i2c_detach_client(new_client);
|
i2c_detach_client(new_client);
|
||||||
ERROR1:
|
ERROR1:
|
||||||
release_region(address, PC87360_EXTENT);
|
for (i = 0; i < 3; i++) {
|
||||||
|
if (data->address[i]) {
|
||||||
|
release_region(data->address[i], PC87360_EXTENT);
|
||||||
|
}
|
||||||
|
}
|
||||||
kfree(data);
|
kfree(data);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -543,7 +551,7 @@ static int pc87360_detach_client(struct i2c_client *client)
|
|||||||
i2c_deregister_entry(data->sysctl_id);
|
i2c_deregister_entry(data->sysctl_id);
|
||||||
|
|
||||||
if ((err = i2c_detach_client(client))) {
|
if ((err = i2c_detach_client(client))) {
|
||||||
printk("pc87360.o: Client deregistration failed, "
|
printk(KERN_ERR "pc87360.o: Client deregistration failed, "
|
||||||
"client not detached.\n");
|
"client not detached.\n");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -591,34 +599,50 @@ static void pc87360_update_client(struct i2c_client *client)
|
|||||||
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
|
if ((jiffies - data->last_updated > HZ + HZ / 2) ||
|
||||||
(jiffies < data->last_updated) || !data->valid) {
|
(jiffies < data->last_updated) || !data->valid) {
|
||||||
for (i = 0; i < data->fannr; i++) {
|
for (i = 0; i < data->fannr; i++) {
|
||||||
data->fan[i] = pc87360_read_value(data, 0, PC87360_REG_FAN(i));
|
data->fan[i] = pc87360_read_value(data, 0,
|
||||||
data->fan_min[i] = pc87360_read_value(data, 0, PC87360_REG_FAN_MIN(i));
|
PC87360_REG_FAN(i));
|
||||||
data->fan_status[i] = pc87360_read_value(data, 0, PC87360_REG_FAN_STATUS(i));
|
data->fan_min[i] = pc87360_read_value(data, 0,
|
||||||
data->pwm[i] = pc87360_read_value(data, 0, PC87360_REG_PWM(i));
|
PC87360_REG_FAN_MIN(i));
|
||||||
|
data->fan_status[i] = pc87360_read_value(data, 0,
|
||||||
|
PC87360_REG_FAN_STATUS(i));
|
||||||
|
data->pwm[i] = pc87360_read_value(data, 0,
|
||||||
|
PC87360_REG_PWM(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < data->innr; i++) {
|
for (i = 0; i < data->innr; i++) {
|
||||||
pc87360_write_value(data, 1, PC87365_REG_IN_BANK, i);
|
pc87360_write_value(data, 1, PC87365_REG_IN_BANK, i);
|
||||||
data->in_status[i] = pc87360_read_value(data, 1, PC87365_REG_IN_STATUS);
|
data->in_status[i] = pc87360_read_value(data, 1,
|
||||||
|
PC87365_REG_IN_STATUS);
|
||||||
if (data->in_status[i] & 0x01) {
|
if (data->in_status[i] & 0x01) {
|
||||||
data->in[i] = pc87360_read_value(data, 1, PC87365_REG_IN);
|
data->in[i] = pc87360_read_value(data, 1,
|
||||||
data->in_min[i] = pc87360_read_value(data, 1, PC87365_REG_IN_MIN);
|
PC87365_REG_IN);
|
||||||
data->in_max[i] = pc87360_read_value(data, 1, PC87365_REG_IN_MAX);
|
data->in_min[i] = pc87360_read_value(data, 1,
|
||||||
|
PC87365_REG_IN_MIN);
|
||||||
|
data->in_max[i] = pc87360_read_value(data, 1,
|
||||||
|
PC87365_REG_IN_MAX);
|
||||||
}
|
}
|
||||||
data->in_alarms = pc87360_read_value(data, 1, PC87365_REG_IN_ALARMS1)
|
data->in_alarms = pc87360_read_value(data, 1,
|
||||||
| (pc87360_read_value(data, 1, PC87365_REG_IN_ALARMS2) << 8);
|
PC87365_REG_IN_ALARMS1)
|
||||||
|
| (pc87360_read_value(data, 1,
|
||||||
|
PC87365_REG_IN_ALARMS2) << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < data->tempnr; i++) {
|
for (i = 0; i < data->tempnr; i++) {
|
||||||
pc87360_write_value(data, 2, PC87365_REG_TEMP_BANK, i);
|
pc87360_write_value(data, 2, PC87365_REG_TEMP_BANK, i);
|
||||||
data->temp_status[i] = pc87360_read_value(data, 2, PC87365_REG_TEMP_STATUS);
|
data->temp_status[i] = pc87360_read_value(data, 2,
|
||||||
|
PC87365_REG_TEMP_STATUS);
|
||||||
if (data->temp_status[i] & 0x01) {
|
if (data->temp_status[i] & 0x01) {
|
||||||
data->temp[i] = pc87360_read_value(data, 2, PC87365_REG_TEMP);
|
data->temp[i] = pc87360_read_value(data, 2,
|
||||||
data->temp_min[i] = pc87360_read_value(data, 2, PC87365_REG_TEMP_MIN);
|
PC87365_REG_TEMP);
|
||||||
data->temp_max[i] = pc87360_read_value(data, 2, PC87365_REG_TEMP_MAX);
|
data->temp_min[i] = pc87360_read_value(data, 2,
|
||||||
data->temp_crit[i] = pc87360_read_value(data, 2, PC87365_REG_TEMP_CRIT);
|
PC87365_REG_TEMP_MIN);
|
||||||
|
data->temp_max[i] = pc87360_read_value(data, 2,
|
||||||
|
PC87365_REG_TEMP_MAX);
|
||||||
|
data->temp_crit[i] = pc87360_read_value(data, 2,
|
||||||
|
PC87365_REG_TEMP_CRIT);
|
||||||
}
|
}
|
||||||
data->temp_alarms = pc87360_read_value(data, 2, PC87365_REG_TEMP_ALARMS);
|
data->temp_alarms = pc87360_read_value(data, 2,
|
||||||
|
PC87365_REG_TEMP_ALARMS);
|
||||||
}
|
}
|
||||||
|
|
||||||
data->last_updated = jiffies;
|
data->last_updated = jiffies;
|
||||||
@@ -655,9 +679,9 @@ void pc87360_fan(struct i2c_client *client, int operation, int ctl_name,
|
|||||||
else if (operation == SENSORS_PROC_REAL_READ) {
|
else if (operation == SENSORS_PROC_REAL_READ) {
|
||||||
pc87360_update_client(client);
|
pc87360_update_client(client);
|
||||||
results[0] = FAN_FROM_REG(data->fan_min[nr],
|
results[0] = FAN_FROM_REG(data->fan_min[nr],
|
||||||
FAN_DIV_FROM_REG(data->fan_status[nr]));
|
FAN_DIV_FROM_REG(data->fan_status[nr]));
|
||||||
results[1] = FAN_FROM_REG(data->fan[nr],
|
results[1] = FAN_FROM_REG(data->fan[nr],
|
||||||
FAN_DIV_FROM_REG(data->fan_status[nr]));
|
FAN_DIV_FROM_REG(data->fan_status[nr]));
|
||||||
*nrels_mag = 2;
|
*nrels_mag = 2;
|
||||||
}
|
}
|
||||||
/* We ignore National's recommendation */
|
/* We ignore National's recommendation */
|
||||||
@@ -666,7 +690,7 @@ void pc87360_fan(struct i2c_client *client, int operation, int ctl_name,
|
|||||||
return;
|
return;
|
||||||
if (*nrels_mag >= 1) {
|
if (*nrels_mag >= 1) {
|
||||||
data->fan_min[nr] = FAN_TO_REG(results[0],
|
data->fan_min[nr] = FAN_TO_REG(results[0],
|
||||||
FAN_DIV_FROM_REG(data->fan_status[nr]));
|
FAN_DIV_FROM_REG(data->fan_status[nr]));
|
||||||
pc87360_write_value(data, 0, PC87360_REG_FAN_MIN(nr),
|
pc87360_write_value(data, 0, PC87360_REG_FAN_MIN(nr),
|
||||||
data->fan_min[nr]);
|
data->fan_min[nr]);
|
||||||
}
|
}
|
||||||
@@ -693,13 +717,13 @@ void pc87360_fan_div(struct i2c_client *client, int operation,
|
|||||||
for (i = 0; i < data->fannr && i < *nrels_mag; i++) {
|
for (i = 0; i < data->fannr && i < *nrels_mag; i++) {
|
||||||
/* Preserve fan min */
|
/* Preserve fan min */
|
||||||
int fan_min = FAN_FROM_REG(data->fan_min[i],
|
int fan_min = FAN_FROM_REG(data->fan_min[i],
|
||||||
FAN_DIV_FROM_REG(data->fan_status[i]));
|
FAN_DIV_FROM_REG(data->fan_status[i]));
|
||||||
data->fan_status[i] = (data->fan_status[i] & 0x9F)
|
data->fan_status[i] = (data->fan_status[i] & 0x9F)
|
||||||
| FAN_DIV_TO_REG(results[i]);
|
| FAN_DIV_TO_REG(results[i]);
|
||||||
pc87360_write_value(data, 0, PC87360_REG_FAN_STATUS(i),
|
pc87360_write_value(data, 0, PC87360_REG_FAN_STATUS(i),
|
||||||
data->fan_status[i]);
|
data->fan_status[i]);
|
||||||
data->fan_min[i] = FAN_TO_REG(fan_min,
|
data->fan_min[i] = FAN_TO_REG(fan_min,
|
||||||
FAN_DIV_FROM_REG(data->fan_status[i]));
|
FAN_DIV_FROM_REG(data->fan_status[i]));
|
||||||
pc87360_write_value(data, 0, PC87360_REG_FAN_MIN(i),
|
pc87360_write_value(data, 0, PC87360_REG_FAN_MIN(i),
|
||||||
data->fan_min[i]);
|
data->fan_min[i]);
|
||||||
}
|
}
|
||||||
@@ -845,15 +869,30 @@ void pc87365_temp_status(struct i2c_client *client, int operation, int ctl_name,
|
|||||||
|
|
||||||
static int __init pc87360_init(void)
|
static int __init pc87360_init(void)
|
||||||
{
|
{
|
||||||
printk("pc87360.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
int i;
|
||||||
|
|
||||||
|
printk(KERN_INFO "pc87360.o version %s (%s)\n", LM_VERSION, LM_DATE);
|
||||||
|
|
||||||
if (pc87360_find(&devid, extra_isa)) {
|
if (pc87360_find(&devid, extra_isa)) {
|
||||||
printk("pc87360.o: PC8736x not detected, module not inserted.\n");
|
printk(KERN_WARNING "pc87360.o: PC8736x not detected, "
|
||||||
|
"module not inserted.\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* i2c-proc wants a checkable region */
|
/* Arbitrarily pick one of the addresses */
|
||||||
normal_isa[0] = extra_isa[0];
|
for (i = 0; i < 3; i++) {
|
||||||
|
if (extra_isa[i] != 0x0000) {
|
||||||
|
normal_isa[0] = extra_isa[i];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (normal_isa[0] == 0x0000) {
|
||||||
|
printk(KERN_WARNING "pc87360.o: No active logical device, "
|
||||||
|
"module not inserted.\n");
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return i2c_add_driver(&pc87360_driver);
|
return i2c_add_driver(&pc87360_driver);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user