Skip to content

Commit

Permalink
[PATCH] I2C: Separate non-i2c hwmon drivers from i2c-core (3/9)
Browse files Browse the repository at this point in the history
Convert the 10 ISA hardware monitoring drivers (it87, lm78, pc87360,
sis5595, smsc47b397, smsc47m1, via686a, w83627hf, w83627ehf, w83781d) to
explicitely register with i2c-isa. For hybrid drivers (it87, lm78,
w83781d), we now have two separate instances of i2c_driver, one for the
I2C interface of the chip, and one for ISA interface. In the long run,
the one for ISA will be replaced with a different driver type.

At this point, all drivers are working again, except for missing
dependencies in Kconfig.

Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Jean Delvare authored and gregkh committed Sep 5, 2005
1 parent 400c455 commit fde0950
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 24 deletions.
29 changes: 25 additions & 4 deletions drivers/hwmon/it87.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <linux/slab.h>
#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-sysfs.h>
Expand Down Expand Up @@ -242,6 +243,14 @@ static struct i2c_driver it87_driver = {
.detach_client = it87_detach_client,
};

static struct i2c_driver it87_isa_driver = {
.owner = THIS_MODULE,
.name = "it87-isa",
.attach_adapter = it87_attach_adapter,
.detach_client = it87_detach_client,
};


static ssize_t show_in(struct device *dev, struct device_attribute *attr,
char *buf)
{
Expand Down Expand Up @@ -741,7 +750,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)

/* Reserve the ISA region */
if (is_isa)
if (!request_region(address, IT87_EXTENT, it87_driver.name))
if (!request_region(address, IT87_EXTENT, it87_isa_driver.name))
goto ERROR0;

/* Probe whether there is anything available on this address. Already
Expand Down Expand Up @@ -787,7 +796,7 @@ int it87_detect(struct i2c_adapter *adapter, int address, int kind)
i2c_set_clientdata(new_client, data);
new_client->addr = address;
new_client->adapter = adapter;
new_client->driver = &it87_driver;
new_client->driver = is_isa ? &it87_isa_driver : &it87_driver;
new_client->flags = 0;

/* Now, we do the remaining detection. */
Expand Down Expand Up @@ -1172,16 +1181,28 @@ static struct it87_data *it87_update_device(struct device *dev)

static int __init sm_it87_init(void)
{
int addr;
int addr, res;

if (!it87_find(&addr)) {
normal_isa[0] = addr;
}
return i2c_add_driver(&it87_driver);

res = i2c_add_driver(&it87_driver);
if (res)
return res;

res = i2c_isa_add_driver(&it87_isa_driver);
if (res) {
i2c_del_driver(&it87_driver);
return res;
}

return 0;
}

static void __exit sm_it87_exit(void)
{
i2c_isa_del_driver(&it87_isa_driver);
i2c_del_driver(&it87_driver);
}

Expand Down
29 changes: 26 additions & 3 deletions drivers/hwmon/lm78.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-isa.h>
#include <linux/i2c-sensor.h>
#include <linux/hwmon.h>
#include <linux/err.h>
Expand Down Expand Up @@ -177,6 +178,14 @@ static struct i2c_driver lm78_driver = {
.detach_client = lm78_detach_client,
};

static struct i2c_driver lm78_isa_driver = {
.owner = THIS_MODULE,
.name = "lm78-isa",
.attach_adapter = lm78_attach_adapter,
.detach_client = lm78_detach_client,
};


/* 7 Voltages */
static ssize_t show_in(struct device *dev, char *buf, int nr)
{
Expand Down Expand Up @@ -488,7 +497,8 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)

