Merge branch 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6

* 'i2c-for-linus' of git://jdelvare.pck.nerim.net/jdelvare-2.6:
i2c-algo-bit: Read block data bugfix
i2c-pxa: Fix adapter number
i2c-gpio: Fix adapter number

+34 -22
+32 -20
drivers/i2c/algos/i2c-algo-bit.c
··· 357 return wrcount; 358 } 359 360 static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) 361 { 362 int inval; 363 int rdcount=0; /* counts bytes read */ 364 - struct i2c_algo_bit_data *adap = i2c_adap->algo_data; 365 unsigned char *temp = msg->buf; 366 int count = msg->len; 367 368 while (count > 0) { 369 inval = i2c_inb(i2c_adap); ··· 393 temp++; 394 count--; 395 396 - if (msg->flags & I2C_M_NO_RD_ACK) { 397 - bit_dbg(2, &i2c_adap->dev, "i2c_inb: 0x%02x\n", 398 - inval); 399 - continue; 400 - } 401 - 402 - /* assert: sda is high */ 403 - if (count) /* send ack */ 404 - setsda(adap, 0); 405 - udelay((adap->udelay + 1) / 2); 406 - bit_dbg(2, &i2c_adap->dev, "i2c_inb: 0x%02x %s\n", inval, 407 - count ? "A" : "NA"); 408 - if (sclhi(adap)<0) { /* timeout */ 409 - dev_err(&i2c_adap->dev, "readbytes: timeout at ack\n"); 410 - return -ETIMEDOUT; 411 - }; 412 - scllo(adap); 413 - 414 /* Some SMBus transactions require that we receive the 415 transaction length as the first read byte. */ 416 - if (rdcount == 1 && (msg->flags & I2C_M_RECV_LEN)) { 417 if (inval <= 0 || inval > I2C_SMBUS_BLOCK_MAX) { 418 dev_err(&i2c_adap->dev, "readbytes: invalid " 419 "block length (%d)\n", inval); 420 return -EREMOTEIO; ··· 408 or 2 for a PEC transaction. */ 409 count += inval; 410 msg->len += inval; 411 } 412 } 413 return rdcount;
··· 357 return wrcount; 358 } 359 360 + static int acknak(struct i2c_adapter *i2c_adap, int is_ack) 361 + { 362 + struct i2c_algo_bit_data *adap = i2c_adap->algo_data; 363 + 364 + /* assert: sda is high */ 365 + if (is_ack) /* send ack */ 366 + setsda(adap, 0); 367 + udelay((adap->udelay + 1) / 2); 368 + if (sclhi(adap) < 0) { /* timeout */ 369 + dev_err(&i2c_adap->dev, "readbytes: ack/nak timeout\n"); 370 + return -ETIMEDOUT; 371 + } 372 + scllo(adap); 373 + return 0; 374 + } 375 + 376 static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) 377 { 378 int inval; 379 int rdcount=0; /* counts bytes read */ 380 unsigned char *temp = msg->buf; 381 int count = msg->len; 382 + const unsigned flags = msg->flags; 383 384 while (count > 0) { 385 inval = i2c_inb(i2c_adap); ··· 377 temp++; 378 count--; 379 380 /* Some SMBus transactions require that we receive the 381 transaction length as the first read byte. */ 382 + if (rdcount == 1 && (flags & I2C_M_RECV_LEN)) { 383 if (inval <= 0 || inval > I2C_SMBUS_BLOCK_MAX) { 384 + if (!(flags & I2C_M_NO_RD_ACK)) 385 + acknak(i2c_adap, 0); 386 dev_err(&i2c_adap->dev, "readbytes: invalid " 387 "block length (%d)\n", inval); 388 return -EREMOTEIO; ··· 408 or 2 for a PEC transaction. */ 409 count += inval; 410 msg->len += inval; 411 + } 412 + 413 + bit_dbg(2, &i2c_adap->dev, "readbytes: 0x%02x %s\n", 414 + inval, 415 + (flags & I2C_M_NO_RD_ACK) 416 + ? "(no ack/nak)" 417 + : (count ? "A" : "NA")); 418 + 419 + if (!(flags & I2C_M_NO_RD_ACK)) { 420 + inval = acknak(i2c_adap, count); 421 + if (inval < 0) 422 + return inval; 423 } 424 } 425 return rdcount;
+1 -1
drivers/i2c/busses/i2c-gpio.c
··· 147 * The reason to do so is to avoid sysfs names that only make 148 * sense when there are multiple adapters. 149 */ 150 - adap->nr = pdev->id >= 0 ? pdev->id : 0; 151 ret = i2c_bit_add_numbered_bus(adap); 152 if (ret) 153 goto err_add_bus;
··· 147 * The reason to do so is to avoid sysfs names that only make 148 * sense when there are multiple adapters. 149 */ 150 + adap->nr = (pdev->id != -1) ? pdev->id : 0; 151 ret = i2c_bit_add_numbered_bus(adap); 152 if (ret) 153 goto err_add_bus;
+1 -1
drivers/i2c/busses/i2c-pxa.c
··· 926 * The reason to do so is to avoid sysfs names that only make 927 * sense when there are multiple adapters. 928 */ 929 - i2c->adap.nr = dev->id >= 0 ? dev->id : 0; 930 931 ret = i2c_add_numbered_adapter(&i2c->adap); 932 if (ret < 0) {
··· 926 * The reason to do so is to avoid sysfs names that only make 927 * sense when there are multiple adapters. 928 */ 929 + i2c->adap.nr = dev->id != -1 ? dev->id : 0; 930 931 ret = i2c_add_numbered_adapter(&i2c->adap); 932 if (ret < 0) {