diff options
author | Jean Delvare <khali@linux-fr.org> | 2006-09-03 16:22:12 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-26 18:38:51 -0400 |
commit | 7b288a018ac563f5babe0818f581d8f8a4fdcbfb (patch) | |
tree | ae177369ee19d059228067aad967a58a87580f03 /drivers/i2c/algos | |
parent | 8202632647278eba7223727dc442f49227c040d0 (diff) |
i2c-algo-bit: Cleanups
i2c-algo-bit: Cleanups
* Uninline long functions (saves around 1 kB or 15%)
* Refactor code in sclhi()
* Drop redundant udelay on repeated start
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/i2c/algos')
-rw-r--r-- | drivers/i2c/algos/i2c-algo-bit.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 761df16838b4..48fe3a3b0b51 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c | |||
@@ -76,17 +76,15 @@ static inline void scllo(struct i2c_algo_bit_data *adap) | |||
76 | * Raise scl line, and do checking for delays. This is necessary for slower | 76 | * Raise scl line, and do checking for delays. This is necessary for slower |
77 | * devices. | 77 | * devices. |
78 | */ | 78 | */ |
79 | static inline int sclhi(struct i2c_algo_bit_data *adap) | 79 | static int sclhi(struct i2c_algo_bit_data *adap) |
80 | { | 80 | { |
81 | unsigned long start; | 81 | unsigned long start; |
82 | 82 | ||
83 | setscl(adap,1); | 83 | setscl(adap,1); |
84 | 84 | ||
85 | /* Not all adapters have scl sense line... */ | 85 | /* Not all adapters have scl sense line... */ |
86 | if (adap->getscl == NULL ) { | 86 | if (!adap->getscl) |
87 | udelay(adap->udelay); | 87 | goto done; |
88 | return 0; | ||
89 | } | ||
90 | 88 | ||
91 | start=jiffies; | 89 | start=jiffies; |
92 | while (! getscl(adap) ) { | 90 | while (! getscl(adap) ) { |
@@ -101,6 +99,8 @@ static inline int sclhi(struct i2c_algo_bit_data *adap) | |||
101 | cond_resched(); | 99 | cond_resched(); |
102 | } | 100 | } |
103 | DEBSTAT(printk(KERN_DEBUG "needed %ld jiffies\n", jiffies-start)); | 101 | DEBSTAT(printk(KERN_DEBUG "needed %ld jiffies\n", jiffies-start)); |
102 | |||
103 | done: | ||
104 | udelay(adap->udelay); | 104 | udelay(adap->udelay); |
105 | return 0; | 105 | return 0; |
106 | } | 106 | } |
@@ -121,7 +121,6 @@ static void i2c_repstart(struct i2c_algo_bit_data *adap) | |||
121 | DEBPROTO(printk(" Sr ")); | 121 | DEBPROTO(printk(" Sr ")); |
122 | setsda(adap,1); | 122 | setsda(adap,1); |
123 | sclhi(adap); | 123 | sclhi(adap); |
124 | udelay(adap->udelay); | ||
125 | 124 | ||
126 | sdalo(adap); | 125 | sdalo(adap); |
127 | scllo(adap); | 126 | scllo(adap); |
@@ -306,7 +305,7 @@ bailout: | |||
306 | * 0 chip did not answer | 305 | * 0 chip did not answer |
307 | * -x transmission error | 306 | * -x transmission error |
308 | */ | 307 | */ |
309 | static inline int try_address(struct i2c_adapter *i2c_adap, | 308 | static int try_address(struct i2c_adapter *i2c_adap, |
310 | unsigned char addr, int retries) | 309 | unsigned char addr, int retries) |
311 | { | 310 | { |
312 | struct i2c_algo_bit_data *adap = i2c_adap->algo_data; | 311 | struct i2c_algo_bit_data *adap = i2c_adap->algo_data; |
@@ -358,7 +357,7 @@ static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | |||
358 | return wrcount; | 357 | return wrcount; |
359 | } | 358 | } |
360 | 359 | ||
361 | static inline int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | 360 | static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) |
362 | { | 361 | { |
363 | int inval; | 362 | int inval; |
364 | int rdcount=0; /* counts bytes read */ | 363 | int rdcount=0; /* counts bytes read */ |
@@ -408,7 +407,7 @@ static inline int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | |||
408 | * -x an error occurred (like: -EREMOTEIO if the device did not answer, or | 407 | * -x an error occurred (like: -EREMOTEIO if the device did not answer, or |
409 | * -ETIMEDOUT, for example if the lines are stuck...) | 408 | * -ETIMEDOUT, for example if the lines are stuck...) |
410 | */ | 409 | */ |
411 | static inline int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | 410 | static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) |
412 | { | 411 | { |
413 | unsigned short flags = msg->flags; | 412 | unsigned short flags = msg->flags; |
414 | unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK; | 413 | unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK; |