Skip to content

Commit 658daa9

Browse files
geertugregkh
authored andcommitted
serial: sh-sci: Simplify sci_submit_rx() error handling
Simplify the error handling in sci_submit_rx() by - Moving it to the end of the function, - Just calling dmaengine_terminate_all() instead of calling async_tx_ack() for all already submitted descriptors. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 32f2ce0 commit 658daa9

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

drivers/tty/serial/sh-sci.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1398,35 +1398,35 @@ static void sci_submit_rx(struct sci_port *s)
13981398

13991399
desc = dmaengine_prep_slave_sg(chan,
14001400
sg, 1, DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT);
1401+
if (!desc)
1402+
goto fail;
14011403

1402-
if (desc) {
1403-
s->desc_rx[i] = desc;
1404-
desc->callback = sci_dma_rx_complete;
1405-
desc->callback_param = s;
1406-
s->cookie_rx[i] = dmaengine_submit(desc);
1407-
}
1404+
s->desc_rx[i] = desc;
1405+
desc->callback = sci_dma_rx_complete;
1406+
desc->callback_param = s;
1407+
s->cookie_rx[i] = dmaengine_submit(desc);
1408+
if (dma_submit_error(s->cookie_rx[i]))
1409+
goto fail;
14081410

1409-
if (!desc || dma_submit_error(s->cookie_rx[i])) {
1410-
if (i) {
1411-
async_tx_ack(s->desc_rx[0]);
1412-
s->cookie_rx[0] = -EINVAL;
1413-
}
1414-
if (desc) {
1415-
async_tx_ack(desc);
1416-
s->cookie_rx[i] = -EINVAL;
1417-
}
1418-
dev_warn(s->port.dev,
1419-
"Failed to re-start Rx DMA, using PIO\n");
1420-
sci_rx_dma_release(s, true);
1421-
return;
1422-
}
14231411
dev_dbg(s->port.dev, "%s(): cookie %d to #%d\n", __func__,
14241412
s->cookie_rx[i], i);
14251413
}
14261414

14271415
s->active_rx = s->cookie_rx[0];
14281416

14291417
dma_async_issue_pending(chan);
1418+
return;
1419+
1420+
fail:
1421+
if (i)
1422+
dmaengine_terminate_all(chan);
1423+
for (i = 0; i < 2; i++) {
1424+
s->desc_rx[i] = NULL;
1425+
s->cookie_rx[i] = -EINVAL;
1426+
}
1427+
s->active_rx = -EINVAL;
1428+
dev_warn(s->port.dev, "Failed to re-start Rx DMA, using PIO\n");
1429+
sci_rx_dma_release(s, true);
14301430
}
14311431

14321432
static void work_fn_rx(struct work_struct *work)

0 commit comments

Comments
 (0)