- Update to 2.6.25-rc3.
[linux-flexiantxendom0-3.2.10.git] / drivers / hwmon / dme1737.c
index b50a096..6e1e227 100644 (file)
@@ -45,8 +45,12 @@ static int force_start;
 module_param(force_start, bool, 0);
 MODULE_PARM_DESC(force_start, "Force the chip to start monitoring inputs");
 
+static unsigned short force_id;
+module_param(force_id, ushort, 0);
+MODULE_PARM_DESC(force_id, "Override the detected device ID");
+
 /* Addresses to scan */
-static unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END};
+static const unsigned short normal_i2c[] = {0x2c, 0x2d, 0x2e, I2C_CLIENT_END};
 
 /* Insmod parameters */
 I2C_CLIENT_INSMOD_1(dme1737);
@@ -280,14 +284,21 @@ static inline int TEMP_HYST_TO_REG(int val, int ix, int reg)
 /* Fan input RPM */
 static inline int FAN_FROM_REG(int reg, int tpc)
 {
-       return (reg == 0 || reg == 0xffff) ? 0 :
-               (tpc == 0) ? 90000 * 60 / reg : tpc * reg;
+       if (tpc) {
+               return tpc * reg;
+       } else {
+               return (reg == 0 || reg == 0xffff) ? 0 : 90000 * 60 / reg;
+       }
 }
 
 static inline int FAN_TO_REG(int val, int tpc)
 {
-       return SENSORS_LIMIT((tpc == 0) ? 90000 * 60 / val : val / tpc,
-                            0, 0xffff);
+       if (tpc) {
+               return SENSORS_LIMIT(val / tpc, 0, 0xffff);
+       } else {
+               return (val <= 0) ? 0xffff :
+                       SENSORS_LIMIT(90000 * 60 / val, 0, 0xfffe);
+       }
 }
 
 /* Fan TPC (tach pulse count)
@@ -2020,7 +2031,7 @@ static int dme1737_i2c_get_features(int sio_cip, struct dme1737_data *data)
 
        /* Check device ID
         * The DME1737 can return either 0x78 or 0x77 as its device ID. */
-       reg = dme1737_sio_inb(sio_cip, 0x20);
+       reg = force_id ? force_id : dme1737_sio_inb(sio_cip, 0x20);
        if (!(reg == 0x77 || reg == 0x78)) {
                err = -ENODEV;
                goto exit;
@@ -2192,7 +2203,7 @@ static int __init dme1737_isa_detect(int sio_cip, unsigned short *addr)
        /* Check device ID
         * We currently know about SCH3112 (0x7c), SCH3114 (0x7d), and
         * SCH3116 (0x7f). */
-       reg = dme1737_sio_inb(sio_cip, 0x20);
+       reg = force_id ? force_id : dme1737_sio_inb(sio_cip, 0x20);
        if (!(reg == 0x7c || reg == 0x7d || reg == 0x7f)) {
                err = -ENODEV;
                goto exit;