aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2006-06-12 15:53:02 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-06-22 14:10:35 -0400
commit6dcc19dfbc84b2ea5428711b7a47146b5b1788bb (patch)
treef4f9edfc5c66a7ef586e941172c47f2482aa4508 /drivers/i2c
parent455f332323a17446fb66ea7b2f65f2751f1a3f06 (diff)
[PATCH] i2c-i801: Better pci subsystem integration
i2c-i801: Better pci subsystem integration Integrate the i2c-i801 driver better with the pci subsystem, by calling pci_{enable,disable}_device and requesting the I/O region by BAR rather than direct configuration space access. Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-i801.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index b9e6fac8142d..94a30f5de776 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -66,7 +66,7 @@
66#define SMBAUXCTL (13 + i801_smba) /* ICH4 only */ 66#define SMBAUXCTL (13 + i801_smba) /* ICH4 only */
67 67
68/* PCI Address Constants */ 68/* PCI Address Constants */
69#define SMBBA 0x020 69#define SMBBAR 4
70#define SMBHSTCFG 0x040 70#define SMBHSTCFG 0x040
71#define SMBREV 0x008 71#define SMBREV 0x008
72 72
@@ -97,7 +97,7 @@ static int i801_transaction(void);
97static int i801_block_transaction(union i2c_smbus_data *data, char read_write, 97static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
98 int command, int hwpec); 98 int command, int hwpec);
99 99
100static unsigned short i801_smba; 100static unsigned long i801_smba;
101static struct pci_driver i801_driver; 101static struct pci_driver i801_driver;
102static struct pci_dev *I801_dev; 102static struct pci_dev *I801_dev;
103static int isich4; 103static int isich4;
@@ -105,6 +105,7 @@ static int isich4;
105static int __devinit i801_setup(struct pci_dev *dev) 105static int __devinit i801_setup(struct pci_dev *dev)
106{ 106{
107 unsigned char temp; 107 unsigned char temp;
108 int err;
108 109
109 I801_dev = dev; 110 I801_dev = dev;
110 if ((dev->device == PCI_DEVICE_ID_INTEL_82801DB_3) || 111 if ((dev->device == PCI_DEVICE_ID_INTEL_82801DB_3) ||
@@ -114,19 +115,28 @@ static int __devinit i801_setup(struct pci_dev *dev)
114 else 115 else
115 isich4 = 0; 116 isich4 = 0;
116 117
118 err = pci_enable_device(dev);
119 if (err) {
120 dev_err(&dev->dev, "Failed to enable SMBus device (%d)\n",
121 err);
122 goto exit;
123 }
124
117 /* Determine the address of the SMBus area */ 125 /* Determine the address of the SMBus area */
118 pci_read_config_word(I801_dev, SMBBA, &i801_smba); 126 i801_smba = pci_resource_start(dev, SMBBAR);
119 i801_smba &= 0xfff0;
120 if (!i801_smba) { 127 if (!i801_smba) {
121 dev_err(&dev->dev, "SMBus base address uninitialized, " 128 dev_err(&dev->dev, "SMBus base address uninitialized, "
122 "upgrade BIOS\n"); 129 "upgrade BIOS\n");
123 return -ENODEV; 130 err = -ENODEV;
131 goto exit_disable;
124 } 132 }
125 133
126 if (!request_region(i801_smba, (isich4 ? 16 : 8), i801_driver.name)) { 134 err = pci_request_region(dev, SMBBAR, i801_driver.name);
127 dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n", 135 if (err) {
128 i801_smba); 136 dev_err(&dev->dev, "Failed to request SMBus region "
129 return -EBUSY; 137 "0x%lx-0x%lx\n", i801_smba,
138 pci_resource_end(dev, SMBBAR));
139 goto exit_disable;
130 } 140 }
131 141
132 pci_read_config_byte(I801_dev, SMBHSTCFG, &temp); 142 pci_read_config_byte(I801_dev, SMBHSTCFG, &temp);
@@ -147,6 +157,11 @@ static int __devinit i801_setup(struct pci_dev *dev)
147 dev_dbg(&dev->dev, "I801_smba = 0x%X\n", i801_smba); 157 dev_dbg(&dev->dev, "I801_smba = 0x%X\n", i801_smba);
148 158
149 return 0; 159 return 0;
160
161exit_disable:
162 pci_disable_device(dev);
163exit:
164 return err;
150} 165}
151 166
152static int i801_transaction(void) 167static int i801_transaction(void)
@@ -521,14 +536,15 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
521 i801_adapter.dev.parent = &dev->dev; 536 i801_adapter.dev.parent = &dev->dev;
522 537
523 snprintf(i801_adapter.name, I2C_NAME_SIZE, 538 snprintf(i801_adapter.name, I2C_NAME_SIZE,
524 "SMBus I801 adapter at %04x", i801_smba); 539 "SMBus I801 adapter at %04lx", i801_smba);
525 return i2c_add_adapter(&i801_adapter); 540 return i2c_add_adapter(&i801_adapter);
526} 541}
527 542
528static void __devexit i801_remove(struct pci_dev *dev) 543static void __devexit i801_remove(struct pci_dev *dev)
529{ 544{
530 i2c_del_adapter(&i801_adapter); 545 i2c_del_adapter(&i801_adapter);
531 release_region(i801_smba, (isich4 ? 16 : 8)); 546 pci_release_region(dev, SMBBAR);
547 pci_disable_device(dev);
532} 548}
533 549
534static struct pci_driver i801_driver = { 550static struct pci_driver i801_driver = {