Skip to content

Commit a878090

Browse files
author
Wolfram Sang
committed
Merge tag 'i2c-host-fixes-6.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux into i2c/for-current
i2c-host-fixes for v6.16-rc6 omap: add missing error check and fix PM disable in probe error path. stm32: unmap DMA buffer on transfer failure and use correct device when mapping and unmapping during transfers.
2 parents d7b8f8e + 6aae87f commit a878090

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

drivers/i2c/busses/i2c-omap.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,7 +1472,9 @@ omap_i2c_probe(struct platform_device *pdev)
14721472
}
14731473

14741474
/* reset ASAP, clearing any IRQs */
1475-
omap_i2c_init(omap);
1475+
r = omap_i2c_init(omap);
1476+
if (r)
1477+
goto err_mux_state_deselect;
14761478

14771479
if (omap->rev < OMAP_I2C_OMAP1_REV_2)
14781480
r = devm_request_irq(&pdev->dev, omap->irq, omap_i2c_omap1_isr,
@@ -1515,12 +1517,13 @@ omap_i2c_probe(struct platform_device *pdev)
15151517

15161518
err_unuse_clocks:
15171519
omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0);
1520+
err_mux_state_deselect:
15181521
if (omap->mux_state)
15191522
mux_state_deselect(omap->mux_state);
15201523
err_put_pm:
1521-
pm_runtime_dont_use_autosuspend(omap->dev);
15221524
pm_runtime_put_sync(omap->dev);
15231525
err_disable_pm:
1526+
pm_runtime_dont_use_autosuspend(omap->dev);
15241527
pm_runtime_disable(&pdev->dev);
15251528

15261529
return r;

drivers/i2c/busses/i2c-stm32.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma,
102102
void *dma_async_param)
103103
{
104104
struct dma_async_tx_descriptor *txdesc;
105-
struct device *chan_dev;
106105
int ret;
107106

108107
if (rd_wr) {
@@ -116,11 +115,10 @@ int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma,
116115
}
117116

118117
dma->dma_len = len;
119-
chan_dev = dma->chan_using->device->dev;
120118

121-
dma->dma_buf = dma_map_single(chan_dev, buf, dma->dma_len,
119+
dma->dma_buf = dma_map_single(dev, buf, dma->dma_len,
122120
dma->dma_data_dir);
123-
if (dma_mapping_error(chan_dev, dma->dma_buf)) {
121+
if (dma_mapping_error(dev, dma->dma_buf)) {
124122
dev_err(dev, "DMA mapping failed\n");
125123
return -EINVAL;
126124
}
@@ -150,7 +148,7 @@ int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma,
150148
return 0;
151149

152150
err:
153-
dma_unmap_single(chan_dev, dma->dma_buf, dma->dma_len,
151+
dma_unmap_single(dev, dma->dma_buf, dma->dma_len,
154152
dma->dma_data_dir);
155153
return ret;
156154
}

drivers/i2c/busses/i2c-stm32f7.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -739,12 +739,13 @@ static void stm32f7_i2c_disable_dma_req(struct stm32f7_i2c_dev *i2c_dev)
739739

740740
static void stm32f7_i2c_dma_callback(void *arg)
741741
{
742-
struct stm32f7_i2c_dev *i2c_dev = (struct stm32f7_i2c_dev *)arg;
742+
struct stm32f7_i2c_dev *i2c_dev = arg;
743743
struct stm32_i2c_dma *dma = i2c_dev->dma;
744-
struct device *dev = dma->chan_using->device->dev;
745744

746745
stm32f7_i2c_disable_dma_req(i2c_dev);
747-
dma_unmap_single(dev, dma->dma_buf, dma->dma_len, dma->dma_data_dir);
746+
dmaengine_terminate_async(dma->chan_using);
747+
dma_unmap_single(i2c_dev->dev, dma->dma_buf, dma->dma_len,
748+
dma->dma_data_dir);
748749
complete(&dma->dma_complete);
749750
}
750751

@@ -1510,7 +1511,6 @@ static irqreturn_t stm32f7_i2c_handle_isr_errs(struct stm32f7_i2c_dev *i2c_dev,
15101511
u16 addr = f7_msg->addr;
15111512
void __iomem *base = i2c_dev->base;
15121513
struct device *dev = i2c_dev->dev;
1513-
struct stm32_i2c_dma *dma = i2c_dev->dma;
15141514

15151515
/* Bus error */
15161516
if (status & STM32F7_I2C_ISR_BERR) {
@@ -1551,10 +1551,8 @@ static irqreturn_t stm32f7_i2c_handle_isr_errs(struct stm32f7_i2c_dev *i2c_dev,
15511551
}
15521552

15531553
/* Disable dma */
1554-
if (i2c_dev->use_dma) {
1555-
stm32f7_i2c_disable_dma_req(i2c_dev);
1556-
dmaengine_terminate_async(dma->chan_using);
1557-
}
1554+
if (i2c_dev->use_dma)
1555+
stm32f7_i2c_dma_callback(i2c_dev);
15581556

15591557
i2c_dev->master_mode = false;
15601558
complete(&i2c_dev->complete);
@@ -1600,7 +1598,6 @@ static irqreturn_t stm32f7_i2c_isr_event_thread(int irq, void *data)
16001598
{
16011599
struct stm32f7_i2c_dev *i2c_dev = data;
16021600
struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
1603-
struct stm32_i2c_dma *dma = i2c_dev->dma;
16041601
void __iomem *base = i2c_dev->base;
16051602
u32 status, mask;
16061603
int ret;
@@ -1619,10 +1616,8 @@ static irqreturn_t stm32f7_i2c_isr_event_thread(int irq, void *data)
16191616
dev_dbg(i2c_dev->dev, "<%s>: Receive NACK (addr %x)\n",
16201617
__func__, f7_msg->addr);
16211618
writel_relaxed(STM32F7_I2C_ICR_NACKCF, base + STM32F7_I2C_ICR);
1622-
if (i2c_dev->use_dma) {
1623-
stm32f7_i2c_disable_dma_req(i2c_dev);
1624-
dmaengine_terminate_async(dma->chan_using);
1625-
}
1619+
if (i2c_dev->use_dma)
1620+
stm32f7_i2c_dma_callback(i2c_dev);
16261621
f7_msg->result = -ENXIO;
16271622
}
16281623

@@ -1640,8 +1635,7 @@ static irqreturn_t stm32f7_i2c_isr_event_thread(int irq, void *data)
16401635
ret = wait_for_completion_timeout(&i2c_dev->dma->dma_complete, HZ);
16411636
if (!ret) {
16421637
dev_dbg(i2c_dev->dev, "<%s>: Timed out\n", __func__);
1643-
stm32f7_i2c_disable_dma_req(i2c_dev);
1644-
dmaengine_terminate_async(dma->chan_using);
1638+
stm32f7_i2c_dma_callback(i2c_dev);
16451639
f7_msg->result = -ETIMEDOUT;
16461640
}
16471641
}

0 commit comments

Comments
 (0)