linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
Cc: Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	Ben Dooks <ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/6] i2c: i2c_del_adapter: Don't treat removing a non-registered adapter as error
Date: Sat, 30 Mar 2013 19:17:20 +0100	[thread overview]
Message-ID: <20130330191720.0134ee7e@endymion.delvare> (raw)
In-Reply-To: <1362853009-20789-3-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>

On Sat,  9 Mar 2013 19:16:45 +0100, Lars-Peter Clausen wrote:
> Currently i2c_del_adapter() returns -EINVAL when it gets an adapter which is not
> registered. But none of the users of i2c_del_adapter() depend on this behavior,

At least two used to depend on it actually, and this is even why this
code was added in the first place. See:
  http://lists.lm-sensors.org/pipermail/lm-sensors/2004-November/009350.html
The check was added for the i2c-amd756-s4882 and i2c-nforce2-s4985
old-style SMBus multiplexing drivers.

Meanwhile a safer check was added:

commit 399d6b26539d83dd734746dc2292d53fbc5807b2
Author: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Date:   Sun Aug 10 22:56:15 2008 +0200

    i2c: Fix oops on bus multiplexer driver loading
    
    The two I2C bus multiplexer drivers (i2c-amd756-s4882 and
    i2c-nforce2-s4985) make use of the bus they want to multiplex before
    checking if it is really present. Swap the instructions to test for
    presence first. This fixes a oops reported by Ingo Molnar.
    
So these drivers indeed no longer depend on i2c_del_adapter() to detect
whether their parent I2C adapter has been added or not.

These two drivers should be removed and replaced with code using the
standard I2C multiplexing infrastructure anyway, but it's not clear
when anyone will find the time to actually do that.

> so for the sake of being able to sanitize the return type of i2c_del_adapter
> argue, that the purpose of i2c_del_adapter() is to remove an I2C adapter from
> the system. If the adapter is not registered in the first place this becomes a
> no-op. So we can return success without having to do anything.
> 
> Signed-off-by: Lars-Peter Clausen <lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
> ---
>  drivers/i2c/i2c-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index a853cb3..7727d33 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -1072,7 +1072,7 @@ int i2c_del_adapter(struct i2c_adapter *adap)
>  	if (found != adap) {
>  		pr_debug("i2c-core: attempting to delete unregistered "
>  			 "adapter [%s]\n", adap->name);
> -		return -EINVAL;
> +		return 0;
>  	}
>  
>  	/* Tell drivers about this removal */

Reviewed-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>

A more radical approach would be to say that you are simply not
supposed to try and remove an adapter that was never added, so the
whole check is pointless and should be removed. After all,
i2c_unregister_device() and i2c_del_driver() do not have such a check.
I don't know how cautious other subsystems are but I suspect most don't
have such a check either.

-- 
Jean Delvare

  parent reply	other threads:[~2013-03-30 18:17 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-09 18:16 [PATCH 0/6] Make return type of i2c_del_adapter() (and i2c_del_mux_adapter()) void Lars-Peter Clausen
2013-03-09 18:16 ` [PATCH 1/6] i2c: Remove detach_adapter Lars-Peter Clausen
     [not found]   ` <1362853009-20789-2-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-03-30 14:52     ` Jean Delvare
2013-03-09 18:16 ` [PATCH 2/6] i2c: i2c_del_adapter: Don't treat removing a non-registered adapter as error Lars-Peter Clausen
     [not found]   ` <1362853009-20789-3-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-03-30 18:17     ` Jean Delvare [this message]
2013-03-09 18:16 ` [PATCH 3/6] i2c: Ignore return value of i2c_del_adapter() Lars-Peter Clausen
     [not found]   ` <1362853009-20789-4-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-03-11 17:52     ` Ben Hutchings
2013-03-30  6:34     ` Wolfram Sang
2013-03-30  7:55     ` Jean Delvare
     [not found]       ` <20130330085539.442321fa-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2013-03-30  8:11         ` Lars-Peter Clausen
     [not found]           ` <51569E4A.2080006-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-03-30  8:43             ` Jean Delvare
2013-03-31 13:12     ` Shawn Guo
2013-03-31  8:25   ` Jean Delvare
2013-03-09 18:16 ` [PATCH 4/6] i2c: Make return type of i2c_del_adapter() void Lars-Peter Clausen
     [not found]   ` <1362853009-20789-5-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-03-31  9:04     ` Jean Delvare
2013-03-09 18:16 ` [PATCH 5/6] i2c: Ignore the return value of i2c_del_mux_adapter() Lars-Peter Clausen
     [not found]   ` <1362853009-20789-6-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-03-13  6:05     ` [5/6] " Guenter Roeck
2013-03-31  9:23     ` [PATCH 5/6] " Jean Delvare
2013-03-09 18:16 ` [PATCH 6/6] i2c: Make the return type of i2c_del_mux_adapter() void Lars-Peter Clausen
     [not found]   ` <1362853009-20789-7-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-03-31  9:24     ` Jean Delvare
2013-03-30  6:33 ` [PATCH 0/6] Make return type of i2c_del_adapter() (and i2c_del_mux_adapter()) void Wolfram Sang
     [not found] ` <1362853009-20789-1-git-send-email-lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-03-30 20:13   ` Jean Delvare
2013-03-30 20:43     ` Lars-Peter Clausen
     [not found]       ` <51574E71.7010403-Qo5EllUWu/uELgA04lAiVw@public.gmane.org>
2013-03-31  7:56         ` Jean Delvare
2013-03-31 11:30   ` Jean Delvare
2013-04-02  5:09   ` Wolfram Sang

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=20130330191720.0134ee7e@endymion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=lars-Qo5EllUWu/uELgA04lAiVw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org \
    /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;
as well as URLs for NNTP newsgroup(s).