public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@s-opensource.com>
To: Peter Rosin <peda@axentia.se>
Cc: linux-kernel@vger.kernel.org,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org
Subject: Re: [PATCH 3/3] [media] cx231xx: only unregister successfully registered i2c adapters
Date: Wed, 9 Aug 2017 12:04:02 -0300	[thread overview]
Message-ID: <20170809120402.3358552c@vento.lan> (raw)
In-Reply-To: <24c02947-3812-1a1b-f6b7-dc5a3ff69d66@axentia.se>

Em Wed, 9 Aug 2017 16:43:03 +0200
Peter Rosin <peda@axentia.se> escreveu:

> On 2017-08-09 16:27, Mauro Carvalho Chehab wrote:
> > Em Mon, 31 Jul 2017 15:38:52 +0200
> > Peter Rosin <peda@axentia.se> escreveu:
> >   
> >> This prevents potentially scary debug messages from the i2c core.
> >>
> >> Signed-off-by: Peter Rosin <peda@axentia.se>
> >> ---
> >>  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);  
> 
> In theory, yes. But in practice i2c_add_adapter never returns >0, and is
> also documented so.

Good point. Just applied the patch.
> 
> Let me know if you still want an update. In that case I'll also fix the
> precedent present in the context of patch 1/3, i.e.
> 
> 	if (0 != bus->i2c_rc)
> 		...
> 
> Cheers,
> peda



Thanks,
Mauro

      reply	other threads:[~2017-08-09 15:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-31 13:38 [PATCH 0/3] [media] cx231xx: cleanup i2c adapter handling Peter Rosin
2017-07-31 13:38 ` [PATCH 1/3] [media] cx231xx: fail probe if i2c_add_adapter fails Peter Rosin
2017-07-31 13:38 ` [PATCH 2/3] [media] cx231xx: drop return value of cx231xx_i2c_unregister Peter Rosin
2017-07-31 13:38 ` [PATCH 3/3] [media] cx231xx: only unregister successfully registered i2c adapters Peter Rosin
2017-08-09 14:27   ` Mauro Carvalho Chehab
2017-08-09 14:43     ` Peter Rosin
2017-08-09 15:04       ` Mauro Carvalho Chehab [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170809120402.3358552c@vento.lan \
    --to=mchehab@s-opensource.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=peda@axentia.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox