diff options
author | Jean Delvare <khali@linux-fr.org> | 2006-06-12 15:52:02 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-06-22 14:10:35 -0400 |
commit | 455f332323a17446fb66ea7b2f65f2751f1a3f06 (patch) | |
tree | e5e8011731dd00b41bd1dbf035bc9595afa1f114 /drivers/i2c/busses/i2c-i801.c | |
parent | 520e64d5c081c76b77b4ee87d241cd3e40edc43a (diff) |
[PATCH] i2c-i801: Cleanups
i2c-i801: Cleanups
Various cleanups to the i2c-i801 driver:
* Fix documentation file and self file name references.
* i801_setup can be marked __devinit.
* Drop useless error local variable and label in i801_setup.
* Avoid a double PCI configuration register write in some cases.
* Use symbolic names for SMBHSTCFG bits.
* Transmit the error code returned by i801_setup instead of forcing it
to an arbitrary value.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c/busses/i2c-i801.c')
-rw-r--r-- | drivers/i2c/busses/i2c-i801.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index b651493375ca..b9e6fac8142d 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | i801.c - Part of lm_sensors, Linux kernel modules for hardware | 2 | i2c-i801.c - Part of lm_sensors, Linux kernel modules for hardware |
3 | monitoring | 3 | monitoring |
4 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, | 4 | Copyright (c) 1998 - 2002 Frodo Looijaard <frodol@dds.nl>, |
5 | Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker | 5 | Philip Edelbrock <phil@netroedge.com>, and Mark D. Studebaker |
@@ -36,7 +36,7 @@ | |||
36 | This driver supports several versions of Intel's I/O Controller Hubs (ICH). | 36 | This driver supports several versions of Intel's I/O Controller Hubs (ICH). |
37 | For SMBus support, they are similar to the PIIX4 and are part | 37 | For SMBus support, they are similar to the PIIX4 and are part |
38 | of Intel's '810' and other chipsets. | 38 | of Intel's '810' and other chipsets. |
39 | See the doc/busses/i2c-i801 file for details. | 39 | See the file Documentation/i2c/busses/i2c-i801 for details. |
40 | I2C Block Read and Process Call are not supported. | 40 | I2C Block Read and Process Call are not supported. |
41 | */ | 41 | */ |
42 | 42 | ||
@@ -102,9 +102,8 @@ static struct pci_driver i801_driver; | |||
102 | static struct pci_dev *I801_dev; | 102 | static struct pci_dev *I801_dev; |
103 | static int isich4; | 103 | static int isich4; |
104 | 104 | ||
105 | static int i801_setup(struct pci_dev *dev) | 105 | static int __devinit i801_setup(struct pci_dev *dev) |
106 | { | 106 | { |
107 | int error_return = 0; | ||
108 | unsigned char temp; | 107 | unsigned char temp; |
109 | 108 | ||
110 | I801_dev = dev; | 109 | I801_dev = dev; |
@@ -115,7 +114,7 @@ static int i801_setup(struct pci_dev *dev) | |||
115 | else | 114 | else |
116 | isich4 = 0; | 115 | isich4 = 0; |
117 | 116 | ||
118 | /* Determine the address of the SMBus areas */ | 117 | /* Determine the address of the SMBus area */ |
119 | pci_read_config_word(I801_dev, SMBBA, &i801_smba); | 118 | pci_read_config_word(I801_dev, SMBBA, &i801_smba); |
120 | i801_smba &= 0xfff0; | 119 | i801_smba &= 0xfff0; |
121 | if (!i801_smba) { | 120 | if (!i801_smba) { |
@@ -127,20 +126,18 @@ static int i801_setup(struct pci_dev *dev) | |||
127 | if (!request_region(i801_smba, (isich4 ? 16 : 8), i801_driver.name)) { | 126 | if (!request_region(i801_smba, (isich4 ? 16 : 8), i801_driver.name)) { |
128 | dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n", | 127 | dev_err(&dev->dev, "I801_smb region 0x%x already in use!\n", |
129 | i801_smba); | 128 | i801_smba); |
130 | error_return = -EBUSY; | 129 | return -EBUSY; |
131 | goto END; | ||
132 | } | 130 | } |
133 | 131 | ||
134 | pci_read_config_byte(I801_dev, SMBHSTCFG, &temp); | 132 | pci_read_config_byte(I801_dev, SMBHSTCFG, &temp); |
135 | temp &= ~SMBHSTCFG_I2C_EN; /* SMBus timing */ | 133 | temp &= ~SMBHSTCFG_I2C_EN; /* SMBus timing */ |
136 | pci_write_config_byte(I801_dev, SMBHSTCFG, temp); | 134 | if (!(temp & SMBHSTCFG_HST_EN)) { |
137 | |||
138 | if (!(temp & 1)) { | ||
139 | pci_write_config_byte(I801_dev, SMBHSTCFG, temp | 1); | ||
140 | dev_warn(&dev->dev, "enabling SMBus device\n"); | 135 | dev_warn(&dev->dev, "enabling SMBus device\n"); |
136 | temp |= SMBHSTCFG_HST_EN; | ||
141 | } | 137 | } |
138 | pci_write_config_byte(I801_dev, SMBHSTCFG, temp); | ||
142 | 139 | ||
143 | if (temp & 0x02) | 140 | if (temp & SMBHSTCFG_SMB_SMI_EN) |
144 | dev_dbg(&dev->dev, "I801 using Interrupt SMI# for SMBus.\n"); | 141 | dev_dbg(&dev->dev, "I801 using Interrupt SMI# for SMBus.\n"); |
145 | else | 142 | else |
146 | dev_dbg(&dev->dev, "I801 using PCI Interrupt for SMBus.\n"); | 143 | dev_dbg(&dev->dev, "I801 using PCI Interrupt for SMBus.\n"); |
@@ -149,8 +146,7 @@ static int i801_setup(struct pci_dev *dev) | |||
149 | dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp); | 146 | dev_dbg(&dev->dev, "SMBREV = 0x%X\n", temp); |
150 | dev_dbg(&dev->dev, "I801_smba = 0x%X\n", i801_smba); | 147 | dev_dbg(&dev->dev, "I801_smba = 0x%X\n", i801_smba); |
151 | 148 | ||
152 | END: | 149 | return 0; |
153 | return error_return; | ||
154 | } | 150 | } |
155 | 151 | ||
156 | static int i801_transaction(void) | 152 | static int i801_transaction(void) |
@@ -516,12 +512,10 @@ MODULE_DEVICE_TABLE (pci, i801_ids); | |||
516 | 512 | ||
517 | static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id) | 513 | static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id *id) |
518 | { | 514 | { |
515 | int err; | ||
519 | 516 | ||
520 | if (i801_setup(dev)) { | 517 | if ((err = i801_setup(dev))) |
521 | dev_warn(&dev->dev, | 518 | return err; |
522 | "I801 not detected, module not inserted.\n"); | ||
523 | return -ENODEV; | ||
524 | } | ||
525 | 519 | ||
526 | /* set up the driverfs linkage to our parent device */ | 520 | /* set up the driverfs linkage to our parent device */ |
527 | i801_adapter.dev.parent = &dev->dev; | 521 | i801_adapter.dev.parent = &dev->dev; |