aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/smsc47m1.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2005-07-19 17:56:35 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-09-05 12:14:10 -0400
commit2d8672c5a6ba0d3f1d8d3ad61ef67868941364f0 (patch)
treef01f038198bad63fee4c7d23af806ad0ab4e5071 /drivers/hwmon/smsc47m1.c
parent5042c7d752fe72c6924037058367f63902e68c5c (diff)
[PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (5/9)
Call the ISA chip drivers detection function directly instead of relying on i2c_detect. The net effect is that address lists won't be handled anymore, but they were mostly useless in the ISA case anyway (pc87360, smsc47m1, smsc47b397 had already dropped them). We don't need to handle multiple devices, all we may need is a way to force a given address instead of the original one (some drivers already do: sis5595, via686a, w83627hf), and, for drivers supporting multiple chips, a way to force one given kind. All this may be added later on demand, but I actually don't think there will be much demand. Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/smsc47m1.c')
-rw-r--r--drivers/hwmon/smsc47m1.c42
1 files changed, 9 insertions, 33 deletions
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c
index b07d01ecd2e3..8126fdd7cbee 100644
--- a/drivers/hwmon/smsc47m1.c
+++ b/drivers/hwmon/smsc47m1.c
@@ -37,17 +37,8 @@
37#include <linux/init.h> 37#include <linux/init.h>
38#include <asm/io.h> 38#include <asm/io.h>
39 39
40static unsigned short normal_i2c[] = { I2C_CLIENT_END };
41/* Address is autodetected, there is no default value */ 40/* Address is autodetected, there is no default value */
42static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; 41static unsigned short address;
43static struct i2c_force_data forces[] = {{NULL}};
44
45enum chips { any_chip, smsc47m1 };
46static struct i2c_address_data addr_data = {
47 .normal_i2c = normal_i2c,
48 .normal_isa = normal_isa,
49 .forces = forces,
50};
51 42
52/* Super-I/0 registers and commands */ 43/* Super-I/0 registers and commands */
53 44
@@ -125,9 +116,7 @@ struct smsc47m1_data {
125}; 116};
126 117
127 118
128static int smsc47m1_attach_adapter(struct i2c_adapter *adapter); 119static int smsc47m1_detect(struct i2c_adapter *adapter);
129static int smsc47m1_find(int *address);
130static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind);
131static int smsc47m1_detach_client(struct i2c_client *client); 120static int smsc47m1_detach_client(struct i2c_client *client);
132 121
133static int smsc47m1_read_value(struct i2c_client *client, u8 reg); 122static int smsc47m1_read_value(struct i2c_client *client, u8 reg);
@@ -140,9 +129,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
140static struct i2c_driver smsc47m1_driver = { 129static struct i2c_driver smsc47m1_driver = {
141 .owner = THIS_MODULE, 130 .owner = THIS_MODULE,
142 .name = "smsc47m1", 131 .name = "smsc47m1",
143 .id = I2C_DRIVERID_SMSC47M1, 132 .attach_adapter = smsc47m1_detect,
144 .flags = I2C_DF_NOTIFY,
145 .attach_adapter = smsc47m1_attach_adapter,
146 .detach_client = smsc47m1_detach_client, 133 .detach_client = smsc47m1_detach_client,
147}; 134};
148 135
@@ -358,14 +345,7 @@ fan_present(2);
358 345
359static DEVICE_ATTR(alarms, S_IRUGO, get_alarms, NULL); 346static DEVICE_ATTR(alarms, S_IRUGO, get_alarms, NULL);
360 347
361static int smsc47m1_attach_adapter(struct i2c_adapter *adapter) 348static int smsc47m1_find(unsigned short *addr)
362{
363 if (!(adapter->class & I2C_CLASS_HWMON))
364 return 0;
365 return i2c_detect(adapter, &addr_data, smsc47m1_detect);
366}
367
368static int smsc47m1_find(int *address)
369{ 349{
370 u8 val; 350 u8 val;
371 351
@@ -392,10 +372,10 @@ static int smsc47m1_find(int *address)
392 } 372 }
393 373
394 superio_select(); 374 superio_select();
395 *address = (superio_inb(SUPERIO_REG_BASE) << 8) 375 *addr = (superio_inb(SUPERIO_REG_BASE) << 8)
396 | superio_inb(SUPERIO_REG_BASE + 1); 376 | superio_inb(SUPERIO_REG_BASE + 1);
397 val = superio_inb(SUPERIO_REG_ACT); 377 val = superio_inb(SUPERIO_REG_ACT);
398 if (*address == 0 || (val & 0x01) == 0) { 378 if (*addr == 0 || (val & 0x01) == 0) {
399 printk(KERN_INFO "smsc47m1: Device is disabled, will not use\n"); 379 printk(KERN_INFO "smsc47m1: Device is disabled, will not use\n");
400 superio_exit(); 380 superio_exit();
401 return -ENODEV; 381 return -ENODEV;
@@ -405,17 +385,13 @@ static int smsc47m1_find(int *address)
405 return 0; 385 return 0;
406} 386}
407 387
408static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind) 388static int smsc47m1_detect(struct i2c_adapter *adapter)
409{ 389{
410 struct i2c_client *new_client; 390 struct i2c_client *new_client;
411 struct smsc47m1_data *data; 391 struct smsc47m1_data *data;
412 int err = 0; 392 int err = 0;
413 int fan1, fan2, pwm1, pwm2; 393 int fan1, fan2, pwm1, pwm2;
414 394
415 if (!i2c_is_isa_adapter(adapter)) {
416 return 0;
417 }
418
419 if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.name)) { 395 if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.name)) {
420 dev_err(&adapter->dev, "Region 0x%x already in use!\n", address); 396 dev_err(&adapter->dev, "Region 0x%x already in use!\n", address);
421 return -EBUSY; 397 return -EBUSY;
@@ -589,7 +565,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
589 565
590static int __init sm_smsc47m1_init(void) 566static int __init sm_smsc47m1_init(void)
591{ 567{
592 if (smsc47m1_find(normal_isa)) { 568 if (smsc47m1_find(&address)) {
593 return -ENODEV; 569 return -ENODEV;
594 } 570 }
595 571