Commit 2d8672c5 authored by Jean Delvare's avatar Jean Delvare Committed by Greg Kroah-Hartman

[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: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 5042c7d7
...@@ -48,7 +48,8 @@ ...@@ -48,7 +48,8 @@
/* Addresses to scan */ /* Addresses to scan */
static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d,
0x2e, 0x2f, I2C_CLIENT_END }; 0x2e, 0x2f, I2C_CLIENT_END };
static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
static unsigned short isa_address = 0x290;
/* Insmod parameters */ /* Insmod parameters */
SENSORS_INSMOD_2(it87, it8712); SENSORS_INSMOD_2(it87, it8712);
...@@ -222,7 +223,7 @@ struct it87_data { ...@@ -222,7 +223,7 @@ struct it87_data {
static int it87_attach_adapter(struct i2c_adapter *adapter); static int it87_attach_adapter(struct i2c_adapter *adapter);
static int it87_find(int *address); static int it87_isa_attach_adapter(struct i2c_adapter *adapter);
static int it87_detect(struct i2c_adapter *adapter, int address, int kind); static int it87_detect(struct i2c_adapter *adapter, int address, int kind);
static int it87_detach_client(struct i2c_client *client); static int it87_detach_client(struct i2c_client *client);
...@@ -246,7 +247,7 @@ static struct i2c_driver it87_driver = { ...@@ -246,7 +247,7 @@ static struct i2c_driver it87_driver = {
static struct i2c_driver it87_isa_driver = { static struct i2c_driver it87_isa_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "it87-isa", .name = "it87-isa",
.attach_adapter = it87_attach_adapter, .attach_adapter = it87_isa_attach_adapter,
.detach_client = it87_detach_client, .detach_client = it87_detach_client,
}; };
...@@ -701,7 +702,12 @@ static int it87_attach_adapter(struct i2c_adapter *adapter) ...@@ -701,7 +702,12 @@ static int it87_attach_adapter(struct i2c_adapter *adapter)
return i2c_detect(adapter, &addr_data, it87_detect); return i2c_detect(adapter, &addr_data, it87_detect);
} }
/* SuperIO detection - will change normal_isa[0] if a chip is found */ static int it87_isa_attach_adapter(struct i2c_adapter *adapter)
{
return it87_detect(adapter, isa_address, -1);
}
/* SuperIO detection - will change isa_address if a chip is found */
static int it87_find(int *address) static int it87_find(int *address)
{ {
int err = -ENODEV; int err = -ENODEV;
...@@ -1184,7 +1190,7 @@ static int __init sm_it87_init(void) ...@@ -1184,7 +1190,7 @@ static int __init sm_it87_init(void)
int addr, res; int addr, res;
if (!it87_find(&addr)) { if (!it87_find(&addr)) {
normal_isa[0] = addr; isa_address = addr;
} }
res = i2c_add_driver(&it87_driver); res = i2c_add_driver(&it87_driver);
......
...@@ -34,7 +34,8 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, ...@@ -34,7 +34,8 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24,
0x25, 0x26, 0x27, 0x28, 0x29, 0x25, 0x26, 0x27, 0x28, 0x29,
0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
0x2f, I2C_CLIENT_END }; 0x2f, I2C_CLIENT_END };
static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
static unsigned short isa_address = 0x290;
/* Insmod parameters */ /* Insmod parameters */
SENSORS_INSMOD_2(lm78, lm79); SENSORS_INSMOD_2(lm78, lm79);
...@@ -160,6 +161,7 @@ struct lm78_data { ...@@ -160,6 +161,7 @@ struct lm78_data {
static int lm78_attach_adapter(struct i2c_adapter *adapter); static int lm78_attach_adapter(struct i2c_adapter *adapter);
static int lm78_isa_attach_adapter(struct i2c_adapter *adapter);
static int lm78_detect(struct i2c_adapter *adapter, int address, int kind); static int lm78_detect(struct i2c_adapter *adapter, int address, int kind);
static int lm78_detach_client(struct i2c_client *client); static int lm78_detach_client(struct i2c_client *client);
...@@ -181,7 +183,7 @@ static struct i2c_driver lm78_driver = { ...@@ -181,7 +183,7 @@ static struct i2c_driver lm78_driver = {
static struct i2c_driver lm78_isa_driver = { static struct i2c_driver lm78_isa_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "lm78-isa", .name = "lm78-isa",
.attach_adapter = lm78_attach_adapter, .attach_adapter = lm78_isa_attach_adapter,
.detach_client = lm78_detach_client, .detach_client = lm78_detach_client,
}; };
...@@ -480,6 +482,11 @@ static int lm78_attach_adapter(struct i2c_adapter *adapter) ...@@ -480,6 +482,11 @@ static int lm78_attach_adapter(struct i2c_adapter *adapter)
return i2c_detect(adapter, &addr_data, lm78_detect); return i2c_detect(adapter, &addr_data, lm78_detect);
} }
static int lm78_isa_attach_adapter(struct i2c_adapter *adapter)
{
return lm78_detect(adapter, isa_address, -1);
}
/* This function is called by i2c_detect */ /* This function is called by i2c_detect */
int lm78_detect(struct i2c_adapter *adapter, int address, int kind) int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
{ {
......
...@@ -39,25 +39,17 @@ ...@@ -39,25 +39,17 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-isa.h> #include <linux/i2c-isa.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h> #include <linux/i2c-vid.h>
#include <linux/hwmon.h> #include <linux/hwmon.h>
#include <linux/err.h> #include <linux/err.h>
#include <asm/io.h> #include <asm/io.h>
static unsigned short normal_i2c[] = { I2C_CLIENT_END };
static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
static struct i2c_force_data forces[] = {{ NULL }};
static u8 devid; static u8 devid;
static unsigned int extra_isa[3]; static unsigned short address;
static unsigned short extra_isa[3];
static u8 confreg[4]; static u8 confreg[4];
enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 }; enum chips { any_chip, pc87360, pc87363, pc87364, pc87365, pc87366 };
static struct i2c_address_data addr_data = {
.normal_i2c = normal_i2c,
.normal_isa = normal_isa,
.forces = forces,
};
static int init = 1; static int init = 1;
module_param(init, int, 0); module_param(init, int, 0);
...@@ -228,8 +220,7 @@ struct pc87360_data { ...@@ -228,8 +220,7 @@ struct pc87360_data {
* Functions declaration * Functions declaration
*/ */
static int pc87360_attach_adapter(struct i2c_adapter *adapter); static int pc87360_detect(struct i2c_adapter *adapter);
static int pc87360_detect(struct i2c_adapter *adapter, int address, int kind);
static int pc87360_detach_client(struct i2c_client *client); static int pc87360_detach_client(struct i2c_client *client);
static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank, static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
...@@ -246,8 +237,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev); ...@@ -246,8 +237,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev);
static struct i2c_driver pc87360_driver = { static struct i2c_driver pc87360_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "pc87360", .name = "pc87360",
.flags = I2C_DF_NOTIFY, .attach_adapter = pc87360_detect,
.attach_adapter = pc87360_attach_adapter,
.detach_client = pc87360_detach_client, .detach_client = pc87360_detach_client,
}; };
...@@ -636,12 +626,7 @@ static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL); ...@@ -636,12 +626,7 @@ static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL);
* Device detection, registration and update * Device detection, registration and update
*/ */
static int pc87360_attach_adapter(struct i2c_adapter *adapter) static int pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses)
{
return i2c_detect(adapter, &addr_data, pc87360_detect);
}
static int pc87360_find(int sioaddr, u8 *devid, int *address)
{ {
u16 val; u16 val;
int i; int i;
...@@ -687,7 +672,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address) ...@@ -687,7 +672,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address)
continue; continue;
} }
address[i] = val; addresses[i] = val;
if (i==0) { /* Fans */ if (i==0) { /* Fans */
confreg[0] = superio_inb(sioaddr, 0xF0); confreg[0] = superio_inb(sioaddr, 0xF0);
...@@ -731,9 +716,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address) ...@@ -731,9 +716,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address)
return 0; return 0;
} }
/* We don't really care about the address. static int pc87360_detect(struct i2c_adapter *adapter)
Read from extra_isa instead. */
int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
{ {
int i; int i;
struct i2c_client *new_client; struct i2c_client *new_client;
...@@ -742,9 +725,6 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -742,9 +725,6 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
const char *name = "pc87360"; const char *name = "pc87360";
int use_thermistors = 0; int use_thermistors = 0;
if (!i2c_is_isa_adapter(adapter))
return -ENODEV;
if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL))) if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL)))
return -ENOMEM; return -ENOMEM;
memset(data, 0x00, sizeof(struct pc87360_data)); memset(data, 0x00, sizeof(struct pc87360_data));
...@@ -1334,12 +1314,12 @@ static int __init pc87360_init(void) ...@@ -1334,12 +1314,12 @@ static int __init pc87360_init(void)
/* Arbitrarily pick one of the addresses */ /* Arbitrarily pick one of the addresses */
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (extra_isa[i] != 0x0000) { if (extra_isa[i] != 0x0000) {
normal_isa[0] = extra_isa[i]; address = extra_isa[i];
break; break;
} }
} }
if (normal_isa[0] == 0x0000) { if (address == 0x0000) {
printk(KERN_WARNING "pc87360: No active logical device, " printk(KERN_WARNING "pc87360: No active logical device, "
"module not inserted.\n"); "module not inserted.\n");
return -ENODEV; return -ENODEV;
......
...@@ -71,14 +71,10 @@ module_param(force_addr, ushort, 0); ...@@ -71,14 +71,10 @@ module_param(force_addr, ushort, 0);
MODULE_PARM_DESC(force_addr, MODULE_PARM_DESC(force_addr,
"Initialize the base address of the sensors"); "Initialize the base address of the sensors");
/* Addresses to scan. /* Device address
Note that we can't determine the ISA address until we have initialized Note that we can't determine the ISA address until we have initialized
our module */ our module */
static unsigned short normal_i2c[] = { I2C_CLIENT_END }; static unsigned short address;
static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
/* Insmod parameters */
SENSORS_INSMOD_1(sis5595);
/* Many SIS5595 constants specified below */ /* Many SIS5595 constants specified below */
...@@ -194,8 +190,7 @@ struct sis5595_data { ...@@ -194,8 +190,7 @@ struct sis5595_data {
static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */ static struct pci_dev *s_bridge; /* pointer to the (only) sis5595 */
static int sis5595_attach_adapter(struct i2c_adapter *adapter); static int sis5595_detect(struct i2c_adapter *adapter);
static int sis5595_detect(struct i2c_adapter *adapter, int address, int kind);
static int sis5595_detach_client(struct i2c_client *client); static int sis5595_detach_client(struct i2c_client *client);
static int sis5595_read_value(struct i2c_client *client, u8 register); static int sis5595_read_value(struct i2c_client *client, u8 register);
...@@ -206,9 +201,7 @@ static void sis5595_init_client(struct i2c_client *client); ...@@ -206,9 +201,7 @@ static void sis5595_init_client(struct i2c_client *client);
static struct i2c_driver sis5595_driver = { static struct i2c_driver sis5595_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "sis5595", .name = "sis5595",
.id = I2C_DRIVERID_SIS5595, .attach_adapter = sis5595_detect,
.flags = I2C_DF_NOTIFY,
.attach_adapter = sis5595_attach_adapter,
.detach_client = sis5595_detach_client, .detach_client = sis5595_detach_client,
}; };
...@@ -480,14 +473,7 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch ...@@ -480,14 +473,7 @@ static ssize_t show_alarms(struct device *dev, struct device_attribute *attr, ch
static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
/* This is called when the module is loaded */ /* This is called when the module is loaded */
static int sis5595_attach_adapter(struct i2c_adapter *adapter) static int sis5595_detect(struct i2c_adapter *adapter)
{
if (!(adapter->class & I2C_CLASS_HWMON))
return 0;
return i2c_detect(adapter, &addr_data, sis5595_detect);
}
int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
{ {
int err = 0; int err = 0;
int i; int i;
...@@ -496,10 +482,6 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -496,10 +482,6 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
char val; char val;
u16 a; u16 a;
/* Make sure we are probing the ISA bus!! */
if (!i2c_is_isa_adapter(adapter))
goto exit;
if (force_addr) if (force_addr)
address = force_addr & ~(SIS5595_EXTENT - 1); address = force_addr & ~(SIS5595_EXTENT - 1);
/* Reserve the ISA region */ /* Reserve the ISA region */
...@@ -642,7 +624,6 @@ static int sis5595_detach_client(struct i2c_client *client) ...@@ -642,7 +624,6 @@ static int sis5595_detach_client(struct i2c_client *client)
return err; return err;
} }
if (i2c_is_isa_client(client))
release_region(client->addr, SIS5595_EXTENT); release_region(client->addr, SIS5595_EXTENT);
kfree(data); kfree(data);
...@@ -760,7 +741,6 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev, ...@@ -760,7 +741,6 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev,
{ {
u16 val; u16 val;
int *i; int *i;
int addr = 0;
for (i = blacklist; *i != 0; i++) { for (i = blacklist; *i != 0; i++) {
struct pci_dev *dev; struct pci_dev *dev;
...@@ -776,19 +756,16 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev, ...@@ -776,19 +756,16 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev,
pci_read_config_word(dev, SIS5595_BASE_REG, &val)) pci_read_config_word(dev, SIS5595_BASE_REG, &val))
return -ENODEV; return -ENODEV;
addr = val & ~(SIS5595_EXTENT - 1); address = val & ~(SIS5595_EXTENT - 1);
if (addr == 0 && force_addr == 0) { if (address == 0 && force_addr == 0) {
dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n"); dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n");
return -ENODEV; return -ENODEV;
} }
if (force_addr)
addr = force_addr; /* so detect will get called */
if (!addr) { if (!address) {
dev_err(&dev->dev,"No SiS 5595 sensors found.\n"); dev_err(&dev->dev,"No SiS 5595 sensors found.\n");
return -ENODEV; return -ENODEV;
} }
normal_isa[0] = addr;
s_bridge = pci_dev_get(dev); s_bridge = pci_dev_get(dev);
if (i2c_isa_add_driver(&sis5595_driver)) { if (i2c_isa_add_driver(&sis5595_driver)) {
......
...@@ -32,25 +32,13 @@ ...@@ -32,25 +32,13 @@
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-isa.h> #include <linux/i2c-isa.h>
#include <linux/i2c-sensor.h>
#include <linux/hwmon.h> #include <linux/hwmon.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/init.h> #include <linux/init.h>
#include <asm/io.h> #include <asm/io.h>
static unsigned short normal_i2c[] = { I2C_CLIENT_END };
/* Address is autodetected, there is no default value */ /* Address is autodetected, there is no default value */
static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; static unsigned short address;
static struct i2c_force_data forces[] = {{NULL}};
enum chips { any_chip, smsc47b397 };
static struct i2c_address_data addr_data = {
.normal_i2c = normal_i2c,
.normal_isa = normal_isa,
.probe = normal_i2c, /* cheat */
.ignore = normal_i2c, /* cheat */
.forces = forces,
};
/* Super-I/0 registers and commands */ /* Super-I/0 registers and commands */
...@@ -219,15 +207,6 @@ sysfs_fan(4); ...@@ -219,15 +207,6 @@ sysfs_fan(4);
#define device_create_file_fan(client, num) \ #define device_create_file_fan(client, num) \
device_create_file(&client->dev, &dev_attr_fan##num##_input) device_create_file(&client->dev, &dev_attr_fan##num##_input)
static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind);
static int smsc47b397_attach_adapter(struct i2c_adapter *adapter)
{
if (!(adapter->class & I2C_CLASS_HWMON))
return 0;
return i2c_detect(adapter, &addr_data, smsc47b397_detect);
}
static int smsc47b397_detach_client(struct i2c_client *client) static int smsc47b397_detach_client(struct i2c_client *client)
{ {
struct smsc47b397_data *data = i2c_get_clientdata(client); struct smsc47b397_data *data = i2c_get_clientdata(client);
...@@ -247,27 +226,24 @@ static int smsc47b397_detach_client(struct i2c_client *client) ...@@ -247,27 +226,24 @@ static int smsc47b397_detach_client(struct i2c_client *client)
return 0; return 0;
} }
static int smsc47b397_detect(struct i2c_adapter *adapter);
static struct i2c_driver smsc47b397_driver = { static struct i2c_driver smsc47b397_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "smsc47b397", .name = "smsc47b397",
.id = I2C_DRIVERID_SMSC47B397, .attach_adapter = smsc47b397_detect,
.flags = I2C_DF_NOTIFY,
.attach_adapter = smsc47b397_attach_adapter,
.detach_client = smsc47b397_detach_client, .detach_client = smsc47b397_detach_client,
}; };
static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind) static int smsc47b397_detect(struct i2c_adapter *adapter)
{ {
struct i2c_client *new_client; struct i2c_client *new_client;
struct smsc47b397_data *data; struct smsc47b397_data *data;
int err = 0; int err = 0;
if (!i2c_is_isa_adapter(adapter)) { if (!request_region(address, SMSC_EXTENT, smsc47b397_driver.name)) {
return 0; dev_err(&adapter->dev, "Region 0x%x already in use!\n",
} address);
if (!request_region(addr, SMSC_EXTENT, smsc47b397_driver.name)) {
dev_err(&adapter->dev, "Region 0x%x already in use!\n", addr);
return -EBUSY; return -EBUSY;
} }
...@@ -279,7 +255,7 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind) ...@@ -279,7 +255,7 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
new_client = &data->client; new_client = &data->client;
i2c_set_clientdata(new_client, data); i2c_set_clientdata(new_client, data);
new_client->addr = addr; new_client->addr = address;
init_MUTEX(&data->lock); init_MUTEX(&data->lock);
new_client->adapter = adapter; new_client->adapter = adapter;
new_client->driver = &smsc47b397_driver; new_client->driver = &smsc47b397_driver;
...@@ -315,11 +291,11 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind) ...@@ -315,11 +291,11 @@ static int smsc47b397_detect(struct i2c_adapter *adapter, int addr, int kind)
error_free: error_free:
kfree(data); kfree(data);
error_release: error_release:
release_region(addr, SMSC_EXTENT); release_region(address, SMSC_EXTENT);
return err; return err;
} }
static int __init smsc47b397_find(unsigned int *addr) static int __init smsc47b397_find(unsigned short *addr)
{ {
u8 id, rev; u8 id, rev;
...@@ -348,7 +324,7 @@ static int __init smsc47b397_init(void) ...@@ -348,7 +324,7 @@ static int __init smsc47b397_init(void)
{ {
int ret; int ret;
if ((ret = smsc47b397_find(normal_isa))) if ((ret = smsc47b397_find(&address)))
return ret; return ret;
return i2c_isa_add_driver(&smsc47b397_driver); return i2c_isa_add_driver(&smsc47b397_driver);
......
...@@ -37,17 +37,8 @@ ...@@ -37,17 +37,8 @@
#include <linux/init.h> #include <linux/init.h>
#include <asm/io.h> #include <asm/io.h>
static unsigned short normal_i2c[] = { I2C_CLIENT_END };
/* Address is autodetected, there is no default value */ /* Address is autodetected, there is no default value */
static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END }; static unsigned short address;
static struct i2c_force_data forces[] = {{NULL}};
enum chips { any_chip, smsc47m1 };
static struct i2c_address_data addr_data = {
.normal_i2c = normal_i2c,
.normal_isa = normal_isa,
.forces = forces,
};
/* Super-I/0 registers and commands */ /* Super-I/0 registers and commands */
...@@ -125,9 +116,7 @@ struct smsc47m1_data { ...@@ -125,9 +116,7 @@ struct smsc47m1_data {
}; };
static int smsc47m1_attach_adapter(struct i2c_adapter *adapter); static int smsc47m1_detect(struct i2c_adapter *adapter);
static int smsc47m1_find(int *address);
static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind);
static int smsc47m1_detach_client(struct i2c_client *client); static int smsc47m1_detach_client(struct i2c_client *client);
static int smsc47m1_read_value(struct i2c_client *client, u8 reg); static int smsc47m1_read_value(struct i2c_client *client, u8 reg);
...@@ -140,9 +129,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, ...@@ -140,9 +129,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
static struct i2c_driver smsc47m1_driver = { static struct i2c_driver smsc47m1_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "smsc47m1", .name = "smsc47m1",
.id = I2C_DRIVERID_SMSC47M1, .attach_adapter = smsc47m1_detect,
.flags = I2C_DF_NOTIFY,
.attach_adapter = smsc47m1_attach_adapter,
.detach_client = smsc47m1_detach_client, .detach_client = smsc47m1_detach_client,
}; };
...@@ -358,14 +345,7 @@ fan_present(2); ...@@ -358,14 +345,7 @@ fan_present(2);
static DEVICE_ATTR(alarms, S_IRUGO, get_alarms, NULL); static DEVICE_ATTR(alarms, S_IRUGO, get_alarms, NULL);
static int smsc47m1_attach_adapter(struct i2c_adapter *adapter) static int smsc47m1_find(unsigned short *addr)
{
if (!(adapter->class & I2C_CLASS_HWMON))
return 0;
return i2c_detect(adapter, &addr_data, smsc47m1_detect);
}
static int smsc47m1_find(int *address)
{ {
u8 val; u8 val;
...@@ -392,10 +372,10 @@ static int smsc47m1_find(int *address) ...@@ -392,10 +372,10 @@ static int smsc47m1_find(int *address)
} }
superio_select(); superio_select();
*address = (superio_inb(SUPERIO_REG_BASE) << 8) *addr = (superio_inb(SUPERIO_REG_BASE) << 8)
| superio_inb(SUPERIO_REG_BASE + 1); | superio_inb(SUPERIO_REG_BASE + 1);
val = superio_inb(SUPERIO_REG_ACT); val = superio_inb(SUPERIO_REG_ACT);
if (*address == 0 || (val & 0x01) == 0) { if (*addr == 0 || (val & 0x01) == 0) {
printk(KERN_INFO "smsc47m1: Device is disabled, will not use\n"); printk(KERN_INFO "smsc47m1: Device is disabled, will not use\n");
superio_exit(); superio_exit();
return -ENODEV; return -ENODEV;
...@@ -405,17 +385,13 @@ static int smsc47m1_find(int *address) ...@@ -405,17 +385,13 @@ static int smsc47m1_find(int *address)
return 0; return 0;
} }
static int smsc47m1_detect(struct i2c_adapter *adapter, int address, int kind) static int smsc47m1_detect(struct i2c_adapter *adapter)
{ {
struct i2c_client *new_client; struct i2c_client *new_client;
struct smsc47m1_data *data; struct smsc47m1_data *data;
int err = 0; int err = 0;
int fan1, fan2, pwm1, pwm2; int fan1, fan2, pwm1, pwm2;
if (!i2c_is_isa_adapter(adapter)) {
return 0;
}
if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.name)) { if (!request_region(address, SMSC_EXTENT, smsc47m1_driver.name)) {
dev_err(&adapter->dev, "Region 0x%x already in use!\n", address); dev_err(&adapter->dev, "Region 0x%x already in use!\n", address);
return -EBUSY; return -EBUSY;
...@@ -589,7 +565,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev, ...@@ -589,7 +565,7 @@ static struct smsc47m1_data *smsc47m1_update_device(struct device *dev,
static int __init sm_smsc47m1_init(void) static int __init sm_smsc47m1_init(void)
{ {
if (smsc47m1_find(normal_isa)) { if (smsc47m1_find(&address)) {
return -ENODEV; return -ENODEV;
} }
......
...@@ -50,14 +50,10 @@ module_param(force_addr, ushort, 0); ...@@ -50,14 +50,10 @@ module_param(force_addr, ushort, 0);
MODULE_PARM_DESC(force_addr, MODULE_PARM_DESC(force_addr,
"Initialize the base address of the sensors"); "Initialize the base address of the sensors");
/* Addresses to scan. /* Device address
Note that we can't determine the ISA address until we have initialized Note that we can't determine the ISA address until we have initialized
our module */ our module */
static unsigned short normal_i2c[] = { I2C_CLIENT_END }; static unsigned short address;
static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };
/* Insmod parameters */
SENSORS_INSMOD_1(via686a);
/* /*
The Via 686a southbridge has a LM78-like chip integrated on the same IC. The Via 686a southbridge has a LM78-like chip integrated on the same IC.
...@@ -319,8 +315,7 @@ struct via686a_data { ...@@ -319,8 +315,7 @@ struct via686a_data {
static struct pci_dev *s_bridge; /* pointer to the (only) via686a */ static struct pci_dev *s_bridge; /* pointer to the (only) via686a */
static int via686a_attach_adapter(struct i2c_adapter *adapter); static int via686a_detect(struct i2c_adapter *adapter);
static int via686a_detect(struct i2c_adapter *adapter, int address, int kind);
static int via686a_detach_client(struct i2c_client *client); static int via686a_detach_client(struct i2c_client *client);
static inline int via686a_read_value(struct i2c_client *client, u8 reg) static inline int via686a_read_value(struct i2c_client *client, u8 reg)
...@@ -580,22 +575,13 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); ...@@ -580,22 +575,13 @@ static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
static struct i2c_driver via686a_driver = { static struct i2c_driver via686a_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "via686a", .name = "via686a",
.id = I2C_DRIVERID_VIA686A, .attach_adapter = via686a_detect,
.flags = I2C_DF_NOTIFY,
.attach_adapter = via686a_attach_adapter,
.detach_client = via686a_detach_client, .detach_client = via686a_detach_client,
}; };
/* This is called when the module is loaded */ /* This is called when the module is loaded */
static int via686a_attach_adapter(struct i2c_adapter *adapter) static int via686a_detect(struct i2c_adapter *adapter)
{
if (!(adapter->class & I2C_CLASS_HWMON))
return 0;
return i2c_detect(adapter, &addr_data, via686a_detect);
}
static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
{ {
struct i2c_client *new_client; struct i2c_client *new_client;
struct via686a_data *data; struct via686a_data *data;
...@@ -603,13 +589,6 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -603,13 +589,6 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind)
const char client_name[] = "via686a"; const char client_name[] = "via686a";
u16 val; u16 val;
/* Make sure we are probing the ISA bus!! */
if (!i2c_is_isa_adapter(adapter)) {
dev_err(&adapter->dev,
"via686a_detect called for an I2C bus adapter?!?\n");
return 0;
}
/* 8231 requires multiple of 256, we enforce that on 686 as well */ /* 8231 requires multiple of 256, we enforce that on 686 as well */
if (force_addr) if (force_addr)
address = force_addr & 0xFF00; address = force_addr & 0xFF00;
...@@ -825,26 +804,22 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev, ...@@ -825,26 +804,22 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
u16 val; u16 val;
int addr = 0;
if (PCIBIOS_SUCCESSFUL != if (PCIBIOS_SUCCESSFUL !=
pci_read_config_word(dev, VIA686A_BASE_REG, &val)) pci_read_config_word(dev, VIA686A_BASE_REG, &val))
return -ENODEV; return -ENODEV;
addr = val & ~(VIA686A_EXTENT - 1); address = val & ~(VIA686A_EXTENT - 1);
if (addr == 0 && force_addr == 0) { if (address == 0 && force_addr == 0) {
dev_err(&dev->dev, "base address not set - upgrade BIOS " dev_err(&dev->dev, "base address not set - upgrade BIOS "
"or use force_addr=0xaddr\n"); "or use force_addr=0xaddr\n");
return -ENODEV; return -ENODEV;
} }
if (force_addr)
addr = force_addr; /* so detect will get called */
if (!addr) { if (!address) {
dev_err(&dev->dev, "No Via 686A sensors found.\n"); dev_err(&dev->dev, "No Via 686A sensors found.\n");
return -ENODEV; return -ENODEV;
} }
normal_isa[0] = addr;
s_bridge = pci_dev_get(dev); s_bridge = pci_dev_get(dev);
if (i2c_isa_add_driver(&via686a_driver)) { if (i2c_isa_add_driver(&via686a_driver)) {
......
...@@ -41,19 +41,13 @@ ...@@ -41,19 +41,13 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/i2c-isa.h> #include <linux/i2c-isa.h>
#include <linux/i2c-sensor.h>
#include <linux/hwmon.h> #include <linux/hwmon.h>
#include <linux/err.h> #include <linux/err.h>
#include <asm/io.h> #include <asm/io.h>
#include "lm75.h" #include "lm75.h"
/* Addresses to scan /* The actual ISA address is read from Super-I/O configuration space */
The actual ISA address is read from Super-I/O configuration space */ static unsigned short address;
static unsigned short normal_i2c[] = { I2C_CLIENT_END };
static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
/* Insmod parameters */
SENSORS_INSMOD_1(w83627ehf);
/* /*
* Super-I/O constants and functions * Super-I/O constants and functions
...@@ -673,15 +667,12 @@ static void w83627ehf_init_client(struct i2c_client *client) ...@@ -673,15 +667,12 @@ static void w83627ehf_init_client(struct i2c_client *client)
} }
} }
static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) static int w83627ehf_detect(struct i2c_adapter *adapter)
{ {
struct i2c_client *client; struct i2c_client *client;
struct w83627ehf_data *data; struct w83627ehf_data *data;
int i, err = 0; int i, err = 0;
if (!i2c_is_isa_adapter(adapter))
return 0;
if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) { if (!request_region(address, REGION_LENGTH, w83627ehf_driver.name)) {
err = -EBUSY; err = -EBUSY;
goto exit; goto exit;
...@@ -776,13 +767,6 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind) ...@@ -776,13 +767,6 @@ static int w83627ehf_detect(struct i2c_adapter *adapter, int address, int kind)
return err; return err;
} }
static int w83627ehf_attach_adapter(struct i2c_adapter *adapter)
{
if (!(adapter->class & I2C_CLASS_HWMON))
return 0;
return i2c_detect(adapter, &addr_data, w83627ehf_detect);
}
static int w83627ehf_detach_client(struct i2c_client *client) static int w83627ehf_detach_client(struct i2c_client *client)
{ {
struct w83627ehf_data *data = i2c_get_clientdata(client); struct w83627ehf_data *data = i2c_get_clientdata(client);
...@@ -804,12 +788,11 @@ static int w83627ehf_detach_client(struct i2c_client *client) ...@@ -804,12 +788,11 @@ static int w83627ehf_detach_client(struct i2c_client *client)
static struct i2c_driver w83627ehf_driver = { static struct i2c_driver w83627ehf_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "w83627ehf", .name = "w83627ehf",
.flags = I2C_DF_NOTIFY, .attach_adapter = w83627ehf_detect,
.attach_adapter = w83627ehf_attach_adapter,
.detach_client = w83627ehf_detach_client, .detach_client = w83627ehf_detach_client,
}; };
static int __init w83627ehf_find(int sioaddr, int *address) static int __init w83627ehf_find(int sioaddr, unsigned short *addr)
{ {
u16 val; u16 val;
...@@ -827,8 +810,8 @@ static int __init w83627ehf_find(int sioaddr, int *address) ...@@ -827,8 +810,8 @@ static int __init w83627ehf_find(int sioaddr, int *address)
superio_select(W83627EHF_LD_HWM); superio_select(W83627EHF_LD_HWM);
val = (superio_inb(SIO_REG_ADDR) << 8) val = (superio_inb(SIO_REG_ADDR) << 8)
| superio_inb(SIO_REG_ADDR + 1); | superio_inb(SIO_REG_ADDR + 1);
*address = val & ~(REGION_LENGTH - 1); *addr = val & ~(REGION_LENGTH - 1);
if (*address == 0) { if (*addr == 0) {
superio_exit(); superio_exit();
return -ENODEV; return -ENODEV;
} }
...@@ -844,8 +827,8 @@ static int __init w83627ehf_find(int sioaddr, int *address) ...@@ -844,8 +827,8 @@ static int __init w83627ehf_find(int sioaddr, int *address)
static int __init sensors_w83627ehf_init(void) static int __init sensors_w83627ehf_init(void)
{ {
if (w83627ehf_find(0x2e, &normal_isa[0]) if (w83627ehf_find(0x2e, &address)
&& w83627ehf_find(0x4e, &normal_isa[0])) && w83627ehf_find(0x4e, &address))
return -ENODEV; return -ENODEV;
return i2c_isa_add_driver(&w83627ehf_driver); return i2c_isa_add_driver(&w83627ehf_driver);
......
...@@ -59,12 +59,11 @@ module_param(force_i2c, byte, 0); ...@@ -59,12 +59,11 @@ module_param(force_i2c, byte, 0);
MODULE_PARM_DESC(force_i2c, MODULE_PARM_DESC(force_i2c,
"Initialize the i2c address of the sensors"); "Initialize the i2c address of the sensors");
/* Addresses to scan */ /* The actual ISA address is read from Super-I/O configuration space */
static unsigned short normal_i2c[] = { I2C_CLIENT_END }; static unsigned short address;
static unsigned int normal_isa[] = { 0, I2C_CLIENT_ISA_END };
/* Insmod parameters */ /* Insmod parameters */
SENSORS_INSMOD_4(w83627hf, w83627thf, w83697hf, w83637hf); enum chips { any_chip, w83627hf, w83627thf, w83697hf, w83637hf };
static int init = 1; static int init = 1;
module_param(init, bool, 0); module_param(init, bool, 0);
...@@ -318,9 +317,7 @@ struct w83627hf_data { ...@@ -318,9 +317,7 @@ struct w83627hf_data {
}; };
static int w83627hf_attach_adapter(struct i2c_adapter *adapter); static int w83627hf_detect(struct i2c_adapter *adapter);
static int w83627hf_detect(struct i2c_adapter *adapter, int address,
int kind);
static int w83627hf_detach_client(struct i2c_client *client); static int w83627hf_detach_client(struct i2c_client *client);
static int w83627hf_read_value(struct i2c_client *client, u16 register); static int w83627hf_read_value(struct i2c_client *client, u16 register);
...@@ -332,9 +329,7 @@ static void w83627hf_init_client(struct i2c_client *client); ...@@ -332,9 +329,7 @@ static void w83627hf_init_client(struct i2c_client *client);
static struct i2c_driver w83627hf_driver = { static struct i2c_driver w83627hf_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "w83627hf", .name = "w83627hf",
.id = I2C_DRIVERID_W83627HF, .attach_adapter = w83627hf_detect,
.flags = I2C_DF_NOTIFY,
.attach_adapter = w83627hf_attach_adapter,
.detach_client = w83627hf_detach_client, .detach_client = w83627hf_detach_client,
}; };
...@@ -963,16 +958,7 @@ device_create_file(&client->dev, &dev_attr_temp##offset##_type); \ ...@@ -963,16 +958,7 @@ device_create_file(&client->dev, &dev_attr_temp##offset##_type); \
} while (0) } while (0)
/* This function is called when: static int w83627hf_find(int sioaddr, unsigned short *addr)
* w83627hf_driver is inserted (when this module is loaded), for each
available adapter
* when a new adapter is inserted (and w83627hf_driver is still present) */
static int w83627hf_attach_adapter(struct i2c_adapter *adapter)
{
return i2c_detect(adapter, &addr_data, w83627hf_detect);
}
static int w83627hf_find(int sioaddr, int *address)
{ {
u16 val; u16 val;
...@@ -992,32 +978,24 @@ static int w83627hf_find(int sioaddr, int *address) ...@@ -992,32 +978,24 @@ static int w83627hf_find(int sioaddr, int *address)
superio_select(W83627HF_LD_HWM); superio_select(W83627HF_LD_HWM);
val = (superio_inb(WINB_BASE_REG) << 8) | val = (superio_inb(WINB_BASE_REG) << 8) |
superio_inb(WINB_BASE_REG + 1); superio_inb(WINB_BASE_REG + 1);
*address = val & ~(WINB_EXTENT - 1); *addr = val & ~(WINB_EXTENT - 1);
if (*address == 0 && force_addr == 0) { if (*addr == 0 && force_addr == 0) {
superio_exit(); superio_exit();
return -ENODEV; return -ENODEV;
} }
if (force_addr)
*address = force_addr; /* so detect will get called */
superio_exit(); superio_exit();
return 0; return 0;
} }
int w83627hf_detect(struct i2c_adapter *adapter, int address, static int w83627hf_detect(struct i2c_adapter *adapter)
int kind)
{ {
int val; int val, kind;
struct i2c_client *new_client; struct i2c_client *new_client;
struct w83627hf_data *data; struct w83627hf_data *data;
int err = 0; int err = 0;
const char *client_name = ""; const char *client_name = "";
if (!i2c_is_isa_adapter(adapter)) {
err = -ENODEV;
goto ERROR0;
}
if(force_addr) if(force_addr)
address = force_addr & ~(WINB_EXTENT - 1); address = force_addr & ~(WINB_EXTENT - 1);
...@@ -1500,13 +1478,10 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev) ...@@ -1500,13 +1478,10 @@ static struct w83627hf_data *w83627hf_update_device(struct device *dev)
static int __init sensors_w83627hf_init(void) static int __init sensors_w83627hf_init(void)
{ {
int addr; if (w83627hf_find(0x2e, &address)
&& w83627hf_find(0x4e, &address)) {
if (w83627hf_find(0x2e, &addr)
&& w83627hf_find(0x4e, &addr)) {
return -ENODEV; return -ENODEV;
} }
normal_isa[0] = addr;
return i2c_isa_add_driver(&w83627hf_driver); return i2c_isa_add_driver(&w83627hf_driver);
} }
......
...@@ -50,7 +50,8 @@ ...@@ -50,7 +50,8 @@
static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END }; 0x2c, 0x2d, 0x2e, 0x2f, I2C_CLIENT_END };
static unsigned int normal_isa[] = { 0x0290, I2C_CLIENT_ISA_END }; static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
static unsigned short isa_address = 0x290;
/* Insmod parameters */ /* Insmod parameters */
SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f); SENSORS_INSMOD_5(w83781d, w83782d, w83783s, w83627hf, as99127f);
...@@ -259,6 +260,7 @@ struct w83781d_data { ...@@ -259,6 +260,7 @@ struct w83781d_data {
}; };
static int w83781d_attach_adapter(struct i2c_adapter *adapter); static int w83781d_attach_adapter(struct i2c_adapter *adapter);
static int w83781d_isa_attach_adapter(struct i2c_adapter *adapter);
static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind); static int w83781d_detect(struct i2c_adapter *adapter, int address, int kind);
static int w83781d_detach_client(struct i2c_client *client); static int w83781d_detach_client(struct i2c_client *client);
...@@ -280,7 +282,7 @@ static struct i2c_driver w83781d_driver = { ...@@ -280,7 +282,7 @@ static struct i2c_driver w83781d_driver = {
static struct i2c_driver w83781d_isa_driver = { static struct i2c_driver w83781d_isa_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = "w83781d-isa", .name = "w83781d-isa",
.attach_adapter = w83781d_attach_adapter, .attach_adapter = w83781d_isa_attach_adapter,
.detach_client = w83781d_detach_client, .detach_client = w83781d_detach_client,
}; };
...@@ -871,6 +873,12 @@ w83781d_attach_adapter(struct i2c_adapter *adapter) ...@@ -871,6 +873,12 @@ w83781d_attach_adapter(struct i2c_adapter *adapter)
return i2c_detect(adapter, &addr_data, w83781d_detect); return i2c_detect(adapter, &addr_data, w83781d_detect);
} }
static int
w83781d_isa_attach_adapter(struct i2c_adapter *adapter)
{
return w83781d_detect(adapter, isa_address, -1);
}
/* Assumes that adapter is of I2C, not ISA variety. /* Assumes that adapter is of I2C, not ISA variety.
* OTHERWISE DON'T CALL THIS * OTHERWISE DON'T CALL THIS
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment