diff options
author | Jean Delvare <khali@linux-fr.org> | 2009-04-17 09:56:51 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-04-29 14:41:13 -0400 |
commit | 272aa3966b3244e576c5c07bfff77ea320b89317 (patch) | |
tree | a0e8069b696d27fd5a0c38f2ae91355c83069d69 /drivers | |
parent | a357482a1e8fdd39f0a58c33ed2ffd0f1becb825 (diff) |
V4L/DVB (11568): cx18: Fix the handling of i2c bus registration error
* Return actual error values as returned by the i2c subsystem, rather
than 0 or 1.
* If the registration of the second bus fails, unregister the first one
before exiting, otherwise we are leaking resources.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Acked-by: Andy Walls <awalls@radix.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/cx18/cx18-i2c.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c index b9b7064a2be8..8591e4fc359f 100644 --- a/drivers/media/video/cx18/cx18-i2c.c +++ b/drivers/media/video/cx18/cx18-i2c.c | |||
@@ -211,7 +211,7 @@ static struct i2c_algo_bit_data cx18_i2c_algo_template = { | |||
211 | /* init + register i2c algo-bit adapter */ | 211 | /* init + register i2c algo-bit adapter */ |
212 | int init_cx18_i2c(struct cx18 *cx) | 212 | int init_cx18_i2c(struct cx18 *cx) |
213 | { | 213 | { |
214 | int i; | 214 | int i, err; |
215 | CX18_DEBUG_I2C("i2c init\n"); | 215 | CX18_DEBUG_I2C("i2c init\n"); |
216 | 216 | ||
217 | for (i = 0; i < 2; i++) { | 217 | for (i = 0; i < 2; i++) { |
@@ -268,8 +268,18 @@ int init_cx18_i2c(struct cx18 *cx) | |||
268 | cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL, | 268 | cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL, |
269 | core, reset, (u32) CX18_GPIO_RESET_I2C); | 269 | core, reset, (u32) CX18_GPIO_RESET_I2C); |
270 | 270 | ||
271 | return i2c_bit_add_bus(&cx->i2c_adap[0]) || | 271 | err = i2c_bit_add_bus(&cx->i2c_adap[0]); |
272 | i2c_bit_add_bus(&cx->i2c_adap[1]); | 272 | if (err) |
273 | goto err; | ||
274 | err = i2c_bit_add_bus(&cx->i2c_adap[1]); | ||
275 | if (err) | ||
276 | goto err_del_bus_0; | ||
277 | return 0; | ||
278 | |||
279 | err_del_bus_0: | ||
280 | i2c_del_adapter(&cx->i2c_adap[0]); | ||
281 | err: | ||
282 | return err; | ||
273 | } | 283 | } |
274 | 284 | ||
275 | void exit_cx18_i2c(struct cx18 *cx) | 285 | void exit_cx18_i2c(struct cx18 *cx) |