diff options
author | Jean Delvare <khali@linux-fr.org> | 2008-07-16 13:30:05 -0400 |
---|---|---|
committer | Jean Delvare <khali@mahadeva.delvare> | 2008-07-16 13:30:05 -0400 |
commit | bd4bc3dbded9cd7b2bdca6bba1aecb4251a8039d (patch) | |
tree | 463f7b4283b3924abf504e4db020050bd2b55db5 /drivers/i2c/busses/i2c-amd756-s4882.c | |
parent | 45158894d4d6704afbb4cefe55e5f6ca279fe12a (diff) |
i2c: Clear i2c_adapter.dev on adapter removal
Clear i2c_adapter.dev on adapter removal. This makes it possible to
re-add the adapter at a later point, which some drivers
(i2c-amd756-s4882, i2c-nforce2-s4985) actually do.
This fixes a bug reported by John Stultz here:
http://lkml.org/lkml/2008/7/15/720
and by Ingo Molar there:
http://lkml.org/lkml/2008/7/16/78
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: John Stultz <johnstul@us.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'drivers/i2c/busses/i2c-amd756-s4882.c')
-rw-r--r-- | drivers/i2c/busses/i2c-amd756-s4882.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c index 2f150e33c74c..72872d1e63ef 100644 --- a/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/drivers/i2c/busses/i2c-amd756-s4882.c | |||
@@ -155,6 +155,16 @@ static int __init amd756_s4882_init(void) | |||
155 | int i, error; | 155 | int i, error; |
156 | union i2c_smbus_data ioconfig; | 156 | union i2c_smbus_data ioconfig; |
157 | 157 | ||
158 | /* Configure the PCA9556 multiplexer */ | ||
159 | ioconfig.byte = 0x00; /* All I/O to output mode */ | ||
160 | error = i2c_smbus_xfer(&amd756_smbus, 0x18, 0, I2C_SMBUS_WRITE, 0x03, | ||
161 | I2C_SMBUS_BYTE_DATA, &ioconfig); | ||
162 | if (error) { | ||
163 | dev_err(&amd756_smbus.dev, "PCA9556 configuration failed\n"); | ||
164 | error = -EIO; | ||
165 | goto ERROR0; | ||
166 | } | ||
167 | |||
158 | /* Unregister physical bus */ | 168 | /* Unregister physical bus */ |
159 | error = i2c_del_adapter(&amd756_smbus); | 169 | error = i2c_del_adapter(&amd756_smbus); |
160 | if (error) { | 170 | if (error) { |
@@ -198,22 +208,11 @@ static int __init amd756_s4882_init(void) | |||
198 | s4882_algo[3].smbus_xfer = amd756_access_virt3; | 208 | s4882_algo[3].smbus_xfer = amd756_access_virt3; |
199 | s4882_algo[4].smbus_xfer = amd756_access_virt4; | 209 | s4882_algo[4].smbus_xfer = amd756_access_virt4; |
200 | 210 | ||
201 | /* Configure the PCA9556 multiplexer */ | ||
202 | ioconfig.byte = 0x00; /* All I/O to output mode */ | ||
203 | error = amd756_smbus.algo->smbus_xfer(&amd756_smbus, 0x18, 0, | ||
204 | I2C_SMBUS_WRITE, 0x03, | ||
205 | I2C_SMBUS_BYTE_DATA, &ioconfig); | ||
206 | if (error) { | ||
207 | dev_err(&amd756_smbus.dev, "PCA9556 configuration failed\n"); | ||
208 | error = -EIO; | ||
209 | goto ERROR3; | ||
210 | } | ||
211 | |||
212 | /* Register virtual adapters */ | 211 | /* Register virtual adapters */ |
213 | for (i = 0; i < 5; i++) { | 212 | for (i = 0; i < 5; i++) { |
214 | error = i2c_add_adapter(s4882_adapter+i); | 213 | error = i2c_add_adapter(s4882_adapter+i); |
215 | if (error) { | 214 | if (error) { |
216 | dev_err(&amd756_smbus.dev, | 215 | printk(KERN_ERR "i2c-amd756-s4882: " |
217 | "Virtual adapter %d registration " | 216 | "Virtual adapter %d registration " |
218 | "failed, module not inserted\n", i); | 217 | "failed, module not inserted\n", i); |
219 | for (i--; i >= 0; i--) | 218 | for (i--; i >= 0; i--) |
@@ -252,8 +251,8 @@ static void __exit amd756_s4882_exit(void) | |||
252 | 251 | ||
253 | /* Restore physical bus */ | 252 | /* Restore physical bus */ |
254 | if (i2c_add_adapter(&amd756_smbus)) | 253 | if (i2c_add_adapter(&amd756_smbus)) |
255 | dev_err(&amd756_smbus.dev, "Physical bus restoration " | 254 | printk(KERN_ERR "i2c-amd756-s4882: " |
256 | "failed\n"); | 255 | "Physical bus restoration failed\n"); |
257 | } | 256 | } |
258 | 257 | ||
259 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); | 258 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); |