Skip to content

Commit 9e6c269

Browse files
committed
Merge tag 'i2c-for-6.5-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: "Usual set of driver fixes. A bit more than usual because I was unavailable for a while" * tag 'i2c-for-6.5-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: bcm-iproc: Fix bcm_iproc_i2c_isr deadlock issue i2c: Update documentation to use .probe() again i2c: sun6i-p2wi: Fix an error message in probe() i2c: hisi: Only handle the interrupt of the driver's transfer i2c: tegra: Fix i2c-tegra DMA config option processing i2c: tegra: Fix failure during probe deferral cleanup i2c: designware: Handle invalid SMBus block data response length value i2c: designware: Correct length byte validation logic i2c: imx-lpi2c: return -EINVAL when i2c peripheral clk doesn't work
2 parents 12e6cce + 4caf4cb commit 9e6c269

File tree

7 files changed

+37
-9
lines changed

7 files changed

+37
-9
lines changed

Documentation/i2c/writing-clients.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ driver model device node, and its I2C address.
4646
},
4747

4848
.id_table = foo_idtable,
49-
.probe_new = foo_probe,
49+
.probe = foo_probe,
5050
.remove = foo_remove,
5151
/* if device autodetection is needed: */
5252
.class = I2C_CLASS_SOMETHING,

drivers/i2c/busses/i2c-bcm-iproc.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,14 @@ static inline u32 iproc_i2c_rd_reg(struct bcm_iproc_i2c_dev *iproc_i2c,
233233
u32 offset)
234234
{
235235
u32 val;
236+
unsigned long flags;
236237

237238
if (iproc_i2c->idm_base) {
238-
spin_lock(&iproc_i2c->idm_lock);
239+
spin_lock_irqsave(&iproc_i2c->idm_lock, flags);
239240
writel(iproc_i2c->ape_addr_mask,
240241
iproc_i2c->idm_base + IDM_CTRL_DIRECT_OFFSET);
241242
val = readl(iproc_i2c->base + offset);
242-
spin_unlock(&iproc_i2c->idm_lock);
243+
spin_unlock_irqrestore(&iproc_i2c->idm_lock, flags);
243244
} else {
244245
val = readl(iproc_i2c->base + offset);
245246
}
@@ -250,12 +251,14 @@ static inline u32 iproc_i2c_rd_reg(struct bcm_iproc_i2c_dev *iproc_i2c,
250251
static inline void iproc_i2c_wr_reg(struct bcm_iproc_i2c_dev *iproc_i2c,
251252
u32 offset, u32 val)
252253
{
254+
unsigned long flags;
255+
253256
if (iproc_i2c->idm_base) {
254-
spin_lock(&iproc_i2c->idm_lock);
257+
spin_lock_irqsave(&iproc_i2c->idm_lock, flags);
255258
writel(iproc_i2c->ape_addr_mask,
256259
iproc_i2c->idm_base + IDM_CTRL_DIRECT_OFFSET);
257260
writel(val, iproc_i2c->base + offset);
258-
spin_unlock(&iproc_i2c->idm_lock);
261+
spin_unlock_irqrestore(&iproc_i2c->idm_lock, flags);
259262
} else {
260263
writel(val, iproc_i2c->base + offset);
261264
}

drivers/i2c/busses/i2c-designware-master.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,9 +588,21 @@ i2c_dw_read(struct dw_i2c_dev *dev)
588588
u32 flags = msgs[dev->msg_read_idx].flags;
589589

590590
regmap_read(dev->map, DW_IC_DATA_CMD, &tmp);
591+
tmp &= DW_IC_DATA_CMD_DAT;
591592
/* Ensure length byte is a valid value */
592-
if (flags & I2C_M_RECV_LEN &&
593-
(tmp & DW_IC_DATA_CMD_DAT) <= I2C_SMBUS_BLOCK_MAX && tmp > 0) {
593+
if (flags & I2C_M_RECV_LEN) {
594+
/*
595+
* if IC_EMPTYFIFO_HOLD_MASTER_EN is set, which cannot be
596+
* detected from the registers, the controller can be
597+
* disabled if the STOP bit is set. But it is only set
598+
* after receiving block data response length in
599+
* I2C_FUNC_SMBUS_BLOCK_DATA case. That needs to read
600+
* another byte with STOP bit set when the block data
601+
* response length is invalid to complete the transaction.
602+
*/
603+
if (!tmp || tmp > I2C_SMBUS_BLOCK_MAX)
604+
tmp = 1;
605+
594606
len = i2c_dw_recv_len(dev, tmp);
595607
}
596608
*buf++ = tmp;

drivers/i2c/busses/i2c-hisi.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,14 @@ static irqreturn_t hisi_i2c_irq(int irq, void *context)
330330
struct hisi_i2c_controller *ctlr = context;
331331
u32 int_stat;
332332

333+
/*
334+
* Don't handle the interrupt if cltr->completion is NULL. We may
335+
* reach here because the interrupt is spurious or the transfer is
336+
* started by another port (e.g. firmware) rather than us.
337+
*/
338+
if (!ctlr->completion)
339+
return IRQ_NONE;
340+
333341
int_stat = readl(ctlr->iobase + HISI_I2C_INT_MSTAT);
334342
hisi_i2c_clear_int(ctlr, int_stat);
335343
if (!(int_stat & HISI_I2C_INT_ALL))

drivers/i2c/busses/i2c-imx-lpi2c.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ static int lpi2c_imx_config(struct lpi2c_imx_struct *lpi2c_imx)
209209
lpi2c_imx_set_mode(lpi2c_imx);
210210

211211
clk_rate = clk_get_rate(lpi2c_imx->clks[0].clk);
212+
if (!clk_rate)
213+
return -EINVAL;
214+
212215
if (lpi2c_imx->mode == HS || lpi2c_imx->mode == ULTRA_FAST)
213216
filt = 0;
214217
else

drivers/i2c/busses/i2c-sun6i-p2wi.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ static int p2wi_probe(struct platform_device *pdev)
250250

251251
p2wi->rstc = devm_reset_control_get_exclusive(dev, NULL);
252252
if (IS_ERR(p2wi->rstc)) {
253-
dev_err(dev, "failed to retrieve reset controller: %d\n", ret);
253+
dev_err(dev, "failed to retrieve reset controller: %pe\n",
254+
p2wi->rstc);
254255
return PTR_ERR(p2wi->rstc);
255256
}
256257

drivers/i2c/busses/i2c-tegra.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)
442442
if (IS_VI(i2c_dev))
443443
return 0;
444444

445-
if (!i2c_dev->hw->has_apb_dma) {
445+
if (i2c_dev->hw->has_apb_dma) {
446446
if (!IS_ENABLED(CONFIG_TEGRA20_APB_DMA)) {
447447
dev_dbg(i2c_dev->dev, "APB DMA support not enabled\n");
448448
return 0;
@@ -460,6 +460,7 @@ static int tegra_i2c_init_dma(struct tegra_i2c_dev *i2c_dev)
460460
i2c_dev->dma_chan = dma_request_chan(i2c_dev->dev, "tx");
461461
if (IS_ERR(i2c_dev->dma_chan)) {
462462
err = PTR_ERR(i2c_dev->dma_chan);
463+
i2c_dev->dma_chan = NULL;
463464
goto err_out;
464465
}
465466

0 commit comments

Comments
 (0)