summaryrefslogtreecommitdiff
path: root/drivers/hwmon/dme1737.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/dme1737.c')
-rw-r--r--drivers/hwmon/dme1737.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/drivers/hwmon/dme1737.c b/drivers/hwmon/dme1737.c
index a878c98e252e..ddddd9f34c19 100644
--- a/drivers/hwmon/dme1737.c
+++ b/drivers/hwmon/dme1737.c
@@ -44,6 +44,10 @@ 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};
@@ -279,14 +283,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)
@@ -2019,7 +2030,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;
@@ -2191,7 +2202,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;