aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-nforce2-s4985.c
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2008-08-10 16:56:15 -0400
committerJean Delvare <khali@mahadeva.delvare>2008-08-10 16:56:15 -0400
commit399d6b26539d83dd734746dc2292d53fbc5807b2 (patch)
tree3f13ea26c570dafab9c516179da3342cca697858 /drivers/i2c/busses/i2c-nforce2-s4985.c
parent796aadeb1b2db9b5d463946766c5bbfd7717158c (diff)
i2c: Fix oops on bus multiplexer driver loading
The two I2C bus multiplexer drivers (i2c-amd756-s4882 and i2c-nforce2-s4985) make use of the bus they want to multiplex before checking if it is really present. Swap the instructions to test for presence first. This fixes a oops reported by Ingo Molnar. Signed-off-by: Jean Delvare <khali@linux-fr.org> 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.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
index d1a4cbcf2aa4..29015eb9ca46 100644
--- a/drivers/i2c/busses/i2c-nforce2-s4985.c
+++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
@@ -150,6 +150,9 @@ 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 if (!nforce2_smbus)
154 return -ENODEV;
155
153 /* Configure the PCA9556 multiplexer */ 156 /* Configure the PCA9556 multiplexer */
154 ioconfig.byte = 0x00; /* All I/O to output mode */ 157 ioconfig.byte = 0x00; /* All I/O to output mode */
155 error = i2c_smbus_xfer(nforce2_smbus, 0x18, 0, I2C_SMBUS_WRITE, 0x03, 158 error = i2c_smbus_xfer(nforce2_smbus, 0x18, 0, I2C_SMBUS_WRITE, 0x03,
@@ -161,8 +164,6 @@ static int __init nforce2_s4985_init(void)
161 } 164 }
162 165
163 /* Unregister physical bus */ 166 /* Unregister physical bus */
164 if (!nforce2_smbus)
165 return -ENODEV;
166 error = i2c_del_adapter(nforce2_smbus); 167 error = i2c_del_adapter(nforce2_smbus);
167 if (error) { 168 if (error) {
168 dev_err(&nforce2_smbus->dev, "Physical bus removal failed\n"); 169 dev_err(&nforce2_smbus->dev, "Physical bus removal failed\n");