diff options
Diffstat (limited to 'drivers/i2c/algos/i2c-algo-bit.c')
-rw-r--r-- | drivers/i2c/algos/i2c-algo-bit.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index ab230c033f99..21c36bfb5e6b 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; |
@@ -354,15 +353,11 @@ static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | |||
354 | return (retval<0)? retval : -EFAULT; | 353 | return (retval<0)? retval : -EFAULT; |
355 | /* got a better one ?? */ | 354 | /* got a better one ?? */ |
356 | } | 355 | } |
357 | #if 0 | ||
358 | /* from asm/delay.h */ | ||
359 | __delay(adap->mdelay * (loops_per_sec / 1000) ); | ||
360 | #endif | ||
361 | } | 356 | } |
362 | return wrcount; | 357 | return wrcount; |
363 | } | 358 | } |
364 | 359 | ||
365 | 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) |
366 | { | 361 | { |
367 | int inval; | 362 | int inval; |
368 | int rdcount=0; /* counts bytes read */ | 363 | int rdcount=0; /* counts bytes read */ |
@@ -412,7 +407,7 @@ static inline int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) | |||
412 | * -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 |
413 | * -ETIMEDOUT, for example if the lines are stuck...) | 408 | * -ETIMEDOUT, for example if the lines are stuck...) |
414 | */ | 409 | */ |
415 | 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) |
416 | { | 411 | { |
417 | unsigned short flags = msg->flags; | 412 | unsigned short flags = msg->flags; |
418 | unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK; | 413 | unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK; |
@@ -517,7 +512,7 @@ static u32 bit_func(struct i2c_adapter *adap) | |||
517 | 512 | ||
518 | /* -----exported algorithm data: ------------------------------------- */ | 513 | /* -----exported algorithm data: ------------------------------------- */ |
519 | 514 | ||
520 | static struct i2c_algorithm i2c_bit_algo = { | 515 | static const struct i2c_algorithm i2c_bit_algo = { |
521 | .master_xfer = bit_xfer, | 516 | .master_xfer = bit_xfer, |
522 | .functionality = bit_func, | 517 | .functionality = bit_func, |
523 | }; | 518 | }; |