Skip to content

Commit

Permalink
[PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (5/9)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jean Delvare authored and Greg Kroah-Hartman committed Sep 5, 2005
1 parent 5042c7d commit 2d8672c
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 235 deletions.
16 changes: 11 additions & 5 deletions drivers/hwmon/it87.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x28, 0x29, 0x2a, 0x2b, 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 */
SENSORS_INSMOD_2(it87, it8712);
Expand Down Expand Up @@ -222,7 +223,7 @@ struct it87_data {


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_detach_client(struct i2c_client *client);

Expand All @@ -246,7 +247,7 @@ static struct i2c_driver it87_driver = {
static struct i2c_driver it87_isa_driver = {
.owner = THIS_MODULE,
.name = "it87-isa",
.attach_adapter = it87_attach_adapter,
.attach_adapter = it87_isa_attach_adapter,
.detach_client = it87_detach_client,
};

Expand Down Expand Up @@ -701,7 +702,12 @@ static int it87_attach_adapter(struct i2c_adapter *adapter)
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)
{
int err = -ENODEV;
Expand Down Expand Up @@ -1184,7 +1190,7 @@ static int __init sm_it87_init(void)
int addr, res;

if (!it87_find(&addr)) {
normal_isa[0] = addr;
isa_address = addr;
}

res = i2c_add_driver(&it87_driver);
Expand Down
11 changes: 9 additions & 2 deletions drivers/hwmon/lm78.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ static unsigned short normal_i2c[] = { 0x20, 0x21, 0x22, 0x23, 0x24,
0x25, 0x26, 0x27, 0x28, 0x29,
0x2a, 0x2b, 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 */
SENSORS_INSMOD_2(lm78, lm79);
Expand Down Expand Up @@ -160,6 +161,7 @@ struct lm78_data {


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_detach_client(struct i2c_client *client);

Expand All @@ -181,7 +183,7 @@ static struct i2c_driver lm78_driver = {
static struct i2c_driver lm78_isa_driver = {
.owner = THIS_MODULE,
.name = "lm78-isa",
.attach_adapter = lm78_attach_adapter,
.attach_adapter = lm78_isa_attach_adapter,
.detach_client = lm78_detach_client,
};

Expand Down Expand Up @@ -480,6 +482,11 @@ static int lm78_attach_adapter(struct i2c_adapter *adapter)
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 */
int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
{
Expand Down
38 changes: 9 additions & 29 deletions drivers/hwmon/pc87360.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,17 @@
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-isa.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
#include <linux/hwmon.h>
#include <linux/err.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 unsigned int extra_isa[3];
static unsigned short address;
static unsigned short extra_isa[3];
static u8 confreg[4];

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;
module_param(init, int, 0);
Expand Down Expand Up @@ -228,8 +220,7 @@ struct pc87360_data {
* Functions declaration
*/

static int pc87360_attach_adapter(struct i2c_adapter *adapter);
static int pc87360_detect(struct i2c_adapter *adapter, int address, int kind);
static int pc87360_detect(struct i2c_adapter *adapter);
static int pc87360_detach_client(struct i2c_client *client);

static int pc87360_read_value(struct pc87360_data *data, u8 ldi, u8 bank,
Expand All @@ -246,8 +237,7 @@ static struct pc87360_data *pc87360_update_device(struct device *dev);
static struct i2c_driver pc87360_driver = {
.owner = THIS_MODULE,
.name = "pc87360",
.flags = I2C_DF_NOTIFY,
.attach_adapter = pc87360_attach_adapter,
.attach_adapter = pc87360_detect,
.detach_client = pc87360_detach_client,
};

Expand Down Expand Up @@ -636,12 +626,7 @@ static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL);
* Device detection, registration and update
*/

static int pc87360_attach_adapter(struct i2c_adapter *adapter)
{
return i2c_detect(adapter, &addr_data, pc87360_detect);
}

static int pc87360_find(int sioaddr, u8 *devid, int *address)
static int pc87360_find(int sioaddr, u8 *devid, unsigned short *addresses)
{
u16 val;
int i;
Expand Down Expand Up @@ -687,7 +672,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address)
continue;
}

address[i] = val;
addresses[i] = val;

if (i==0) { /* Fans */
confreg[0] = superio_inb(sioaddr, 0xF0);
Expand Down Expand Up @@ -731,9 +716,7 @@ static int pc87360_find(int sioaddr, u8 *devid, int *address)
return 0;
}

/* We don't really care about the address.
Read from extra_isa instead. */
int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
static int pc87360_detect(struct i2c_adapter *adapter)
{
int i;
struct i2c_client *new_client;
Expand All @@ -742,9 +725,6 @@ int pc87360_detect(struct i2c_adapter *adapter, int address, int kind)
const char *name = "pc87360";
int use_thermistors = 0;

if (!i2c_is_isa_adapter(adapter))
return -ENODEV;

if (!(data = kmalloc(sizeof(struct pc87360_data), GFP_KERNEL)))
return -ENOMEM;
memset(data, 0x00, sizeof(struct pc87360_data));
Expand Down Expand Up @@ -1334,12 +1314,12 @@ static int __init pc87360_init(void)
/* Arbitrarily pick one of the addresses */
for (i = 0; i < 3; i++) {
if (extra_isa[i] != 0x0000) {
normal_isa[0] = extra_isa[i];
address = extra_isa[i];
break;
}
}

if (normal_isa[0] == 0x0000) {
if (address == 0x0000) {
printk(KERN_WARNING "pc87360: No active logical device, "
"module not inserted.\n");
return -ENODEV;
Expand Down
41 changes: 9 additions & 32 deletions drivers/hwmon/sis5595.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,10 @@ module_param(force_addr, ushort, 0);
MODULE_PARM_DESC(force_addr,
"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
our module */
static unsigned short normal_i2c[] = { I2C_CLIENT_END };
static unsigned int normal_isa[] = { 0x0000, I2C_CLIENT_ISA_END };

/* Insmod parameters */
SENSORS_INSMOD_1(sis5595);
static unsigned short address;

/* Many SIS5595 constants specified below */

Expand Down Expand Up @@ -194,8 +190,7 @@ struct sis5595_data {

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, int address, int kind);
static int sis5595_detect(struct i2c_adapter *adapter);
static int sis5595_detach_client(struct i2c_client *client);

static int sis5595_read_value(struct i2c_client *client, u8 register);
Expand All @@ -206,9 +201,7 @@ static void sis5595_init_client(struct i2c_client *client);
static struct i2c_driver sis5595_driver = {
.owner = THIS_MODULE,
.name = "sis5595",
.id = I2C_DRIVERID_SIS5595,
.flags = I2C_DF_NOTIFY,
.attach_adapter = sis5595_attach_adapter,
.attach_adapter = sis5595_detect,
.detach_client = sis5595_detach_client,
};

Expand Down Expand Up @@ -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);

/* This is called when the module is loaded */
static int sis5595_attach_adapter(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)
static int sis5595_detect(struct i2c_adapter *adapter)
{
int err = 0;
int i;
Expand All @@ -496,10 +482,6 @@ int sis5595_detect(struct i2c_adapter *adapter, int address, int kind)
char val;
u16 a;

/* Make sure we are probing the ISA bus!! */
if (!i2c_is_isa_adapter(adapter))
goto exit;

if (force_addr)
address = force_addr & ~(SIS5595_EXTENT - 1);
/* Reserve the ISA region */
Expand Down Expand Up @@ -642,8 +624,7 @@ static int sis5595_detach_client(struct i2c_client *client)
return err;
}

if (i2c_is_isa_client(client))
release_region(client->addr, SIS5595_EXTENT);
release_region(client->addr, SIS5595_EXTENT);

kfree(data);

Expand Down Expand Up @@ -760,7 +741,6 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev,
{
u16 val;
int *i;
int addr = 0;

for (i = blacklist; *i != 0; i++) {
struct pci_dev *dev;
Expand All @@ -776,19 +756,16 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev,
pci_read_config_word(dev, SIS5595_BASE_REG, &val))
return -ENODEV;

addr = val & ~(SIS5595_EXTENT - 1);
if (addr == 0 && force_addr == 0) {
address = val & ~(SIS5595_EXTENT - 1);
if (address == 0 && force_addr == 0) {
dev_err(&dev->dev, "Base address not set - upgrade BIOS or use force_addr=0xaddr\n");
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");
return -ENODEV;
}
normal_isa[0] = addr;

s_bridge = pci_dev_get(dev);
if (i2c_isa_add_driver(&sis5595_driver)) {
Expand Down
Loading

0 comments on commit 2d8672c

Please sign in to comment.