Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 69,70c69
- < #define I2C_TIMEOUT_MS 1000
- < #define I2C_WAIT_LOOP_COUNT 40
- ---
- > #define I2C_TIMEOUT_MS 150
- 78c77
- < static bool combined = true;
- ---
- > static bool combined = false;
- 89d87
- < u32 cdiv;
- 113c111
- < BUG_ON(id != 0 && id != 1);
- ---
- > BUG_ON(id != 0 && id != 1);
- 116c114
- < printk("bcm2708_i2c_init_pinmode(%d,%d)\n", id, pin);
- ---
- > printk("bcm2708_i2c_init_pinmode(%d,%d)\n", id, pin);
- 155c153
- < static inline int bcm2708_bsc_setup(struct bcm2708_i2c *bi)
- ---
- > static inline void bcm2708_bsc_setup(struct bcm2708_i2c *bi)
- 157c155
- < // unsigned long bus_hz;
- ---
- > unsigned long bus_hz;
- 160d157
- < int wait_loops = I2C_WAIT_LOOP_COUNT;
- 162,166c159,162
- < // bus_hz = clk_get_rate(bi->clk);
- < // cdiv = bus_hz / baudrate;
- < // if (cdiv > 0xffff)
- < // cdiv = 0xffff;
- < cdiv = bi->cdiv;
- ---
- > bus_hz = clk_get_rate(bi->clk);
- > cdiv = bus_hz / baudrate;
- > if (cdiv > 0xffff)
- > cdiv = 0xffff;
- 183,184c179,180
- < !(bi->msg[0].flags & I2C_M_RD) && (bi->msg[1].flags & I2C_M_RD) &&
- < (bi->msg[0].addr == bi->msg[1].addr) && (bi->msg[0].len <= 16)) {
- ---
- > !(bi->msg[0].flags & I2C_M_RD) && (bi->msg[1].flags & I2C_M_RD) &&
- > (bi->msg[0].addr == bi->msg[1].addr) && (bi->msg[0].len <= 16)) {
- 186c182
- < while (bi->pos < bi->msg->len) {
- ---
- > while (bi->pos < bi->msg->len)
- 188d183
- < }
- 191d185
- <
- 195,201c189
- < } while (!(s & (BSC_S_TA | BSC_S_ERR | BSC_S_CLKT | BSC_S_DONE)) && --wait_loops >= 0);
- <
- < /* did we time out or some error occured? */
- < if (wait_loops < 0 || (s & (BSC_S_ERR | BSC_S_CLKT))) {
- < return -1;
- < }
- <
- ---
- > } while (!(s & (BSC_S_TA | BSC_S_ERR | BSC_S_CLKT | BSC_S_DONE)));
- 211,212d198
- <
- < return 0;
- 220d205
- < int ret;
- 225,226c210,211
- < Just return if we've not sent anything */
- < if (!bi->nmsgs || !bi->msg ) {
- ---
- > Just return if we've not sent anything */
- > if (!bi->nmsgs || !bi->msg )
- 228d212
- < }
- 236,237d219
- < bi->msg = 0; /* to inform the that all work is done */
- < bi->nmsgs = 0;
- 239c221
- < complete_all(&bi->done);
- ---
- > complete(&bi->done);
- 243c225
- < if (bi->msg->flags & I2C_M_RD) {
- ---
- > if (bi->msg->flags & I2C_M_RD)
- 245d226
- < }
- 253,262c234
- < ret = bcm2708_bsc_setup(bi);
- < if (ret < 0) {
- < bcm2708_bsc_reset(bi);
- < bi->error = true;
- < bi->msg = 0; /* to inform the that all work is done */
- < bi->nmsgs = 0;
- < /* wake up our bh */
- < complete_all(&bi->done);
- < goto early_exit;
- < }
- ---
- > bcm2708_bsc_setup(bi);
- 264,265d235
- < bi->msg = 0; /* to inform the that all work is done */
- < bi->nmsgs = 0;
- 267c237
- < complete_all(&bi->done);
- ---
- > complete(&bi->done);
- 298c268
- < ret = bcm2708_bsc_setup(bi);
- ---
- > bcm2708_bsc_setup(bi);
- 299a270
- > /* unlockig _after_ the setup to avoid races with the interrupt routine */
- 302,309c273,274
- < /* check trhe result of the setup */
- < if (ret < 0)
- < {
- < dev_err(&adap->dev, "transfer setup timed out\n");
- < goto error_timeout;
- < }
- <
- < ret = wait_for_completion_timeout(&bi->done, msecs_to_jiffies(I2C_TIMEOUT_MS));
- ---
- > ret = wait_for_completion_timeout(&bi->done,
- > msecs_to_jiffies(I2C_TIMEOUT_MS));
- 312c277,280
- < goto error_timeout;
- ---
- > spin_lock_irqsave(&bi->lock, flags);
- > bcm2708_bsc_reset(bi);
- > spin_unlock_irqrestore(&bi->lock, flags);
- > return -ETIMEDOUT;
- 315,324c283
- < ret = bi->error ? -EIO : num;
- < return ret;
- <
- < error_timeout:
- < spin_lock_irqsave(&bi->lock, flags);
- < bcm2708_bsc_reset(bi);
- < bi->msg = 0; /* to inform the interrupt handler that there's nothing else to be done */
- < bi->nmsgs = 0;
- < spin_unlock_irqrestore(&bi->lock, flags);
- < return -ETIMEDOUT;
- ---
- > return bi->error ? -EIO : num;
- 427d385
- < bi->cdiv = cdiv;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement