rk: revert 20f3d0b+v3.0.66 to v3.0
[firefly-linux-kernel-4.4.55.git] / drivers / hwmon / w83627ehf.c
index 1198a6e5e8ce8de7ae8d30bca04694efd0a8e28a..f2b377c56a3acda506e1efb21837bfa7138879de 100644 (file)
@@ -390,7 +390,7 @@ temp_from_reg(u16 reg, s16 regval)
 {
        if (is_word_sized(reg))
                return LM75_TEMP_FROM_REG(regval);
-       return ((s8)regval) * 1000;
+       return regval * 1000;
 }
 
 static inline u16
@@ -398,8 +398,7 @@ temp_to_reg(u16 reg, long temp)
 {
        if (is_word_sized(reg))
                return LM75_TEMP_TO_REG(temp);
-       return (s8)DIV_ROUND_CLOSEST(SENSORS_LIMIT(temp, -127000, 128000),
-                                    1000);
+       return DIV_ROUND_CLOSEST(SENSORS_LIMIT(temp, -127000, 128000), 1000);
 }
 
 /* Some of analog inputs have internal scaling (2x), 8mV is ADC LSB */
@@ -1295,7 +1294,6 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
 {
        struct w83627ehf_data *data = dev_get_drvdata(dev);
        struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
-       struct w83627ehf_sio_data *sio_data = dev->platform_data;
        int nr = sensor_attr->index;
        unsigned long val;
        int err;
@@ -1307,11 +1305,6 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr,
 
        if (val > 1)
                return -EINVAL;
-
-       /* On NCT67766F, DC mode is only supported for pwm1 */
-       if (sio_data->kind == nct6776 && nr && val != 1)
-               return -EINVAL;
-
        mutex_lock(&data->update_lock);
        reg = w83627ehf_read_value(data, W83627EHF_REG_PWM_ENABLE[nr]);
        data->pwm_mode[nr] = val;
@@ -1583,7 +1576,7 @@ store_##reg(struct device *dev, struct device_attribute *attr, \
        val = step_time_to_reg(val, data->pwm_mode[nr]); \
        mutex_lock(&data->update_lock); \
        data->reg[nr] = val; \
-       w83627ehf_write_value(data, data->REG_##REG[nr], val); \
+       w83627ehf_write_value(data, W83627EHF_REG_##REG[nr], val); \
        mutex_unlock(&data->update_lock); \
        return count; \
 } \
@@ -1722,8 +1715,7 @@ static void w83627ehf_device_remove_files(struct device *dev)
 }
 
 /* Get the monitoring functions started */
-static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data,
-                                                  enum kinds kind)
+static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data)
 {
        int i;
        u8 tmp, diode;
@@ -1754,26 +1746,10 @@ static inline void __devinit w83627ehf_init_device(struct w83627ehf_data *data,
                w83627ehf_write_value(data, W83627EHF_REG_VBAT, tmp | 0x01);
 
        /* Get thermal sensor types */
-       switch (kind) {
-       case w83627ehf:
-               diode = w83627ehf_read_value(data, W83627EHF_REG_DIODE);
-               break;
-       default:
-               diode = 0x70;
-       }
+       diode = w83627ehf_read_value(data, W83627EHF_REG_DIODE);
        for (i = 0; i < 3; i++) {
-               const char *label = NULL;
-
-               if (data->temp_label)
-                       label = data->temp_label[data->temp_src[i]];
-
-               /* Digital source overrides analog type */
-               if (label && strncmp(label, "PECI", 4) == 0)
-                       data->temp_type[i] = 6;
-               else if (label && strncmp(label, "AMD", 3) == 0)
-                       data->temp_type[i] = 5;
-               else if ((tmp & (0x02 << i)))
-                       data->temp_type[i] = (diode & (0x10 << i)) ? 1 : 3;
+               if ((tmp & (0x02 << i)))
+                       data->temp_type[i] = (diode & (0x10 << i)) ? 1 : 2;
                else
                        data->temp_type[i] = 4; /* thermistor */
        }
@@ -1823,8 +1799,7 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
                goto exit;
        }
 
-       data = devm_kzalloc(&pdev->dev, sizeof(struct w83627ehf_data),
-                           GFP_KERNEL);
+       data = kzalloc(sizeof(struct w83627ehf_data), GFP_KERNEL);
        if (!data) {
                err = -ENOMEM;
                goto exit_release;
@@ -1834,7 +1809,6 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
        mutex_init(&data->lock);
        mutex_init(&data->update_lock);
        data->name = w83627ehf_device_names[sio_data->kind];
-       data->bank = 0xff;              /* Force initial bank selection */
        platform_set_drvdata(pdev, data);
 
        /* 627EHG and 627EHF have 10 voltage inputs; 627DHG and 667HG have 9 */
@@ -2042,7 +2016,7 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
        }
 
        /* Initialize the chip */
-       w83627ehf_init_device(data, sio_data->kind);
+       w83627ehf_init_device(data);
 
        data->vrm = vid_which_vrm();
        superio_enter(sio_data->sioreg);
@@ -2106,29 +2080,9 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
                fan4min = 0;
                fan5pin = 0;
        } else if (sio_data->kind == nct6776) {
-               bool gpok = superio_inb(sio_data->sioreg, 0x27) & 0x80;
-               u8 regval;
-
-               superio_select(sio_data->sioreg, W83627EHF_LD_HWM);
-               regval = superio_inb(sio_data->sioreg, SIO_REG_ENABLE);
-
-               if (regval & 0x80)
-                       fan3pin = gpok;
-               else
-                       fan3pin = !(superio_inb(sio_data->sioreg, 0x24) & 0x40);
-
-               if (regval & 0x40)
-                       fan4pin = gpok;
-               else
-                       fan4pin = !!(superio_inb(sio_data->sioreg, 0x1C)
-                                    & 0x01);
-
-               if (regval & 0x20)
-                       fan5pin = gpok;
-               else
-                       fan5pin = !!(superio_inb(sio_data->sioreg, 0x1C)
-                                    & 0x02);
-
+               fan3pin = !(superio_inb(sio_data->sioreg, 0x24) & 0x40);
+               fan4pin = !!(superio_inb(sio_data->sioreg, 0x1C) & 0x01);
+               fan5pin = !!(superio_inb(sio_data->sioreg, 0x1C) & 0x02);
                fan4min = fan4pin;
        } else if (sio_data->kind == w83667hg || sio_data->kind == w83667hg_b) {
                fan3pin = 1;
@@ -2321,8 +2275,9 @@ static int __devinit w83627ehf_probe(struct platform_device *pdev)
 
 exit_remove:
        w83627ehf_device_remove_files(dev);
-exit_release:
+       kfree(data);
        platform_set_drvdata(pdev, NULL);
+exit_release:
        release_region(res->start, IOREGION_LENGTH);
 exit:
        return err;
@@ -2336,6 +2291,7 @@ static int __devexit w83627ehf_remove(struct platform_device *pdev)
        w83627ehf_device_remove_files(&pdev->dev);
        release_region(data->addr, IOREGION_LENGTH);
        platform_set_drvdata(pdev, NULL);
+       kfree(data);
 
        return 0;
 }