--- asc7621.c.orig 2008-07-04 20:33:09.000000000 +0100 +++ asc7621.c 2008-07-05 13:24:12.000000000 +0100 @@ -278,19 +278,16 @@ static ssize_t show_in10(struct device *dev, struct device_attribute *attr, char *buf) { - SETUP_SHOW_data_param(dev, attr); + u8 nr; + unsigned int regval; - u8 nr = sda->index; - u16 regval = (data->reg[param->msb[0]] * asc7621_in_scaling[nr]) / 256; + SETUP_SHOW_data_param(dev, attr); - /* The LSB value is a 2-bit scaling of the MSB's LSbit value. - * I.E. If the maximim voltage for this input is 6640 millivolts then - * a MSB register value of 0 = 0mv and 255 = 6640mv. - * A 1 step change therefore represents 25.9mv (6640 / 256). - * The extra 2-bits therefore represent increments of 6.48mv. - */ - regval += ((asc7621_in_scaling[nr] / 256) / 4) * - (data->reg[param->lsb[0]] >> 6); + nr = sda->index; + /* The LSB value is a 2-bit scaling of the MSB's LSbit value. */ + regval = (data->reg[param->msb[0]] << 2) + + (data->reg[param->lsb[0]] >> 6); + regval = regval * asc7621_in_scaling[nr] / 256 / 4; return sprintf(buf, "%u\n", regval); } @@ -311,12 +308,15 @@ static ssize_t store_in8(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { + u8 nr; + unsigned int reqval; + SETUP_STORE_data_param(dev, attr); - u8 nr = sda->index; - u8 reqval = simple_strtoul(buf, NULL, 10); - reqval = - SENSORS_LIMIT(((reqval * 256) / asc7621_in_scaling[nr]), 0, 255); + nr = sda->index; + reqval = simple_strtoul(buf, NULL, 10); + reqval = reqval * 256 / asc7621_in_scaling[nr]; + reqval = SENSORS_LIMIT(reqval, 0, 255); mutex_lock(&data->update_lock); data->reg[param->msb[0]] = reqval; @@ -385,12 +385,14 @@ struct device_attribute *attr, const char *buf, size_t count) { + s32 reqval; + s32 i, f; + s8 temp; + SETUP_STORE_data_param(dev, attr); - s32 reqval = simple_strtol(buf, NULL, 10); + reqval = simple_strtol(buf, NULL, 10); reqval = SENSORS_LIMIT(reqval, -32000, 31750); - s32 i, f; - s8 temp; i = reqval / 1000; f = reqval - (i * 1000); temp = i << 2; @@ -853,10 +855,10 @@ PWRITE(fan3_min, 2, PRI_LOW, 0x59, 0x58, 0, 0, fan16), PWRITE(fan4_min, 3, PRI_LOW, 0x5b, 0x5a, 0, 0, fan16), - PREAD(fan1_alarm, 0, PRI_LOW, 0x42, 0, 0x01, 0, bitmask), - PREAD(fan2_alarm, 1, PRI_LOW, 0x42, 0, 0x01, 1, bitmask), - PREAD(fan3_alarm, 2, PRI_LOW, 0x42, 0, 0x01, 2, bitmask), - PREAD(fan4_alarm, 3, PRI_LOW, 0x42, 0, 0x01, 3, bitmask), + PREAD(fan1_alarm, 0, PRI_LOW, 0x42, 0, 0x01, 2, bitmask), + PREAD(fan2_alarm, 1, PRI_LOW, 0x42, 0, 0x01, 3, bitmask), + PREAD(fan3_alarm, 2, PRI_LOW, 0x42, 0, 0x01, 4, bitmask), + PREAD(fan4_alarm, 3, PRI_LOW, 0x42, 0, 0x01, 5, bitmask), PREAD(temp1_input, 0, PRI_HIGH, 0x25, 0x10, 0, 0, temp10), PREAD(temp2_input, 1, PRI_HIGH, 0x26, 0x15, 0, 0, temp10), @@ -911,7 +913,7 @@ PWRITE(temp1_smoothing_enable, 0, PRI_LOW, 0x62, 0, 0x01, 3, bitmask), PWRITE(temp2_smoothing_enable, 1, PRI_LOW, 0x63, 0, 0x01, 7, bitmask), - PWRITE(temp3_smoothing_enable, 2, PRI_LOW, 0x64, 0, 0x01, 3, bitmask), + PWRITE(temp3_smoothing_enable, 2, PRI_LOW, 0x63, 0, 0x01, 3, bitmask), PWRITE(temp4_smoothing_enable, 3, PRI_LOW, 0x3c, 0, 0x01, 3, bitmask), PWRITE(temp1_smoothing_time, 0, PRI_LOW, 0x62, 0, 0x07, 0, temp_st), @@ -1047,9 +1049,9 @@ /* Read all the low priority registers. */ if (!data->valid || - time_after(jiffies, data->last_high_reading + INTERVAL_LOW)) { + time_after(jiffies, data->last_low_reading + INTERVAL_LOW)) { - for (i = 0; i < ARRAY_SIZE(asc7621_params); i++) { + for (i = 0; i < ARRAY_SIZE(asc7621_register_priorities); i++) { if (asc7621_register_priorities[i] == PRI_LOW) { data->reg[i] = i2c_smbus_read_byte_data(client, i) & 0xff;