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-nforce2-s4985.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-nforce2-s4985.c')
-rw-r--r-- | drivers/i2c/busses/i2c-nforce2-s4985.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c index 6a8995dfd0bb..d1a4cbcf2aa4 100644 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c | |||
@@ -150,6 +150,16 @@ static int __init nforce2_s4985_init(void) | |||
150 | int i, error; | 150 | int i, error; |
151 | union i2c_smbus_data ioconfig; | 151 | union i2c_smbus_data ioconfig; |
152 | 152 | ||
153 | /* Configure the PCA9556 multiplexer */ | ||
154 | ioconfig.byte = 0x00; /* All I/O to output mode */ | ||
155 | error = i2c_smbus_xfer(nforce2_smbus, 0x18, 0, I2C_SMBUS_WRITE, 0x03, | ||
156 | I2C_SMBUS_BYTE_DATA, &ioconfig); | ||
157 | if (error) { | ||
158 | dev_err(&nforce2_smbus->dev, "PCA9556 configuration failed\n"); | ||
159 | error = -EIO; | ||
160 | goto ERROR0; | ||
161 | } | ||
162 | |||
153 | /* Unregister physical bus */ | 163 | /* Unregister physical bus */ |
154 | if (!nforce2_smbus) | 164 | if (!nforce2_smbus) |
155 | return -ENODEV; | 165 | return -ENODEV; |
@@ -191,24 +201,13 @@ static int __init nforce2_s4985_init(void) | |||
191 | s4985_algo[3].smbus_xfer = nforce2_access_virt3; | 201 | s4985_algo[3].smbus_xfer = nforce2_access_virt3; |
192 | s4985_algo[4].smbus_xfer = nforce2_access_virt4; | 202 | s4985_algo[4].smbus_xfer = nforce2_access_virt4; |
193 | 203 | ||
194 | /* Configure the PCA9556 multiplexer */ | ||
195 | ioconfig.byte = 0x00; /* All I/O to output mode */ | ||
196 | error = nforce2_smbus->algo->smbus_xfer(nforce2_smbus, 0x18, 0, | ||
197 | I2C_SMBUS_WRITE, 0x03, | ||
198 | I2C_SMBUS_BYTE_DATA, &ioconfig); | ||
199 | if (error) { | ||
200 | dev_err(&nforce2_smbus->dev, "PCA9556 configuration failed\n"); | ||
201 | error = -EIO; | ||
202 | goto ERROR3; | ||
203 | } | ||
204 | |||
205 | /* Register virtual adapters */ | 204 | /* Register virtual adapters */ |
206 | for (i = 0; i < 5; i++) { | 205 | for (i = 0; i < 5; i++) { |
207 | error = i2c_add_adapter(s4985_adapter + i); | 206 | error = i2c_add_adapter(s4985_adapter + i); |
208 | if (error) { | 207 | if (error) { |
209 | dev_err(&nforce2_smbus->dev, | 208 | printk(KERN_ERR "i2c-nforce2-s4985: " |
210 | "Virtual adapter %d registration " | 209 | "Virtual adapter %d registration " |
211 | "failed, module not inserted\n", i); | 210 | "failed, module not inserted\n", i); |
212 | for (i--; i >= 0; i--) | 211 | for (i--; i >= 0; i--) |
213 | i2c_del_adapter(s4985_adapter + i); | 212 | i2c_del_adapter(s4985_adapter + i); |
214 | goto ERROR3; | 213 | goto ERROR3; |
@@ -245,8 +244,8 @@ static void __exit nforce2_s4985_exit(void) | |||
245 | 244 | ||
246 | /* Restore physical bus */ | 245 | /* Restore physical bus */ |
247 | if (i2c_add_adapter(nforce2_smbus)) | 246 | if (i2c_add_adapter(nforce2_smbus)) |
248 | dev_err(&nforce2_smbus->dev, "Physical bus restoration " | 247 | printk(KERN_ERR "i2c-nforce2-s4985: " |
249 | "failed\n"); | 248 | "Physical bus restoration failed\n"); |
250 | } | 249 | } |
251 | 250 | ||
252 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); | 251 | MODULE_AUTHOR("Jean Delvare <khali@linux-fr.org>"); |