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.c49
1 files changed, 12 insertions, 37 deletions
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index a2c7cea502cb..9e31f5559ccc 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -59,12 +59,11 @@ module_param(force_i2c, byte, 0);
59MODULE_PARM_DESC(force_i2c, 59MODULE_PARM_DESC(force_i2c,
60 "Initialize the i2c address of the sensors"); 60 "Initialize the i2c address of the sensors");
61 61
62/* Addresses to scan */ 62/* The actual ISA address is read from Super-I/O configuration space */
63static unsigned short normal_i2c[] = { I2C_CLIENT_END }; 63static unsigned short address;
64static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
65 64
66/* Insmod parameters */ 65/* Insmod parameters */
67SENSORS_INSMOD_4(w83627hf, w83627thf, w83697hf, w83637hf); 66enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf };
68 67
69static int init = 1; 68static int init = 1;
70module_param(init, bool, 0); 69module_param(init, bool, 0);
@@ -318,9 +317,7 @@ struct w83627hf_data {
318}; 317};
319 318
320 319
321static int w83627hf_attach_adapter(struct i2c_adapter *adapter); 320static int w83627hf_detect(struct i2c_adapter *adapter);
322static int w83627hf_detect(struct i2c_adapter *adapter, int address,
323 int kind);
324static int w83627hf_detach_client(struct i2c_client *client); 321static int w83627hf_detach_client(struct i2c_client *client);
325 322
326static int w83627hf_read_value(struct i2c_client *client, u16 register); 323static int w83627hf_read_value(struct i2c_client *client, u16 register);
@@ -332,9 +329,7 @@ static void w83627hf_init_client(struct i2c_client *client);
332static struct i2c_driver w83627hf_driver = { 329static struct i2c_driver w83627hf_driver = {
333 .owner = THIS_MODULE, 330 .owner = THIS_MODULE,
334 .name = "w83627hf", 331 .name = "w83627hf",
335 .id = I2C_DRIVERID_W83627HF, 332 .attach_adapter = w83627hf_detect,
336 .flags = I2C_DF_NOTIFY,
337 .attach_adapter = w83627hf_attach_adapter,
338 .detach_client = w83627hf_detach_client, 333 .detach_client = w83627hf_detach_client,
339}; 334};
340 335
@@ -963,16 +958,7 @@ device_create_file(&client->dev, &dev_attr_temp##offset##_type); \
963} while (0) 958} while (0)
964 959
965 960
966/* This function is called when: 961static int w83627hf_find(int sioaddr, unsigned short *addr)
967 * w83627hf_driver is inserted (when this module is loaded), for each
968 available adapter
969 * when a new adapter is inserted (and w83627hf_driver is still present) */
970static int w83627hf_attach_adapter(struct i2c_adapter *adapter)
971{
972 return i2c_detect(adapter, &addr_data, w83627hf_detect);
973}
974
975static int w83627hf_find(int sioaddr, int *address)
976{ 962{
977 u16 val; 963 u16 val;
978 964
@@ -992,32 +978,24 @@ static int w83627hf_find(int sioaddr, int *address)
992 superio_select(W83627HF_LD_HWM); 978 superio_select(W83627HF_LD_HWM);
993 val = (superio_inb(WINB_BASE_REG) << 8) | 979 val = (superio_inb(WINB_BASE_REG) << 8) |
994 superio_inb(WINB_BASE_REG + 1); 980 superio_inb(WINB_BASE_REG + 1);
995 *address = val & ~(WINB_EXTENT - 1); 981 *addr = val & ~(WINB_EXTENT - 1);
996 if (*address == 0 && force_addr == 0) { 982 if (*addr == 0 && force_addr == 0) {
997 superio_exit(); 983 superio_exit();
998 return -ENODEV; 984 return -ENODEV;
999 } 985 }
1000 if (force_addr)
1001 *address = force_addr; /* so detect will get called */
1002 986
1003 superio_exit(); 987 superio_exit();
1004 return 0; 988 return 0;
1005} 989}
1006 990
1007int w83627hf_detect(struct i2c_adapter *adapter, int address, 991static int w83627hf_detect(struct i2c_adapter *adapter)
1008 int kind)
1009{ 992{
1010 int val; 993 int val, kind;
1011 struct i2c_client *new_client; 994 struct i2c_client *new_client;
1012 struct w83627hf_data *data; 995 struct w83627hf_data *data;
1013 int err = 0; 996 int err = 0;
1014 const char *client_name = ""; 997 const char *client_name = "";
1015 998
1016 if (!i2c_is_isa_adapter(adapter)) {
1017 err = -ENODEV;
1018 goto ERROR0;
1019 }
1020
1021 if(force_addr) 999 if(force_addr)
1022 address = force_addr & ~(WINB_EXTENT - 1); 1000 address = force_addr & ~(WINB_EXTENT - 1);
1023 1001
@@ -1500,13 +1478,10 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
1500 1478
1501static int __init sensors_w83627hf_init(void) 1479static int __init sensors_w83627hf_init(void)
1502{ 1480{
1503 int addr; 1481 if (w83627hf_find(0x2e, &address)
1504 1482 && w83627hf_find(0x4e, &address)) {
1505 if (w83627hf_find(0x2e, &addr)
1506 && w83627hf_find(0x4e, &addr)) {
1507 return -ENODEV; 1483 return -ENODEV;
1508 } 1484 }
1509 normal_isa[0] = addr;
1510 1485
1511 return i2c_isa_add_driver(&w83627hf_driver); 1486 return i2c_isa_add_driver(&w83627hf_driver);
1512} 1487}