aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83627hf.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/w83627hf.c')
-rw-r--r--drivers/hwmon/w83627hf.c32
1 files changed, 14 insertions, 18 deletions
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 3479dc5208e2..70ef926c3bd8 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -142,10 +142,14 @@ superio_exit(void)
142#define WINB_BASE_REG 0x60 142#define WINB_BASE_REG 0x60
143/* Constants specified below */ 143/* Constants specified below */
144 144
145/* Length of ISA address segment */ 145/* Alignment of the base address */
146#define WINB_EXTENT 8 146#define WINB_ALIGNMENT ~7
147 147
148/* Where are the ISA address/data registers relative to the base address */ 148/* Offset & size of I/O region we are interested in */
149#define WINB_REGION_OFFSET 5
150#define WINB_REGION_SIZE 2
151
152/* Where are the sensors address/data registers relative to the base address */
149#define W83781D_ADDR_REG_OFFSET 5 153#define W83781D_ADDR_REG_OFFSET 5
150#define W83781D_DATA_REG_OFFSET 6 154#define W83781D_DATA_REG_OFFSET 6
151 155
@@ -197,7 +201,6 @@ superio_exit(void)
197 201
198#define W83627HF_REG_PWM1 0x5A 202#define W83627HF_REG_PWM1 0x5A
199#define W83627HF_REG_PWM2 0x5B 203#define W83627HF_REG_PWM2 0x5B
200#define W83627HF_REG_PWMCLK12 0x5C
201 204
202#define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */ 205#define W83627THF_REG_PWM1 0x01 /* 697HF and 637HF too */
203#define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */ 206#define W83627THF_REG_PWM2 0x03 /* 697HF and 637HF too */
@@ -981,7 +984,7 @@ static int __init w83627hf_find(int sioaddr, unsigned short *addr)
981 superio_select(W83627HF_LD_HWM); 984 superio_select(W83627HF_LD_HWM);
982 val = (superio_inb(WINB_BASE_REG) << 8) | 985 val = (superio_inb(WINB_BASE_REG) << 8) |
983 superio_inb(WINB_BASE_REG + 1); 986 superio_inb(WINB_BASE_REG + 1);
984 *addr = val & ~(WINB_EXTENT - 1); 987 *addr = val & WINB_ALIGNMENT;
985 if (*addr == 0 && force_addr == 0) { 988 if (*addr == 0 && force_addr == 0) {
986 superio_exit(); 989 superio_exit();
987 return -ENODEV; 990 return -ENODEV;
@@ -1000,9 +1003,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1000 const char *client_name = ""; 1003 const char *client_name = "";
1001 1004
1002 if(force_addr) 1005 if(force_addr)
1003 address = force_addr & ~(WINB_EXTENT - 1); 1006 address = force_addr & WINB_ALIGNMENT;
1004 1007
1005 if (!request_region(address, WINB_EXTENT, w83627hf_driver.name)) { 1008 if (!request_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE,
1009 w83627hf_driver.name)) {
1006 err = -EBUSY; 1010 err = -EBUSY;
1007 goto ERROR0; 1011 goto ERROR0;
1008 } 1012 }
@@ -1041,11 +1045,10 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1041 client structure, even though we cannot fill it completely yet. 1045 client structure, even though we cannot fill it completely yet.
1042 But it allows us to access w83627hf_{read,write}_value. */ 1046 But it allows us to access w83627hf_{read,write}_value. */
1043 1047
1044 if (!(data = kmalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) { 1048 if (!(data = kzalloc(sizeof(struct w83627hf_data), GFP_KERNEL))) {
1045 err = -ENOMEM; 1049 err = -ENOMEM;
1046 goto ERROR1; 1050 goto ERROR1;
1047 } 1051 }
1048 memset(data, 0, sizeof(struct w83627hf_data));
1049 1052
1050 new_client = &data->client; 1053 new_client = &data->client;
1051 i2c_set_clientdata(new_client, data); 1054 i2c_set_clientdata(new_client, data);
@@ -1148,7 +1151,7 @@ static int w83627hf_detect(struct i2c_adapter *adapter)
1148 ERROR2: 1151 ERROR2:
1149 kfree(data); 1152 kfree(data);
1150 ERROR1: 1153 ERROR1:
1151 release_region(address, WINB_EXTENT); 1154 release_region(address + WINB_REGION_OFFSET, WINB_REGION_SIZE);
1152 ERROR0: 1155 ERROR0:
1153 return err; 1156 return err;
1154} 1157}
@@ -1163,7 +1166,7 @@ static int w83627hf_detach_client(struct i2c_client *client)
1163 if ((err = i2c_detach_client(client))) 1166 if ((err = i2c_detach_client(client)))
1164 return err; 1167 return err;
1165 1168
1166 release_region(client->addr, WINB_EXTENT); 1169 release_region(client->addr + WINB_REGION_OFFSET, WINB_REGION_SIZE);
1167 kfree(data); 1170 kfree(data);
1168 1171
1169 return 0; 1172 return 0;
@@ -1275,7 +1278,6 @@ static int w83627hf_write_value(struct i2c_client *client, u16 reg, u16 value)
1275 return 0; 1278 return 0;
1276} 1279}
1277 1280
1278/* Called when we have found a new W83781D. It should set limits, etc. */
1279static void w83627hf_init_client(struct i2c_client *client) 1281static void w83627hf_init_client(struct i2c_client *client)
1280{ 1282{
1281 struct w83627hf_data *data = i2c_get_clientdata(client); 1283 struct w83627hf_data *data = i2c_get_clientdata(client);
@@ -1369,12 +1371,6 @@ static void w83627hf_init_client(struct i2c_client *client)
1369 } 1371 }
1370 } 1372 }
1371 1373
1372 if (type == w83627hf) {
1373 /* enable PWM2 control (can't hurt since PWM reg
1374 should have been reset to 0xff) */
1375 w83627hf_write_value(client, W83627HF_REG_PWMCLK12,
1376 0x19);
1377 }
1378 /* enable comparator mode for temp2 and temp3 so 1374 /* enable comparator mode for temp2 and temp3 so
1379 alarm indication will work correctly */ 1375 alarm indication will work correctly */
1380 i = w83627hf_read_value(client, W83781D_REG_IRQ); 1376 i = w83627hf_read_value(client, W83781D_REG_IRQ);