aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2011-01-10 16:11:23 -0500
committerJean Delvare <khali@endymion.delvare>2011-01-10 16:11:23 -0500
commitf451171c5ac829e55581c81caf2cb01e1c0a5c5f (patch)
tree519af0702a8348b043a721d996933b655236712e
parent92ed1a76ca31774eb27de14b2215841367c68056 (diff)
i2c-algo-bit: Refactor adapter registration
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. Signed-off-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r--drivers/i2c/algos/i2c-algo-bit.c21
1 files changed, 5 insertions, 16 deletions
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c
index a39e6cff86e..938170b8998 100644
--- a/drivers/i2c/algos/i2c-algo-bit.c
+++ b/drivers/i2c/algos/i2c-algo-bit.c
@@ -600,7 +600,8 @@ static const struct i2c_algorithm i2c_bit_algo = {
600/* 600/*
601 * registering functions to load algorithms at runtime 601 * registering functions to load algorithms at runtime
602 */ 602 */
603static int i2c_bit_prepare_bus(struct i2c_adapter *adap) 603static int __i2c_bit_add_bus(struct i2c_adapter *adap,
604 int (*add_adapter)(struct i2c_adapter *))
604{ 605{
605 struct i2c_algo_bit_data *bit_adap = adap->algo_data; 606 struct i2c_algo_bit_data *bit_adap = adap->algo_data;
606 607
@@ -614,30 +615,18 @@ static int i2c_bit_prepare_bus(struct i2c_adapter *adap)
614 adap->algo = &i2c_bit_algo; 615 adap->algo = &i2c_bit_algo;
615 adap->retries = 3; 616 adap->retries = 3;
616 617
617 return 0; 618 return add_adapter(adap);
618} 619}
619 620
620int i2c_bit_add_bus(struct i2c_adapter *adap) 621int i2c_bit_add_bus(struct i2c_adapter *adap)
621{ 622{
622 int err; 623 return __i2c_bit_add_bus(adap, i2c_add_adapter);
623
624 err = i2c_bit_prepare_bus(adap);
625 if (err)
626 return err;
627
628 return i2c_add_adapter(adap);
629} 624}
630EXPORT_SYMBOL(i2c_bit_add_bus); 625EXPORT_SYMBOL(i2c_bit_add_bus);
631 626
632int i2c_bit_add_numbered_bus(struct i2c_adapter *adap) 627int i2c_bit_add_numbered_bus(struct i2c_adapter *adap)
633{ 628{
634 int err; 629 return __i2c_bit_add_bus(adap, i2c_add_numbered_adapter);
635
636 err = i2c_bit_prepare_bus(adap);
637 if (err)
638 return err;
639
640 return i2c_add_numbered_adapter(adap);
641} 630}
642EXPORT_SYMBOL(i2c_bit_add_numbered_bus); 631EXPORT_SYMBOL(i2c_bit_add_numbered_bus);
643 632