From patchwork Sat Apr 4 12:26:51 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean Delvare X-Patchwork-Id: 16321 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n34CR2bA010250 for ; Sat, 4 Apr 2009 12:27:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751176AbZDDM1B (ORCPT ); Sat, 4 Apr 2009 08:27:01 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751623AbZDDM1B (ORCPT ); Sat, 4 Apr 2009 08:27:01 -0400 Received: from zone0.gcu-squad.org ([212.85.147.21]:45101 "EHLO services.gcu-squad.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751176AbZDDM1A (ORCPT ); Sat, 4 Apr 2009 08:27:00 -0400 Received: from jdelvare.pck.nerim.net ([62.212.121.182] helo=hyperion.delvare) by services.gcu-squad.org (GCU Mailer Daemon) with esmtpsa id 1Lq62W-00066y-FA (TLSv1:AES256-SHA:256) (envelope-from ) ; Sat, 04 Apr 2009 15:36:04 +0200 Date: Sat, 4 Apr 2009 14:26:51 +0200 From: Jean Delvare To: LMML Cc: Andy Walls , Hans Verkuil , Mauro Carvalho Chehab , Mike Isely Subject: [PATCH 1/6] cx18: Fix the handling of i2c bus registration error Message-ID: <20090404142651.44757ccb@hyperion.delvare> In-Reply-To: <20090404142427.6e81f316@hyperion.delvare> References: <20090404142427.6e81f316@hyperion.delvare> X-Mailer: Claws Mail 3.5.0 (GTK+ 2.14.4; x86_64-suse-linux-gnu) Mime-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org * 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 Cc: Hans Verkuil Cc: Andy Walls Reviewed-by: Andy Walls Acked-by: Andy Walls Acked-by: Andy Walls --- linux/drivers/media/video/cx18/cx18-i2c.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) --- v4l-dvb.orig/linux/drivers/media/video/cx18/cx18-i2c.c 2009-03-01 16:09:09.000000000 +0100 +++ v4l-dvb/linux/drivers/media/video/cx18/cx18-i2c.c 2009-04-03 18:45:18.000000000 +0200 @@ -214,7 +214,7 @@ static struct i2c_algo_bit_data cx18_i2c /* 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++) { @@ -273,8 +273,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)