From: Ben Dooks <ben-i2c-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH 1/2] i2c-algo-bit: Refactor adapter registration
Date: Tue, 7 Dec 2010 11:51:31 +0000 [thread overview]
Message-ID: <20101207115131.GM20097@trinity.fluff.org> (raw)
In-Reply-To: <20101207110631.6222cfed-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
On Tue, Dec 07, 2010 at 11:06:31AM +0100, Jean Delvare wrote:
> Use a function pointer to decide whether to call i2c_add_adapter or
> i2c_add_numbered_adapter. This makes the code more compact than the
> current strategy of having the common code in a separate function.
ok, how about changing i2c_add_numbered_adapter to take a -1 to mean
assign bus number automatically? or something similar?
> Signed-off-by: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
> ---
> drivers/i2c/algos/i2c-algo-bit.c | 21 +++++----------------
> 1 file changed, 5 insertions(+), 16 deletions(-)
>
> --- linux-2.6.37-rc5.orig/drivers/i2c/algos/i2c-algo-bit.c 2010-12-07 10:13:49.000000000 +0100
> +++ linux-2.6.37-rc5/drivers/i2c/algos/i2c-algo-bit.c 2010-12-07 11:02:38.000000000 +0100
> @@ -600,7 +600,8 @@ static const struct i2c_algorithm i2c_bi
> /*
> * registering functions to load algorithms at runtime
> */
> -static int i2c_bit_prepare_bus(struct i2c_adapter *adap)
> +static int __i2c_bit_add_bus(struct i2c_adapter *adap,
> + int (*add_adapter)(struct i2c_adapter *))
> {
> struct i2c_algo_bit_data *bit_adap = adap->algo_data;
>
> @@ -614,30 +615,18 @@ static int i2c_bit_prepare_bus(struct i2
> adap->algo = &i2c_bit_algo;
> adap->retries = 3;
>
> - return 0;
> + return add_adapter(adap);
> }
>
> int i2c_bit_add_bus(struct i2c_adapter *adap)
> {
> - int err;
> -
> - err = i2c_bit_prepare_bus(adap);
> - if (err)
> - return err;
> -
> - return i2c_add_adapter(adap);
> + return __i2c_bit_add_bus(adap, i2c_add_adapter);
> }
> EXPORT_SYMBOL(i2c_bit_add_bus);
>
> int i2c_bit_add_numbered_bus(struct i2c_adapter *adap)
> {
> - int err;
> -
> - err = i2c_bit_prepare_bus(adap);
> - if (err)
> - return err;
> -
> - return i2c_add_numbered_adapter(adap);
> + return __i2c_bit_add_bus(adap, i2c_add_numbered_adapter);
> }
> EXPORT_SYMBOL(i2c_bit_add_numbered_bus);
>
>
>
> --
> Jean Delvare
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
--
Ben
Q: What's a light-year?
A: One-third less calories than a regular year.
next prev parent reply other threads:[~2010-12-07 11:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-07 10:06 [PATCH 1/2] i2c-algo-bit: Refactor adapter registration Jean Delvare
[not found] ` <20101207110631.6222cfed-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2010-12-07 11:51 ` Ben Dooks [this message]
[not found] ` <20101207115131.GM20097-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2010-12-07 11:59 ` Michael Lawnick
[not found] ` <4CFE21A7.9020901-Mmb7MZpHnFY@public.gmane.org>
2010-12-07 17:29 ` Jean Delvare
[not found] ` <20101207182943.1e31507b-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2010-12-08 9:59 ` Michael Lawnick
[not found] ` <4CFF56F6.1000606-Mmb7MZpHnFY@public.gmane.org>
2010-12-08 13:32 ` Jean Delvare
[not found] ` <20101208143236.5f9082af-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2010-12-13 23:47 ` Ben Dooks
[not found] ` <20101213234723.GZ20097-SMNkleLxa3Z6Wcw2j4pizdi2O/JbrIOy@public.gmane.org>
2010-12-14 7:46 ` Jean Delvare
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=20101207115131.GM20097@trinity.fluff.org \
--to=ben-i2c-elnmno+kys3ytjvyw6ydsg@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@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).