/* Reserve the ISA region */
if (is_isa)
if (!request_region(address, LM78_EXTENT, lm78_driver.name)) {
if (!request_region(address, LM78_EXTENT,
lm78_isa_driver.name)) {
err = -EBUSY;
goto ERROR0;
}
Expand Down Expand Up @@ -543,7 +553,7 @@ int lm78_detect(struct i2c_adapter *adapter, int address, int kind)
i2c_set_clientdata(new_client, data);
new_client->addr = address;
new_client->adapter = adapter;
new_client->driver = &lm78_driver;
new_client->driver = is_isa ? &lm78_isa_driver : &lm78_driver;
new_client->flags = 0;

/* Now, we do the remaining detection. */
Expand Down Expand Up @@ -788,11 +798,24 @@ static struct lm78_data *lm78_update_device(struct device *dev)

static int __init sm_lm78_init(void)
{
return i2c_add_driver(&lm78_driver);
int res;

res = i2c_add_driver(&lm78_driver);
if (res)
return res;

res = i2c_isa_add_driver(&lm78_isa_driver);
if (res) {
i2c_del_driver(&lm78_driver);
return res;
}

return 0;
}

static void __exit sm_lm78_exit(void)
{
i2c_isa_del_driver(&lm78_isa_driver);
i2c_del_driver(&lm78_driver);
}

Expand Down
5 changes: 3 additions & 2 deletions drivers/hwmon/pc87360.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <linux/slab.h>
#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>
Expand Down Expand Up @@ -1344,12 +1345,12 @@ static int __init pc87360_init(void)
return -ENODEV;
}

return i2c_add_driver(&pc87360_driver);
return i2c_isa_add_driver(&pc87360_driver);
}

static void __exit pc87360_exit(void)
{
i2c_del_driver(&pc87360_driver);
i2c_isa_del_driver(&pc87360_driver);
}


Expand Down
5 changes: 3 additions & 2 deletions drivers/hwmon/sis5595.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include <linux/ioport.h>
#include <linux/pci.h>
#include <linux/i2c.h>
#include <linux/i2c-isa.h>
#include <linux/i2c-sensor.h>
#include <linux/hwmon.h>
#include <linux/err.h>
Expand Down Expand Up @@ -790,7 +791,7 @@ static int __devinit sis5595_pci_probe(struct pci_dev *dev,
normal_isa[0] = addr;

s_bridge = pci_dev_get(dev);
if (i2c_add_driver(&sis5595_driver)) {
if (i2c_isa_add_driver(&sis5595_driver)) {
pci_dev_put(s_bridge);
s_bridge = NULL;
}
Expand All @@ -817,7 +818,7 @@ static void __exit sm_sis5595_exit(void)
{
pci_unregister_driver(&sis5595_pci_driver);
if (s_bridge != NULL) {
i2c_del_driver(&sis5595_driver);
i2c_isa_del_driver(&sis5595_driver);
pci_dev_put(s_bridge);
s_bridge = NULL;
}
Expand Down
5 changes: 3 additions & 2 deletions drivers/hwmon/smsc47b397.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/ioport.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-isa.h>
#include <linux/i2c-sensor.h>
#include <linux/hwmon.h>
#include <linux/err.h>
Expand Down Expand Up @@ -350,12 +351,12 @@ static int __init smsc47b397_init(void)
if ((ret = smsc47b397_find(normal_isa)))
return ret;

return i2c_add_driver(&smsc47b397_driver);
return i2c_isa_add_driver(&smsc47b397_driver);
}

static void __exit smsc47b397_exit(void)
{
i2c_del_driver(&smsc47b397_driver);
i2c_isa_del_driver(&smsc47b397_driver);
}

MODULE_AUTHOR("Mark M. Hoffman <[email protected]>");
Expand Down
5 changes: 3 additions & 2 deletions drivers/hwmon/smsc47m1.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <linux/ioport.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-isa.h>
#include <linux/i2c-sensor.h>
#include <linux/hwmon.h>
#include <linux/err.h>
Expand Down Expand Up @@ -592,12 +593,12 @@ static int __init sm_smsc47m1_init(void)
return -ENODEV;
}

return i2c_add_driver(&smsc47m1_driver);
return i2c_isa_add_driver(&smsc47m1_driver);
}

static void __exit sm_smsc47m1_exit(void)
{
i2c_del_driver(&smsc47m1_driver);
i2c_isa_del_driver(&smsc47m1_driver);
}

