hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/mmc/host/usdhi6rol0.c
....@@ -1,10 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2013-2014 Renesas Electronics Europe Ltd.
34 * Author: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of version 2 of the GNU General Public License as
7
- * published by the Free Software Foundation.
85 */
96
107 #include <linux/clk.h>
....@@ -139,6 +136,8 @@
139136
140137 #define USDHI6_MIN_DMA 64
141138
139
+#define USDHI6_REQ_TIMEOUT_MS 4000
140
+
142141 enum usdhi6_wait_for {
143142 USDHI6_WAIT_FOR_REQUEST,
144143 USDHI6_WAIT_FOR_CMD,
....@@ -202,7 +201,6 @@
202201
203202 /* Pin control */
204203 struct pinctrl *pinctrl;
205
- struct pinctrl_state *pins_default;
206204 struct pinctrl_state *pins_uhs;
207205 };
208206
....@@ -680,12 +678,14 @@
680678 };
681679 int ret;
682680
683
- host->chan_tx = dma_request_slave_channel(mmc_dev(host->mmc), "tx");
681
+ host->chan_tx = dma_request_chan(mmc_dev(host->mmc), "tx");
684682 dev_dbg(mmc_dev(host->mmc), "%s: TX: got channel %p\n", __func__,
685683 host->chan_tx);
686684
687
- if (!host->chan_tx)
685
+ if (IS_ERR(host->chan_tx)) {
686
+ host->chan_tx = NULL;
688687 return;
688
+ }
689689
690690 cfg.direction = DMA_MEM_TO_DEV;
691691 cfg.dst_addr = start + USDHI6_SD_BUF0;
....@@ -695,12 +695,14 @@
695695 if (ret < 0)
696696 goto e_release_tx;
697697
698
- host->chan_rx = dma_request_slave_channel(mmc_dev(host->mmc), "rx");
698
+ host->chan_rx = dma_request_chan(mmc_dev(host->mmc), "rx");
699699 dev_dbg(mmc_dev(host->mmc), "%s: RX: got channel %p\n", __func__,
700700 host->chan_rx);
701701
702
- if (!host->chan_rx)
702
+ if (IS_ERR(host->chan_rx)) {
703
+ host->chan_rx = NULL;
703704 goto e_release_tx;
705
+ }
704706
705707 cfg.direction = DMA_DEV_TO_MEM;
706708 cfg.src_addr = cfg.dst_addr;
....@@ -1165,8 +1167,7 @@
11651167 host->pins_uhs);
11661168
11671169 default:
1168
- return pinctrl_select_state(host->pinctrl,
1169
- host->pins_default);
1170
+ return pinctrl_select_default_state(mmc_dev(host->mmc));
11701171 }
11711172 }
11721173
....@@ -1342,7 +1343,7 @@
13421343 host->wait = USDHI6_WAIT_FOR_STOP;
13431344 return 0;
13441345 }
1345
- /* Unsupported STOP command */
1346
+ fallthrough; /* Unsupported STOP command */
13461347 default:
13471348 dev_err(mmc_dev(host->mmc),
13481349 "unsupported stop CMD%d for CMD%d\n",
....@@ -1690,7 +1691,7 @@
16901691 switch (host->wait) {
16911692 default:
16921693 dev_err(mmc_dev(host->mmc), "Invalid state %u\n", host->wait);
1693
- /* mrq can be NULL in this actually impossible case */
1694
+ fallthrough; /* mrq can be NULL, but is impossible */
16941695 case USDHI6_WAIT_FOR_CMD:
16951696 usdhi6_error_code(host);
16961697 if (mrq)
....@@ -1712,10 +1713,7 @@
17121713 host->offset, data->blocks, data->blksz, data->sg_len,
17131714 sg_dma_len(sg), sg->offset);
17141715 usdhi6_sg_unmap(host, true);
1715
- /*
1716
- * If USDHI6_WAIT_FOR_DATA_END times out, we have already unmapped
1717
- * the page
1718
- */
1716
+ fallthrough; /* page unmapped in USDHI6_WAIT_FOR_DATA_END */
17191717 case USDHI6_WAIT_FOR_DATA_END:
17201718 usdhi6_error_code(host);
17211719 data->error = -ETIMEDOUT;
....@@ -1767,7 +1765,12 @@
17671765 host = mmc_priv(mmc);
17681766 host->mmc = mmc;
17691767 host->wait = USDHI6_WAIT_FOR_REQUEST;
1770
- host->timeout = msecs_to_jiffies(4000);
1768
+ host->timeout = msecs_to_jiffies(USDHI6_REQ_TIMEOUT_MS);
1769
+ /*
1770
+ * We use a fixed timeout of 4s, hence inform the core about it. A
1771
+ * future improvement should instead respect the cmd->busy_timeout.
1772
+ */
1773
+ mmc->max_busy_timeout = USDHI6_REQ_TIMEOUT_MS;
17711774
17721775 host->pinctrl = devm_pinctrl_get(&pdev->dev);
17731776 if (IS_ERR(host->pinctrl)) {
....@@ -1776,17 +1779,6 @@
17761779 }
17771780
17781781 host->pins_uhs = pinctrl_lookup_state(host->pinctrl, "state_uhs");
1779
- if (!IS_ERR(host->pins_uhs)) {
1780
- host->pins_default = pinctrl_lookup_state(host->pinctrl,
1781
- PINCTRL_STATE_DEFAULT);
1782
-
1783
- if (IS_ERR(host->pins_default)) {
1784
- dev_err(dev,
1785
- "UHS pinctrl requires a default pin state.\n");
1786
- ret = PTR_ERR(host->pins_default);
1787
- goto e_free_mmc;
1788
- }
1789
- }
17901782
17911783 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
17921784 host->base = devm_ioremap_resource(dev, res);