Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753191AbdHIO1v (ORCPT ); Wed, 9 Aug 2017 10:27:51 -0400 Received: from ec2-52-27-115-49.us-west-2.compute.amazonaws.com ([52.27.115.49]:51364 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752675AbdHIO1u (ORCPT ); Wed, 9 Aug 2017 10:27:50 -0400 Date: Wed, 9 Aug 2017 11:27:41 -0300 From: Mauro Carvalho Chehab To: Peter Rosin Cc: linux-kernel@vger.kernel.org, Mauro Carvalho Chehab , linux-media@vger.kernel.org Subject: Re: [PATCH 3/3] [media] cx231xx: only unregister successfully registered i2c adapters Message-ID: <20170809112741.36427eb0@vento.lan> In-Reply-To: <20170731133852.8013-4-peda@axentia.se> References: <20170731133852.8013-1-peda@axentia.se> <20170731133852.8013-4-peda@axentia.se> Organization: Samsung X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2189 Lines: 62 Em Mon, 31 Jul 2017 15:38:52 +0200 Peter Rosin escreveu: > This prevents potentially scary debug messages from the i2c core. > > Signed-off-by: Peter Rosin > --- > drivers/media/usb/cx231xx/cx231xx-core.c | 3 +++ > drivers/media/usb/cx231xx/cx231xx-i2c.c | 3 ++- > 2 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c > index 46646ecd2dbc..f372ad3917a8 100644 > --- a/drivers/media/usb/cx231xx/cx231xx-core.c > +++ b/drivers/media/usb/cx231xx/cx231xx-core.c > @@ -1311,6 +1311,7 @@ int cx231xx_dev_init(struct cx231xx *dev) > dev->i2c_bus[0].i2c_period = I2C_SPEED_100K; /* 100 KHz */ > dev->i2c_bus[0].i2c_nostop = 0; > dev->i2c_bus[0].i2c_reserve = 0; > + dev->i2c_bus[0].i2c_rc = -ENODEV; > > /* External Master 2 Bus */ > dev->i2c_bus[1].nr = 1; > @@ -1318,6 +1319,7 @@ int cx231xx_dev_init(struct cx231xx *dev) > dev->i2c_bus[1].i2c_period = I2C_SPEED_100K; /* 100 KHz */ > dev->i2c_bus[1].i2c_nostop = 0; > dev->i2c_bus[1].i2c_reserve = 0; > + dev->i2c_bus[1].i2c_rc = -ENODEV; > > /* Internal Master 3 Bus */ > dev->i2c_bus[2].nr = 2; > @@ -1325,6 +1327,7 @@ int cx231xx_dev_init(struct cx231xx *dev) > dev->i2c_bus[2].i2c_period = I2C_SPEED_100K; /* 100kHz */ > dev->i2c_bus[2].i2c_nostop = 0; > dev->i2c_bus[2].i2c_reserve = 0; > + dev->i2c_bus[2].i2c_rc = -ENODEV; > > /* register I2C buses */ > errCode = cx231xx_i2c_register(&dev->i2c_bus[0]); > diff --git a/drivers/media/usb/cx231xx/cx231xx-i2c.c b/drivers/media/usb/cx231xx/cx231xx-i2c.c > index 3e49517cb5e0..8ce6b815d16d 100644 > --- a/drivers/media/usb/cx231xx/cx231xx-i2c.c > +++ b/drivers/media/usb/cx231xx/cx231xx-i2c.c > @@ -553,7 +553,8 @@ int cx231xx_i2c_register(struct cx231xx_i2c *bus) > */ > void cx231xx_i2c_unregister(struct cx231xx_i2c *bus) > { > - i2c_del_adapter(&bus->i2c_adap); > + if (!bus->i2c_rc) > + i2c_del_adapter(&bus->i2c_adap); That doesn't sound right. what happens if i2c_rc is 1 or 2? IMHO, the right would would be, instead: if (bus->i2c_rc >= 0) i2c_del_adapter(&bus->i2c_adap); Regards Thanks, Mauro