MODULE_AUTHOR("Mark D. Studebaker <[email protected]>");
Expand Down
5 changes: 3 additions & 2 deletions drivers/hwmon/via686a.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/pci.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/i2c-isa.h>
#include <linux/i2c-sensor.h>
#include <linux/hwmon.h>
#include <linux/err.h>
Expand Down Expand Up @@ -846,7 +847,7 @@ static int __devinit via686a_pci_probe(struct pci_dev *dev,
normal_isa[0] = addr;

s_bridge = pci_dev_get(dev);
if (i2c_add_driver(&via686a_driver)) {
if (i2c_isa_add_driver(&via686a_driver)) {
pci_dev_put(s_bridge);
s_bridge = NULL;
}
Expand All @@ -873,7 +874,7 @@ static void __exit sm_via686a_exit(void)
{
pci_unregister_driver(&via686a_pci_driver);
if (s_bridge != NULL) {
i2c_del_driver(&via686a_driver);
i2c_isa_del_driver(&via686a_driver);
pci_dev_put(s_bridge);
s_bridge = NULL;
}
Expand Down
5 changes: 3 additions & 2 deletions drivers/hwmon/w83627ehf.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
#include <linux/i2c-isa.h>
#include <linux/i2c-sensor.h>
#include <linux/hwmon.h>
#include <linux/err.h>
Expand Down Expand Up @@ -847,12 +848,12 @@ static int __init sensors_w83627ehf_init(void)
&& w83627ehf_find(0x4e, &normal_isa[0]))
return -ENODEV;

return i2c_add_driver(&w83627ehf_driver);
return i2c_isa_add_driver(&w83627ehf_driver);
}

static void __exit sensors_w83627ehf_exit(void)
{
i2c_del_driver(&w83627ehf_driver);
i2c_isa_del_driver(&w83627ehf_driver);
}

MODULE_AUTHOR("Jean Delvare <[email protected]>");
Expand Down
5 changes: 3 additions & 2 deletions drivers/hwmon/w83627hf.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <linux/slab.h>
#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>
Expand Down Expand Up @@ -1507,12 +1508,12 @@ static int __init sensors_w83627hf_init(void)
}
normal_isa[0] = addr;

return i2c_add_driver(&w83627hf_driver);
return i2c_isa_add_driver(&w83627hf_driver);
}

static void __exit sensors_w83627hf_exit(void)
{
i2c_del_driver(&w83627hf_driver);
i2c_isa_del_driver(&w83627hf_driver);
}

MODULE_AUTHOR("Frodo Looijaard <[email protected]>, "
Expand Down
28 changes: 25 additions & 3 deletions drivers/hwmon/w83781d.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <linux/slab.h>
#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>
Expand Down Expand Up @@ -276,6 +277,14 @@ static struct i2c_driver w83781d_driver = {
.detach_client = w83781d_detach_client,
};

static struct i2c_driver w83781d_isa_driver = {
.owner = THIS_MODULE,
.name = "w83781d-isa",
.attach_adapter = w83781d_attach_adapter,
.detach_client = w83781d_detach_client,
};


/* following are the sysfs callback functions */
#define show_in_reg(reg) \
static ssize_t show_##reg (struct device *dev, char *buf, int nr) \
Expand Down Expand Up @@ -1002,7 +1011,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)

if (is_isa)
if (!request_region(address, W83781D_EXTENT,
w83781d_driver.name)) {
w83781d_isa_driver.name)) {
dev_dbg(&adapter->dev, "Request of region "
"0x%x-0x%x for w83781d failed\n", address,
address + W83781D_EXTENT - 1);
Expand Down Expand Up @@ -1060,7 +1069,7 @@ w83781d_detect(struct i2c_adapter *adapter, int address, int kind)
new_client->addr = address;
init_MUTEX(&data->lock);
new_client->adapter = adapter;
new_client->driver = &w83781d_driver;
new_client->driver = is_isa ? &w83781d_isa_driver : &w83781d_driver;
new_client->flags = 0;

/* Now, we do the remaining detection. */
Expand Down Expand Up @@ -1636,12 +1645,25 @@ static struct w83781d_data *w83781d_update_device(struct device *dev)
static int __init
sensors_w83781d_init(void)
{
return i2c_add_driver(&w83781d_driver);
int res;

res = i2c_add_driver(&w83781d_driver);
if (res)
return res;

res = i2c_isa_add_driver(&w83781d_isa_driver);
if (res) {
i2c_del_driver(&w83781d_driver);
return res;
}

return 0;
}

static void __exit
sensors_w83781d_exit(void)
{
i2c_isa_del_driver(&w83781d_isa_driver);
i2c_del_driver(&w83781d_driver);
}

Expand Down

0 comments on commit fde0950

Please sign in to comment.