Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:
"I2C has some pretty standard driver bugfixes and one minor cleanup"

* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: meson: Use complete() instead of complete_all()
i2c: brcmstb: Use complete() instead of complete_all()
i2c: bcm-kona: Use complete() instead of complete_all()
i2c: bcm-iproc: Use complete() instead of complete_all()
i2c: at91: fix support of the "alternative command" feature
i2c: ocores: add missed clk_disable_unprepare() on failure paths
i2c: cros-ec-tunnel: Fix usage of cros_ec_cmd_xfer()
i2c: mux: demux-pinctrl: properly roll back when adding adapter fails

+34 -22
+14 -10
drivers/i2c/busses/i2c-at91.c
··· 38 38 #define AT91_I2C_TIMEOUT msecs_to_jiffies(100) /* transfer timeout */ 39 39 #define AT91_I2C_DMA_THRESHOLD 8 /* enable DMA if transfer size is bigger than this threshold */ 40 40 #define AUTOSUSPEND_TIMEOUT 2000 41 + #define AT91_I2C_MAX_ALT_CMD_DATA_SIZE 256 41 42 42 43 /* AT91 TWI register definitions */ 43 44 #define AT91_TWI_CR 0x0000 /* Control Register */ ··· 142 141 unsigned twi_cwgr_reg; 143 142 struct at91_twi_pdata *pdata; 144 143 bool use_dma; 144 + bool use_alt_cmd; 145 145 bool recv_len_abort; 146 146 u32 fifo_size; 147 147 struct at91_twi_dma dma; ··· 271 269 272 270 /* send stop when last byte has been written */ 273 271 if (--dev->buf_len == 0) 274 - if (!dev->pdata->has_alt_cmd) 272 + if (!dev->use_alt_cmd) 275 273 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP); 276 274 277 275 dev_dbg(dev->dev, "wrote 0x%x, to go %d\n", *dev->buf, dev->buf_len); ··· 294 292 * we just have to enable TXCOMP one. 295 293 */ 296 294 at91_twi_write(dev, AT91_TWI_IER, AT91_TWI_TXCOMP); 297 - if (!dev->pdata->has_alt_cmd) 295 + if (!dev->use_alt_cmd) 298 296 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP); 299 297 } 300 298 ··· 412 410 } 413 411 414 412 /* send stop if second but last byte has been read */ 415 - if (!dev->pdata->has_alt_cmd && dev->buf_len == 1) 413 + if (!dev->use_alt_cmd && dev->buf_len == 1) 416 414 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_STOP); 417 415 418 416 dev_dbg(dev->dev, "read 0x%x, to go %d\n", *dev->buf, dev->buf_len); ··· 428 426 dma_unmap_single(dev->dev, sg_dma_address(&dev->dma.sg[0]), 429 427 dev->buf_len, DMA_FROM_DEVICE); 430 428 431 - if (!dev->pdata->has_alt_cmd) { 429 + if (!dev->use_alt_cmd) { 432 430 /* The last two bytes have to be read without using dma */ 433 431 dev->buf += dev->buf_len - 2; 434 432 dev->buf_len = 2; ··· 445 443 struct dma_chan *chan_rx = dma->chan_rx; 446 444 size_t buf_len; 447 445 448 - buf_len = (dev->pdata->has_alt_cmd) ? dev->buf_len : dev->buf_len - 2; 446 + buf_len = (dev->use_alt_cmd) ? dev->buf_len : dev->buf_len - 2; 449 447 dma->direction = DMA_FROM_DEVICE; 450 448 451 449 /* Keep in mind that we won't use dma to read the last two bytes */ ··· 653 651 unsigned start_flags = AT91_TWI_START; 654 652 655 653 /* if only one byte is to be read, immediately stop transfer */ 656 - if (!has_alt_cmd && dev->buf_len <= 1 && 654 + if (!dev->use_alt_cmd && dev->buf_len <= 1 && 657 655 !(dev->msg->flags & I2C_M_RECV_LEN)) 658 656 start_flags |= AT91_TWI_STOP; 659 657 at91_twi_write(dev, AT91_TWI_CR, start_flags); ··· 747 745 int ret; 748 746 unsigned int_addr_flag = 0; 749 747 struct i2c_msg *m_start = msg; 750 - bool is_read, use_alt_cmd = false; 748 + bool is_read; 751 749 752 750 dev_dbg(&adap->dev, "at91_xfer: processing %d messages:\n", num); 753 751 ··· 770 768 at91_twi_write(dev, AT91_TWI_IADR, internal_address); 771 769 } 772 770 771 + dev->use_alt_cmd = false; 773 772 is_read = (m_start->flags & I2C_M_RD); 774 773 if (dev->pdata->has_alt_cmd) { 775 - if (m_start->len > 0) { 774 + if (m_start->len > 0 && 775 + m_start->len < AT91_I2C_MAX_ALT_CMD_DATA_SIZE) { 776 776 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_ACMEN); 777 777 at91_twi_write(dev, AT91_TWI_ACR, 778 778 AT91_TWI_ACR_DATAL(m_start->len) | 779 779 ((is_read) ? AT91_TWI_ACR_DIR : 0)); 780 - use_alt_cmd = true; 780 + dev->use_alt_cmd = true; 781 781 } else { 782 782 at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_ACMDIS); 783 783 } ··· 788 784 at91_twi_write(dev, AT91_TWI_MMR, 789 785 (m_start->addr << 16) | 790 786 int_addr_flag | 791 - ((!use_alt_cmd && is_read) ? AT91_TWI_MREAD : 0)); 787 + ((!dev->use_alt_cmd && is_read) ? AT91_TWI_MREAD : 0)); 792 788 793 789 dev->buf_len = m_start->len; 794 790 dev->buf = m_start->buf;
+1 -1
drivers/i2c/busses/i2c-bcm-iproc.c
··· 158 158 159 159 if (status & BIT(IS_M_START_BUSY_SHIFT)) { 160 160 iproc_i2c->xfer_is_done = 1; 161 - complete_all(&iproc_i2c->done); 161 + complete(&iproc_i2c->done); 162 162 } 163 163 164 164 writel(status, iproc_i2c->base + IS_OFFSET);
+1 -1
drivers/i2c/busses/i2c-bcm-kona.c
··· 229 229 dev->base + TXFCR_OFFSET); 230 230 231 231 writel(status & ~ISR_RESERVED_MASK, dev->base + ISR_OFFSET); 232 - complete_all(&dev->done); 232 + complete(&dev->done); 233 233 234 234 return IRQ_HANDLED; 235 235 }
+1 -1
drivers/i2c/busses/i2c-brcmstb.c
··· 228 228 return IRQ_NONE; 229 229 230 230 brcmstb_i2c_enable_disable_irq(dev, INT_DISABLE); 231 - complete_all(&dev->done); 231 + complete(&dev->done); 232 232 233 233 dev_dbg(dev->device, "isr handled"); 234 234 return IRQ_HANDLED;
+1 -1
drivers/i2c/busses/i2c-cros-ec-tunnel.c
··· 215 215 msg->outsize = request_len; 216 216 msg->insize = response_len; 217 217 218 - result = cros_ec_cmd_xfer(bus->ec, msg); 218 + result = cros_ec_cmd_xfer_status(bus->ec, msg); 219 219 if (result < 0) { 220 220 dev_err(dev, "Error transferring EC i2c message %d\n", result); 221 221 goto exit;
+3 -3
drivers/i2c/busses/i2c-meson.c
··· 211 211 meson_i2c_add_token(i2c, TOKEN_STOP); 212 212 } else { 213 213 i2c->state = STATE_IDLE; 214 - complete_all(&i2c->done); 214 + complete(&i2c->done); 215 215 } 216 216 } 217 217 ··· 238 238 dev_dbg(i2c->dev, "error bit set\n"); 239 239 i2c->error = -ENXIO; 240 240 i2c->state = STATE_IDLE; 241 - complete_all(&i2c->done); 241 + complete(&i2c->done); 242 242 goto out; 243 243 } 244 244 ··· 269 269 break; 270 270 case STATE_STOP: 271 271 i2c->state = STATE_IDLE; 272 - complete_all(&i2c->done); 272 + complete(&i2c->done); 273 273 break; 274 274 case STATE_IDLE: 275 275 break;
+10 -4
drivers/i2c/busses/i2c-ocores.c
··· 379 379 if (!clock_frequency_present) { 380 380 dev_err(&pdev->dev, 381 381 "Missing required parameter 'opencores,ip-clock-frequency'\n"); 382 + clk_disable_unprepare(i2c->clk); 382 383 return -ENODEV; 383 384 } 384 385 i2c->ip_clock_khz = clock_frequency / 1000; ··· 468 467 default: 469 468 dev_err(&pdev->dev, "Unsupported I/O width (%d)\n", 470 469 i2c->reg_io_width); 471 - return -EINVAL; 470 + ret = -EINVAL; 471 + goto err_clk; 472 472 } 473 473 } 474 474 475 475 ret = ocores_init(&pdev->dev, i2c); 476 476 if (ret) 477 - return ret; 477 + goto err_clk; 478 478 479 479 init_waitqueue_head(&i2c->wait); 480 480 ret = devm_request_irq(&pdev->dev, irq, ocores_isr, 0, 481 481 pdev->name, i2c); 482 482 if (ret) { 483 483 dev_err(&pdev->dev, "Cannot claim IRQ\n"); 484 - return ret; 484 + goto err_clk; 485 485 } 486 486 487 487 /* hook up driver to tree */ ··· 496 494 ret = i2c_add_adapter(&i2c->adap); 497 495 if (ret) { 498 496 dev_err(&pdev->dev, "Failed to add adapter\n"); 499 - return ret; 497 + goto err_clk; 500 498 } 501 499 502 500 /* add in known devices to the bus */ ··· 506 504 } 507 505 508 506 return 0; 507 + 508 + err_clk: 509 + clk_disable_unprepare(i2c->clk); 510 + return ret; 509 511 } 510 512 511 513 static int ocores_i2c_remove(struct platform_device *pdev)
+3 -1
drivers/i2c/muxes/i2c-demux-pinctrl.c
··· 68 68 adap = of_find_i2c_adapter_by_node(priv->chan[new_chan].parent_np); 69 69 if (!adap) { 70 70 ret = -ENODEV; 71 - goto err; 71 + goto err_with_revert; 72 72 } 73 73 74 74 p = devm_pinctrl_get_select(adap->dev.parent, priv->bus_name); ··· 103 103 104 104 err_with_put: 105 105 i2c_put_adapter(adap); 106 + err_with_revert: 107 + of_changeset_revert(&priv->chan[new_chan].chgset); 106 108 err: 107 109 dev_err(priv->dev, "failed to setup demux-adapter %d (%d)\n", new_chan, ret); 108 110 return ret;