aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/via686a.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/via686a.c')
-rw-r--r--drivers/hwmon/via686a.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/drivers/hwmon/via686a.c b/drivers/hwmon/via686a.c
index 05ddc88e7dd2..6f696f897176 100644
--- a/drivers/hwmon/via686a.c
+++ b/drivers/hwmon/via686a.c
@@ -44,7 +44,7 @@
44 44
45/* If force_addr is set to anything different from 0, we forcibly enable 45/* If force_addr is set to anything different from 0, we forcibly enable
46 the device at the given address. */ 46 the device at the given address. */
47static unsigned short force_addr = 0; 47static unsigned short force_addr;
48module_param(force_addr, ushort, 0); 48module_param(force_addr, ushort, 0);
49MODULE_PARM_DESC(force_addr, 49MODULE_PARM_DESC(force_addr,
50 "Initialize the base address of the sensors"); 50 "Initialize the base address of the sensors");
@@ -198,7 +198,7 @@ static inline u8 FAN_TO_REG(long rpm, int div)
198 but the function is very linear in the useful range (0-80 deg C), so 198 but the function is very linear in the useful range (0-80 deg C), so
199 we'll just use linear interpolation for 10-bit readings.) So, tempLUT 199 we'll just use linear interpolation for 10-bit readings.) So, tempLUT
200 is the temp at via register values 0-255: */ 200 is the temp at via register values 0-255: */
201static const long tempLUT[] = 201static const s16 tempLUT[] =
202{ -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519, 202{ -709, -688, -667, -646, -627, -607, -589, -570, -553, -536, -519,
203 -503, -487, -471, -456, -442, -428, -414, -400, -387, -375, 203 -503, -487, -471, -456, -442, -428, -414, -400, -387, -375,
204 -362, -350, -339, -327, -316, -305, -295, -285, -275, -265, 204 -362, -350, -339, -327, -316, -305, -295, -285, -275, -265,
@@ -270,7 +270,7 @@ static inline u8 TEMP_TO_REG(long val)
270} 270}
271 271
272/* for 8-bit temperature hyst and over registers */ 272/* for 8-bit temperature hyst and over registers */
273#define TEMP_FROM_REG(val) (tempLUT[(val)] * 100) 273#define TEMP_FROM_REG(val) ((long)tempLUT[val] * 100)
274 274
275/* for 10-bit temperature readings */ 275/* for 10-bit temperature readings */
276static inline long TEMP_FROM_REG10(u16 val) 276static inline long TEMP_FROM_REG10(u16 val)
@@ -589,10 +589,8 @@ static int via686a_detect(struct i2c_adapter *adapter)
589 u16 val; 589 u16 val;
590 590
591 /* 8231 requires multiple of 256, we enforce that on 686 as well */ 591 /* 8231 requires multiple of 256, we enforce that on 686 as well */
592 if (force_addr)
593 address = force_addr & 0xFF00;
594
595 if (force_addr) { 592 if (force_addr) {
593 address = force_addr & 0xFF00;
596 dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n", 594 dev_warn(&adapter->dev, "forcing ISA address 0x%04X\n",
597 address); 595 address);
598 if (PCIBIOS_SUCCESSFUL != 596 if (PCIBIOS_SUCCESSFUL !=
@@ -603,11 +601,17 @@ static int via686a_detect(struct i2c_adapter *adapter)
603 pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val)) 601 pci_read_config_word(s_bridge, VIA686A_ENABLE_REG, &val))
604 return -ENODEV; 602 return -ENODEV;
605 if (!(val & 0x0001)) { 603 if (!(val & 0x0001)) {
606 dev_warn(&adapter->dev, "enabling sensors\n"); 604 if (force_addr) {
607 if (PCIBIOS_SUCCESSFUL != 605 dev_info(&adapter->dev, "enabling sensors\n");
608 pci_write_config_word(s_bridge, VIA686A_ENABLE_REG, 606 if (PCIBIOS_SUCCESSFUL !=
609 val | 0x0001)) 607 pci_write_config_word(s_bridge, VIA686A_ENABLE_REG,
608 val | 0x0001))
609 return -ENODEV;
610 } else {
611 dev_warn(&adapter->dev, "sensors disabled - enable "
612 "with force_addr=0x%x\n", address);
610 return -ENODEV; 613 return -ENODEV;
614 }
611 } 615 }
612 616
613 /* Reserve the ISA region */ 617 /* Reserve the ISA region */
@@ -617,11 +621,10 @@ static int via686a_detect(struct i2c_adapter *adapter)
617 return -ENODEV; 621 return -ENODEV;
618 } 622 }
619 623
620 if (!(data = kmalloc(sizeof(struct via686a_data), GFP_KERNEL))) { 624 if (!(data = kzalloc(sizeof(struct via686a_data), GFP_KERNEL))) {
621 err = -ENOMEM; 625 err = -ENOMEM;
622 goto exit_release; 626 goto exit_release;
623 } 627 }
624 memset(data, 0, sizeof(struct via686a_data));
625 628
626 new_client = &data->client; 629 new_client = &data->client;
627 i2c_set_clientdata(new_client, data); 630 i2c_set_clientdata(new_client, data);
@@ -708,7 +711,6 @@ static int via686a_detach_client(struct i2c_client *client)
708 return 0; 711 return 0;
709} 712}
710 713
711/* Called when we have found a new VIA686A. Set limits, etc. */
712static void via686a_init_client(struct i2c_client *client) 714static void via686a_init_client(struct i2c_client *client)
713{ 715{
714 u8 reg; 716 u8 reg;