[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    V4L/DVB (11568): cx18: Fix the handling of i2c bus registration error
From:       Linux Kernel Mailing List <linux-kernel () vger ! kernel ! org>
Date:       2009-04-30 4:59:12
Message-ID: 200904300459.n3U4xClp011356 () hera ! kernel ! org
[Download RAW message or body]

Gitweb:     http://git.kernel.org/linus/272aa3966b3244e576c5c07bfff77ea320b89317
Commit:     272aa3966b3244e576c5c07bfff77ea320b89317
Parent:     a357482a1e8fdd39f0a58c33ed2ffd0f1becb825
Author:     Jean Delvare <khali@linux-fr.org>
AuthorDate: Fri Apr 17 10:56:51 2009 -0300
Committer:  Mauro Carvalho Chehab <mchehab@redhat.com>
CommitDate: Wed Apr 29 15:41:13 2009 -0300

    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>
---
 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 b9b7064..8591e4f 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 = {
 /* init + register i2c algo-bit adapter */
 int init_cx18_i2c(struct cx18 *cx)
 {
-	int i;
+	int i, err;
 	CX18_DEBUG_I2C("i2c init\n");
 
 	for (i = 0; i < 2; i++) {
@@ -268,8 +268,18 @@ int init_cx18_i2c(struct cx18 *cx)
 	cx18_call_hw(cx, CX18_HW_GPIO_RESET_CTRL,
 		     core, reset, (u32) CX18_GPIO_RESET_I2C);
 
-	return i2c_bit_add_bus(&cx->i2c_adap[0]) ||
-		i2c_bit_add_bus(&cx->i2c_adap[1]);
+	err = i2c_bit_add_bus(&cx->i2c_adap[0]);
+	if (err)
+		goto err;
+	err = i2c_bit_add_bus(&cx->i2c_adap[1]);
+	if (err)
+		goto err_del_bus_0;
+	return 0;
+
+ err_del_bus_0:
+	i2c_del_adapter(&cx->i2c_adap[0]);
+ err:
+	return err;
 }
 
 void exit_cx18_i2c(struct cx18 *cx)
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic