diff -Naur b/drivers/i2c/chips/w83792d.c c/drivers/i2c/chips/w83792d.c --- b/drivers/i2c/chips/w83792d.c 2005-06-21 09:46:06.926360832 +0200 +++ c/drivers/i2c/chips/w83792d.c 2005-06-21 17:56:21.178714784 +0200 @@ -311,7 +311,7 @@ static struct w83792d_data *w83792d_update_device(struct device *dev); #ifdef DEBUG -static void w83792d_print_debug(struct w83792d_data *data); +static void w83792d_print_debug(struct w83792d_data *data, struct device *dev); #endif static void w83792d_init_client(struct i2c_client *client); @@ -382,8 +382,9 @@ show_in_reg(in_max); #define store_in_reg(REG, reg) \ -static ssize_t store_in_##reg (struct device *dev, struct device_attribute *attr, \ - const char *buf, size_t count) \ +static ssize_t store_in_##reg (struct device *dev, \ + struct device_attribute *attr, \ + const char *buf, size_t count) \ { \ struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); \ int nr = sensor_attr->index; \ @@ -430,10 +431,10 @@ char *buf) \ { \ struct sensor_device_attribute *sensor_attr= to_sensor_dev_attr(attr); \ - int nr = sensor_attr->index; \ + int nr = sensor_attr->index - 1; \ struct w83792d_data *data = w83792d_update_device(dev); \ return sprintf(buf,"%ld\n", \ - FAN_FROM_REG(data->reg[nr-1], (long)DIV_FROM_REG(data->fan_div[nr-1]))); \ + FAN_FROM_REG(data->reg[nr], (long)DIV_FROM_REG(data->fan_div[nr]))); \ } show_fan_reg(fan); @@ -444,16 +445,15 @@ const char *buf, size_t count) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); - int nr = sensor_attr->index; + int nr = sensor_attr->index - 1; struct i2c_client *client = to_i2c_client(dev); struct w83792d_data *data = i2c_get_clientdata(client); u32 val; val = simple_strtoul(buf, NULL, 10); - data->fan_min[nr - 1] = - FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr - 1])); - w83792d_write_value(client, W83792D_REG_FAN_MIN[nr - 1], - data->fan_min[nr - 1]); + data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); + w83792d_write_value(client, W83792D_REG_FAN_MIN[nr], + data->fan_min[nr]); return count; } @@ -660,16 +660,22 @@ char *buf) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); - int nr = sensor_attr->index; + int nr = sensor_attr->index - 1; struct w83792d_data *data = w83792d_update_device(dev); long pwm_enable_tmp = 1; - if (data->pwmenable[nr-1] == 0) { + + switch (data->pwmenable[nr]) { + case 0: pwm_enable_tmp = 1; /* manual mode */ - } else if (data->pwmenable[nr-1] == 1) { - pwm_enable_tmp = 3; /* thermal cruise/Smart Fan I */ - } else if (data->pwmenable[nr-1] == 2) { - pwm_enable_tmp = 2; /* Smart Fan II */ + break; + case 1: + pwm_enable_tmp = 3; /*thermal cruise/Smart Fan I */ + break; + case 2: + pwm_enable_tmp = 2; /* Smart Fan II */ + break; } + return sprintf(buf, "%ld\n", pwm_enable_tmp); } @@ -678,15 +684,14 @@ const char *buf, size_t count) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); - int nr = sensor_attr->index; + int nr = sensor_attr->index - 1; struct i2c_client *client = to_i2c_client(dev); struct w83792d_data *data = i2c_get_clientdata(client); u32 val; val = simple_strtoul(buf, NULL, 10); - - data->pwm[nr-1] = PWM_TO_REG(val); - w83792d_write_value(client, W83792D_REG_PWM[nr-1], data->pwm[nr-1]); + data->pwm[nr] = PWM_TO_REG(val); + w83792d_write_value(client, W83792D_REG_PWM[nr], data->pwm[nr]); return count; } @@ -696,23 +701,22 @@ const char *buf, size_t count) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); - int nr = sensor_attr->index; + int nr = sensor_attr->index - 1; struct i2c_client *client = to_i2c_client(dev); struct w83792d_data *data = i2c_get_clientdata(client); u32 val; u8 fan_cfg_tmp, cfg1_tmp, cfg2_tmp, cfg3_tmp, cfg4_tmp; val = simple_strtoul(buf, NULL, 10); - switch (val) { case 1: - data->pwmenable[nr-1] = 0; /* manual mode */ + data->pwmenable[nr] = 0; /* manual mode */ break; case 2: - data->pwmenable[nr-1] = 2; /* Smart Fan II */ + data->pwmenable[nr] = 2; /* Smart Fan II */ break; case 3: - data->pwmenable[nr-1] = 1; /* thermal cruise/Smart Fan I */ + data->pwmenable[nr] = 1; /* thermal cruise/Smart Fan I */ break; default: return -EINVAL; @@ -764,18 +768,18 @@ const char *buf, size_t count) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); - int nr = sensor_attr->index; + int nr = sensor_attr->index - 1; struct i2c_client *client = to_i2c_client(dev); struct w83792d_data *data = i2c_get_clientdata(client); u32 val; u8 pwm_mode_mask = 0; val = simple_strtoul(buf, NULL, 10); - data->pwm_mode[nr-1] = SENSORS_LIMIT(val, 0, 1); + data->pwm_mode[nr] = SENSORS_LIMIT(val, 0, 1); pwm_mode_mask = w83792d_read_value(client, - W83792D_REG_PWM[nr-1]) & 0x7f; - w83792d_write_value(client, W83792D_REG_PWM[nr-1], - ((data->pwm_mode[nr-1]) << 7) | pwm_mode_mask); + W83792D_REG_PWM[nr]) & 0x7f; + w83792d_write_value(client, W83792D_REG_PWM[nr], + ((data->pwm_mode[nr]) << 7) | pwm_mode_mask); return count; } @@ -863,20 +867,19 @@ const char *buf, size_t count) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); - int nr = sensor_attr->index; + int nr = sensor_attr->index - 1; struct i2c_client *client = to_i2c_client(dev); struct w83792d_data *data = i2c_get_clientdata(client); u32 val; u8 target_tmp=0, target_mask=0; val = simple_strtoul(buf, NULL, 10); - target_tmp = val; target_tmp = target_tmp & 0x7f; - target_mask = w83792d_read_value(client, W83792D_REG_THERMAL[nr-1]) & 0x80; - data->thermal_cruise[nr-1] = SENSORS_LIMIT(target_tmp, 0, 255); - w83792d_write_value(client, W83792D_REG_THERMAL[nr-1], - (data->thermal_cruise[nr-1]) | target_mask); + target_mask = w83792d_read_value(client, W83792D_REG_THERMAL[nr]) & 0x80; + data->thermal_cruise[nr] = SENSORS_LIMIT(target_tmp, 0, 255); + w83792d_write_value(client, W83792D_REG_THERMAL[nr], + (data->thermal_cruise[nr]) | target_mask); return count; } @@ -891,7 +894,8 @@ #define device_create_file_thermal_cruise(client, offset) \ do { \ -device_create_file(&client->dev, &sensor_dev_attr_thermal_cruise##offset.dev_attr); \ +device_create_file(&client->dev, \ +&sensor_dev_attr_thermal_cruise##offset.dev_attr); \ } while (0) @@ -911,23 +915,22 @@ const char *buf, size_t count) { struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); - int nr = sensor_attr->index; + int nr = sensor_attr->index - 1; struct i2c_client *client = to_i2c_client(dev); struct w83792d_data *data = i2c_get_clientdata(client); u32 val; u8 tol_tmp, tol_mask; val = simple_strtoul(buf, NULL, 10); - tol_mask = w83792d_read_value(client, - W83792D_REG_TOLERANCE[nr - 1]) & ((nr == 2) ? 0x0f : 0xf0); + W83792D_REG_TOLERANCE[nr]) & ((nr == 1) ? 0x0f : 0xf0); tol_tmp = SENSORS_LIMIT(val, 0, 15); tol_tmp &= 0x0f; - data->tolerance[nr - 1] = tol_tmp; - if (nr == 2) { + data->tolerance[nr] = tol_tmp; + if (nr == 1) { tol_tmp <<= 4; } - w83792d_write_value(client, W83792D_REG_TOLERANCE[nr - 1], + w83792d_write_value(client, W83792D_REG_TOLERANCE[nr], tol_mask | tol_tmp); return count; @@ -964,20 +967,19 @@ const char *buf, size_t count) { struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); - int nr = sensor_attr->nr; - int index = sensor_attr->index; + int nr = sensor_attr->nr - 1; + int index = sensor_attr->index - 1; struct i2c_client *client = to_i2c_client(dev); struct w83792d_data *data = i2c_get_clientdata(client); u32 val; u8 mask_tmp = 0; val = simple_strtoul(buf, NULL, 10); - - data->sf2_points[index-1][nr-1] = SENSORS_LIMIT(val, 0, 127); - mask_tmp = w83792d_read_value(client, - W83792D_REG_POINTS[index-1][nr-1]) & 0x80; - w83792d_write_value(client, W83792D_REG_POINTS[index-1][nr-1], - mask_tmp|data->sf2_points[index-1][nr-1]); + data->sf2_points[index][nr] = SENSORS_LIMIT(val, 0, 127); + mask_tmp = w83792d_read_value(client, + W83792D_REG_POINTS[index][nr]) & 0x80; + w83792d_write_value(client, W83792D_REG_POINTS[index][nr], + mask_tmp|data->sf2_points[index][nr]); return count; } @@ -1024,24 +1026,22 @@ { struct sensor_device_attribute_2 *sensor_attr = to_sensor_dev_attr_2(attr); int nr = sensor_attr->nr; - int index = sensor_attr->index; + int index = sensor_attr->index - 1; struct i2c_client *client = to_i2c_client(dev); struct w83792d_data *data = i2c_get_clientdata(client); u32 val; u8 mask_tmp=0, level_tmp=0; val = simple_strtoul(buf, NULL, 10); - - data->sf2_levels[index - 1][nr] = - SENSORS_LIMIT((val * 15) / 100, 0, 15); - mask_tmp = w83792d_read_value(client, W83792D_REG_LEVELS[index - 1][nr]) + data->sf2_levels[index][nr] = SENSORS_LIMIT((val * 15) / 100, 0, 15); + mask_tmp = w83792d_read_value(client, W83792D_REG_LEVELS[index][nr]) & ((nr==3) ? 0xf0 : 0x0f); if (nr==3) { - level_tmp = data->sf2_levels[index-1][nr]; + level_tmp = data->sf2_levels[index][nr]; } else { - level_tmp = data->sf2_levels[index-1][nr] << 4; + level_tmp = data->sf2_levels[index][nr] << 4; } - w83792d_write_value(client, W83792D_REG_LEVELS[index-1][nr], level_tmp | mask_tmp); + w83792d_write_value(client, W83792D_REG_LEVELS[index][nr], level_tmp | mask_tmp); return count; } @@ -1206,7 +1206,7 @@ bank. */ if (kind < 0) { if (w83792d_read_value(new_client, W83792D_REG_CONFIG) & 0x80) { - dev_warn(&new_client->dev, "Detection failed at step " + dev_err(&new_client->dev, "Detection failed at step " "3\n"); goto ERROR1; } @@ -1221,8 +1221,9 @@ } /* If Winbond chip, address of chip and W83792D_REG_I2C_ADDR should match */ - if (w83792d_read_value(new_client, W83792D_REG_I2C_ADDR) != address) { - dev_warn(&new_client->dev, "Detection failed " + if (w83792d_read_value(new_client, + W83792D_REG_I2C_ADDR) != address) { + dev_err(&new_client->dev, "Detection failed " "at step 5\n"); goto ERROR1; } @@ -1246,11 +1247,11 @@ if (val1 == 0x7a && address >= 0x2c) { kind = w83792d; } else { - if (kind == 0) - printk - (KERN_WARNING "w83792d: Ignoring 'force' parameter for unknown chip at" - "adapter %d, address 0x%02x\n", - i2c_adapter_id(adapter), address); + if (kind == 0) dev_warn(&new_client->dev, + "w83792d: Ignoring 'force' parameter for" + " unknown chip at adapter %d, address" + " 0x%02x\n", i2c_adapter_id(adapter), + address); goto ERROR1; } } @@ -1258,8 +1259,8 @@ if (kind == w83792d) { client_name = "w83792d"; } else { - dev_warn(&new_client->dev, "w83792d: Internal error: unknown kind (%d)?!?", - kind); + dev_err(&new_client->dev, "w83792d: Internal error: unknown" + " kind (%d)?!?", kind); goto ERROR1; } @@ -1456,7 +1457,7 @@ if (time_after (jiffies - data->last_updated, (unsigned long) (HZ * 3)) || time_before(jiffies, data->last_updated) || !data->valid) { - dev_warn(dev, "Starting device update\n"); + dev_dbg(dev, "Starting device update\n"); /* Update the voltages measured value and limits */ for (i = 0; i < 9; i++) { @@ -1490,7 +1491,8 @@ data->pwmenable[2] = (reg_tmp>>4) & 0x03; for (i = 0; i < 3; i++) { - data->temp1[i] = w83792d_read_value(client, W83792D_REG_TEMP1[i]); + data->temp1[i] = w83792d_read_value(client, + W83792D_REG_TEMP1[i]); } for (i = 0; i < 2; i++) { for (j = 0; j < 6; j++) { @@ -1501,7 +1503,8 @@ /* Update the Fan Divisor */ for (i = 0; i < 4; i++) { - reg_array_tmp[i] = w83792d_read_value(client, W83792D_REG_FAN_DIV[i]); + reg_array_tmp[i] = w83792d_read_value(client, + W83792D_REG_FAN_DIV[i]); } data->fan_div[0] = reg_array_tmp[0] & 0x07; data->fan_div[1] = (reg_array_tmp[0] >> 4) & 0x07; @@ -1533,8 +1536,8 @@ reg_tmp = w83792d_read_value(client, W83792D_REG_TOLERANCE[0]); data->tolerance[0] = reg_tmp & 0x0f; data->tolerance[1] = (reg_tmp >> 4) & 0x0f; - data->tolerance[2] = - w83792d_read_value(client, W83792D_REG_TOLERANCE[2]) & 0x0f; + data->tolerance[2] = w83792d_read_value(client, + W83792D_REG_TOLERANCE[2]) & 0x0f; /* Update Smart Fan II temperature points */ for (i = 0; i < 3; i++) { @@ -1563,48 +1566,49 @@ up(&data->update_lock); #ifdef DEBUG - w83792d_print_debug(data); + w83792d_print_debug(data, dev); #endif return data; } #ifdef DEBUG -static void w83792d_print_debug(struct w83792d_data *data) +static void w83792d_print_debug(struct w83792d_data *data, struct device *dev) { int i=0, j=0; - printk(KERN_DEBUG "==========The following is the debug message...========\n"); - printk(KERN_DEBUG "9 set of Voltages: =====>\n"); + dev_dbg(dev, "==========The following is the debug message...========\n"); + dev_dbg(dev, "9 set of Voltages: =====>\n"); for (i=0; i<=8; i++) { - printk(KERN_DEBUG "vin[%d] is: 0x%x\n", i, data->in[i]); - printk(KERN_DEBUG "vin[%d] max is: 0x%x\n", i, data->in_max[i]); - printk(KERN_DEBUG "vin[%d] min is: 0x%x\n", i, data->in_min[i]); - } - printk(KERN_DEBUG "Low Bit1 is: 0x%x\n", data->low_bits[0]); - printk(KERN_DEBUG "Low Bit2 is: 0x%x\n", data->low_bits[1]); - printk(KERN_DEBUG "7 set of Fan Counts and Duty Cycles: =====>\n"); + dev_dbg(dev, "vin[%d] is: 0x%x\n", i, data->in[i]); + dev_dbg(dev, "vin[%d] max is: 0x%x\n", i, data->in_max[i]); + dev_dbg(dev, "vin[%d] min is: 0x%x\n", i, data->in_min[i]); + } + dev_dbg(dev, "Low Bit1 is: 0x%x\n", data->low_bits[0]); + dev_dbg(dev, "Low Bit2 is: 0x%x\n", data->low_bits[1]); + dev_dbg(dev, "7 set of Fan Counts and Duty Cycles: =====>\n"); for (i=0; i<=6; i++) { - printk(KERN_DEBUG "fan[%d] is: 0x%x\n", i, data->fan[i]); - printk(KERN_DEBUG "fan[%d] min is: 0x%x\n", i, data->fan_min[i]); - printk(KERN_DEBUG "pwm[%d] is: 0x%x\n", i, data->pwm[i]); - printk(KERN_DEBUG "pwm_mode[%d] is: 0x%x\n", i, data->pwm_mode[i]); + dev_dbg(dev, "fan[%d] is: 0x%x\n", i, data->fan[i]); + dev_dbg(dev, "fan[%d] min is: 0x%x\n", i, data->fan_min[i]); + dev_dbg(dev, "pwm[%d] is: 0x%x\n", i, data->pwm[i]); + dev_dbg(dev, "pwm_mode[%d] is: 0x%x\n", i, data->pwm_mode[i]); } - printk(KERN_DEBUG "3 set of Temperatures: =====>\n"); + dev_dbg(dev, "3 set of Temperatures: =====>\n"); for (i=0; i<=3; i++) { - printk(KERN_DEBUG "temp1[%d] is: 0x%x\n", i, data->temp1[i]); + dev_dbg(dev, "temp1[%d] is: 0x%x\n", i, data->temp1[i]); } for (i=0; i<=2; i++) { for (j=0; j<=6; j++) { - printk(KERN_DEBUG "temp_add[%d][%d] is: 0x%x\n", i, j, data->temp_add[i][j]); + dev_dbg(dev, "temp_add[%d][%d] is: 0x%x\n", i, j, + data->temp_add[i][j]); } } for (i=0; i<=6; i++) { - printk(KERN_DEBUG "fan_div[%d] is: 0x%x\n", i, data->fan_div[i]); + dev_dbg(dev, "fan_div[%d] is: 0x%x\n", i, data->fan_div[i]); } - printk(KERN_DEBUG "==========End of the debug message...==================\n"); - printk(KERN_DEBUG "\n"); + dev_dbg(dev, "==========End of the debug message...==================\n"); + dev_dbg(dev, "\n"); } #endif