From: Shawn Lin <shawn.lin@rock-chips.com>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: linux-mmc@vger.kernel.org, Jaehoon Chung <jh80.chung@samsung.com>,
Shawn Lin <shawn.lin@rock-chips.com>
Subject: [PATCH 05/13] mmc: dw_mmc: Move struct mmc_host from struct dw_mci_slot to struct dw_mci
Date: Thu, 20 Nov 2025 18:29:17 +0800 [thread overview]
Message-ID: <1763634565-183891-6-git-send-email-shawn.lin@rock-chips.com> (raw)
In-Reply-To: <1763634565-183891-1-git-send-email-shawn.lin@rock-chips.com>
No functional change intended.
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
---
drivers/mmc/host/dw_mmc-exynos.c | 2 +-
drivers/mmc/host/dw_mmc-hi3798cv200.c | 2 +-
drivers/mmc/host/dw_mmc-hi3798mv200.c | 2 +-
drivers/mmc/host/dw_mmc-k3.c | 2 +-
drivers/mmc/host/dw_mmc-rockchip.c | 2 +-
drivers/mmc/host/dw_mmc-starfive.c | 2 +-
drivers/mmc/host/dw_mmc.c | 62 +++++++++++++++++------------------
drivers/mmc/host/dw_mmc.h | 4 +--
8 files changed, 38 insertions(+), 40 deletions(-)
diff --git a/drivers/mmc/host/dw_mmc-exynos.c b/drivers/mmc/host/dw_mmc-exynos.c
index 3846096..067569b 100644
--- a/drivers/mmc/host/dw_mmc-exynos.c
+++ b/drivers/mmc/host/dw_mmc-exynos.c
@@ -534,7 +534,7 @@ static int dw_mci_exynos_execute_tuning(struct dw_mci_slot *slot, u32 opcode)
{
struct dw_mci *host = slot->host;
struct dw_mci_exynos_priv_data *priv = host->priv;
- struct mmc_host *mmc = slot->mmc;
+ struct mmc_host *mmc = host->mmc;
u8 start_smpl, smpl, candidates = 0;
s8 found;
int ret = 0;
diff --git a/drivers/mmc/host/dw_mmc-hi3798cv200.c b/drivers/mmc/host/dw_mmc-hi3798cv200.c
index 0ccfae1..03f7ed8 100644
--- a/drivers/mmc/host/dw_mmc-hi3798cv200.c
+++ b/drivers/mmc/host/dw_mmc-hi3798cv200.c
@@ -72,7 +72,7 @@ static int dw_mci_hi3798cv200_execute_tuning(struct dw_mci_slot *slot,
clk_set_phase(priv->sample_clk, degrees[i]);
mci_writel(host, RINTSTS, ALL_INT_CLR);
- err = mmc_send_tuning(slot->mmc, opcode, NULL);
+ err = mmc_send_tuning(host->mmc, opcode, NULL);
if (!err)
found = 1;
diff --git a/drivers/mmc/host/dw_mmc-hi3798mv200.c b/drivers/mmc/host/dw_mmc-hi3798mv200.c
index 5791a97..3cc4bc2 100644
--- a/drivers/mmc/host/dw_mmc-hi3798mv200.c
+++ b/drivers/mmc/host/dw_mmc-hi3798mv200.c
@@ -115,7 +115,7 @@ static int dw_mci_hi3798mv200_execute_tuning_mix_mode(struct dw_mci_slot *slot,
*
* Treat edge(flip) found as an error too.
*/
- err = mmc_send_tuning(slot->mmc, opcode, NULL);
+ err = mmc_send_tuning(host->mmc, opcode, NULL);
regval = mci_readl(host, TUNING_CTRL);
if (err || (regval & SDMMC_TUNING_FIND_EDGE))
err = 1;
diff --git a/drivers/mmc/host/dw_mmc-k3.c b/drivers/mmc/host/dw_mmc-k3.c
index ad6aa1a..4ef99c0 100644
--- a/drivers/mmc/host/dw_mmc-k3.c
+++ b/drivers/mmc/host/dw_mmc-k3.c
@@ -368,7 +368,7 @@ static int dw_mci_hi3660_execute_tuning(struct dw_mci_slot *slot, u32 opcode)
{
int i = 0;
struct dw_mci *host = slot->host;
- struct mmc_host *mmc = slot->mmc;
+ struct mmc_host *mmc = host->mmc;
int smpl_phase = 0;
u32 tuning_sample_flag = 0;
int best_clksmpl = 0;
diff --git a/drivers/mmc/host/dw_mmc-rockchip.c b/drivers/mmc/host/dw_mmc-rockchip.c
index 62c68cd..ffffbf59 100644
--- a/drivers/mmc/host/dw_mmc-rockchip.c
+++ b/drivers/mmc/host/dw_mmc-rockchip.c
@@ -286,7 +286,7 @@ static int dw_mci_rk3288_execute_tuning(struct dw_mci_slot *slot, u32 opcode)
{
struct dw_mci *host = slot->host;
struct dw_mci_rockchip_priv_data *priv = host->priv;
- struct mmc_host *mmc = slot->mmc;
+ struct mmc_host *mmc = host->mmc;
int ret = 0;
int i;
bool v, prev_v = 0, first_v;
diff --git a/drivers/mmc/host/dw_mmc-starfive.c b/drivers/mmc/host/dw_mmc-starfive.c
index 34964b0..d4ea289 100644
--- a/drivers/mmc/host/dw_mmc-starfive.c
+++ b/drivers/mmc/host/dw_mmc-starfive.c
@@ -65,7 +65,7 @@ static int dw_mci_starfive_execute_tuning(struct dw_mci_slot *slot,
dw_mci_starfive_set_sample_phase(host, smpl_phase);
mci_writel(host, RINTSTS, ALL_INT_CLR);
- ret = mmc_send_tuning(slot->mmc, opcode, NULL);
+ ret = mmc_send_tuning(host->mmc, opcode, NULL);
if (!ret && smpl_raise < 0) {
smpl_raise = smpl_phase;
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 2e2d492..26db1ef 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -160,8 +160,8 @@ DEFINE_SHOW_ATTRIBUTE(dw_mci_regs);
static void dw_mci_init_debugfs(struct dw_mci_slot *slot)
{
- struct mmc_host *mmc = slot->mmc;
struct dw_mci *host = slot->host;
+ struct mmc_host *mmc = host->mmc;
struct dentry *root;
root = mmc->debugfs_root;
@@ -237,7 +237,7 @@ static void mci_send_cmd(struct dw_mci_slot *slot, u32 cmd, u32 arg)
if (readl_poll_timeout_atomic(host->regs + SDMMC_CMD, cmd_status,
!(cmd_status & SDMMC_CMD_START),
1, 500 * USEC_PER_MSEC))
- dev_err(&slot->mmc->class_dev,
+ dev_err(&host->mmc->class_dev,
"Timeout sending command (cmd %#x arg %#x status %#x)\n",
cmd, arg, cmd_status);
}
@@ -473,7 +473,7 @@ static void dw_mci_dmac_complete_dma(void *arg)
if ((host->use_dma == TRANS_MODE_EDMAC) &&
data && (data->flags & MMC_DATA_READ))
/* Invalidate cache after read */
- dma_sync_sg_for_cpu(mmc_dev(host->slot->mmc),
+ dma_sync_sg_for_cpu(mmc_dev(host->mmc),
data->sg,
data->sg_len,
DMA_FROM_DEVICE);
@@ -755,7 +755,7 @@ static int dw_mci_edmac_start_dma(struct dw_mci *host,
/* Flush cache before write */
if (host->data->flags & MMC_DATA_WRITE)
- dma_sync_sg_for_device(mmc_dev(host->slot->mmc), sgl,
+ dma_sync_sg_for_device(mmc_dev(host->mmc), sgl,
sg_elems, DMA_TO_DEVICE);
dma_async_issue_pending(host->dms->ch);
@@ -1144,7 +1144,7 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
if (host->state == STATE_WAITING_CMD11_DONE)
sdmmc_cmd_bits |= SDMMC_CMD_VOLT_SWITCH;
- slot->mmc->actual_clock = 0;
+ host->mmc->actual_clock = 0;
if (!clock) {
mci_writel(host, CLKENA, 0);
@@ -1165,7 +1165,7 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
force_clkinit) {
/* Silent the verbose log if calling from PM context */
if (!force_clkinit)
- dev_info(&slot->mmc->class_dev,
+ dev_info(&host->mmc->class_dev,
"Bus speed (slot %d) = %dHz (slot req %dHz, actual %dHZ div = %d)\n",
slot->id, host->bus_hz, clock,
div ? ((host->bus_hz / div) >> 1) :
@@ -1175,8 +1175,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
* If card is polling, display the message only
* one time at boot time.
*/
- if (slot->mmc->caps & MMC_CAP_NEEDS_POLL &&
- slot->mmc->f_min == clock)
+ if (host->mmc->caps & MMC_CAP_NEEDS_POLL &&
+ host->mmc->f_min == clock)
set_bit(DW_MMC_CARD_NEEDS_POLL, &slot->flags);
}
@@ -1204,7 +1204,7 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
/* keep the last clock value that was requested from core */
slot->__clk_old = clock;
- slot->mmc->actual_clock = div ? ((host->bus_hz / div) >> 1) :
+ host->mmc->actual_clock = div ? ((host->bus_hz / div) >> 1) :
host->bus_hz;
}
@@ -1270,7 +1270,7 @@ static void __dw_mci_start_request(struct dw_mci *host,
mci_writel(host, BLKSIZ, data->blksz);
}
- cmdflags = dw_mci_prepare_command(slot->mmc, cmd);
+ cmdflags = dw_mci_prepare_command(host->mmc, cmd);
/* this is the first command, send the initialization clock */
if (test_and_clear_bit(DW_MMC_CARD_NEED_INIT, &slot->flags))
@@ -1320,13 +1320,13 @@ static void dw_mci_start_request(struct dw_mci *host,
static void dw_mci_queue_request(struct dw_mci *host, struct dw_mci_slot *slot,
struct mmc_request *mrq)
{
- dev_vdbg(&slot->mmc->class_dev, "queue request: state=%d\n",
+ dev_vdbg(&host->mmc->class_dev, "queue request: state=%d\n",
host->state);
slot->mrq = mrq;
if (host->state == STATE_WAITING_CMD11_DONE) {
- dev_warn(&slot->mmc->class_dev,
+ dev_warn(&host->mmc->class_dev,
"Voltage change didn't complete\n");
/*
* this case isn't expected to happen, so we can
@@ -1816,7 +1816,7 @@ static void dw_mci_request_end(struct dw_mci *host, struct mmc_request *mrq)
__acquires(&host->lock)
{
struct dw_mci_slot *slot;
- struct mmc_host *prev_mmc = host->slot->mmc;
+ struct mmc_host *prev_mmc = host->mmc;
WARN_ON(host->cmd || host->data);
@@ -1827,7 +1827,7 @@ static void dw_mci_request_end(struct dw_mci *host, struct mmc_request *mrq)
struct dw_mci_slot, queue_node);
list_del(&slot->queue_node);
dev_vdbg(host->dev, "list not empty: %s is next\n",
- mmc_hostname(slot->mmc));
+ mmc_hostname(host->mmc));
host->state = STATE_SENDING_CMD;
dw_mci_start_request(host, slot);
} else {
@@ -2723,9 +2723,7 @@ static void dw_mci_cmd_interrupt(struct dw_mci *host, u32 status)
static void dw_mci_handle_cd(struct dw_mci *host)
{
- struct dw_mci_slot *slot = host->slot;
-
- mmc_detect_change(slot->mmc,
+ mmc_detect_change(host->mmc,
msecs_to_jiffies(host->pdata->detect_delay_ms));
}
@@ -2838,7 +2836,7 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
mci_writel(host, RINTSTS,
SDMMC_INT_SDIO(slot->sdio_id));
__dw_mci_enable_sdio_irq(slot, 0);
- sdio_signal_irq(slot->mmc);
+ sdio_signal_irq(host->mmc);
}
}
@@ -2874,7 +2872,7 @@ static int dw_mci_init_slot_caps(struct dw_mci_slot *slot)
{
struct dw_mci *host = slot->host;
const struct dw_mci_drv_data *drv_data = host->drv_data;
- struct mmc_host *mmc = slot->mmc;
+ struct mmc_host *mmc = host->mmc;
int ctrl_id;
if (host->pdata->caps)
@@ -2935,7 +2933,7 @@ static int dw_mci_init_slot(struct dw_mci *host)
slot = mmc_priv(mmc);
slot->id = 0;
slot->sdio_id = host->sdio_id0 + slot->id;
- slot->mmc = mmc;
+ host->mmc = mmc;
slot->host = host;
host->slot = slot;
@@ -2997,7 +2995,7 @@ static int dw_mci_init_slot(struct dw_mci *host)
static void dw_mci_cleanup_slot(struct dw_mci_slot *slot)
{
/* Debugfs stuff is cleaned up by mmc core */
- mmc_remove_host(slot->mmc);
+ mmc_remove_host(slot->host->mmc);
slot->host->slot = NULL;
}
@@ -3269,10 +3267,10 @@ static void dw_mci_enable_cd(struct dw_mci *host)
* No need for CD if all slots have a non-error GPIO
* as well as broken card detection is found.
*/
- if (host->slot->mmc->caps & MMC_CAP_NEEDS_POLL)
+ if (host->mmc->caps & MMC_CAP_NEEDS_POLL)
return;
- if (mmc_gpio_get_cd(host->slot->mmc) < 0) {
+ if (mmc_gpio_get_cd(host->mmc) < 0) {
spin_lock_irqsave(&host->irq_lock, irqflags);
temp = mci_readl(host, INTMASK);
temp |= SDMMC_INT_CD;
@@ -3536,8 +3534,8 @@ int dw_mci_runtime_suspend(struct device *dev)
clk_disable_unprepare(host->ciu_clk);
if (host->slot &&
- (mmc_host_can_gpio_cd(host->slot->mmc) ||
- !mmc_card_is_removable(host->slot->mmc)))
+ (mmc_host_can_gpio_cd(host->mmc) ||
+ !mmc_card_is_removable(host->mmc)))
clk_disable_unprepare(host->biu_clk);
return 0;
@@ -3550,8 +3548,8 @@ int dw_mci_runtime_resume(struct device *dev)
struct dw_mci *host = dev_get_drvdata(dev);
if (host->slot &&
- (mmc_host_can_gpio_cd(host->slot->mmc) ||
- !mmc_card_is_removable(host->slot->mmc))) {
+ (mmc_host_can_gpio_cd(host->mmc) ||
+ !mmc_card_is_removable(host->mmc))) {
ret = clk_prepare_enable(host->biu_clk);
if (ret)
return ret;
@@ -3587,14 +3585,14 @@ int dw_mci_runtime_resume(struct device *dev)
mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE);
- if (host->slot && host->slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
- dw_mci_set_ios(host->slot->mmc, &host->slot->mmc->ios);
+ if (host->slot && host->mmc->pm_flags & MMC_PM_KEEP_POWER)
+ dw_mci_set_ios(host->mmc, &host->mmc->ios);
/* Force setup bus to guarantee available clock output */
dw_mci_setup_bus(host->slot, true);
/* Re-enable SDIO interrupts. */
- if (sdio_irq_claimed(host->slot->mmc))
+ if (sdio_irq_claimed(host->mmc))
__dw_mci_enable_sdio_irq(host->slot, 1);
/* Now that slots are all setup, we can enable card detect */
@@ -3604,8 +3602,8 @@ int dw_mci_runtime_resume(struct device *dev)
err:
if (host->slot &&
- (mmc_host_can_gpio_cd(host->slot->mmc) ||
- !mmc_card_is_removable(host->slot->mmc)))
+ (mmc_host_can_gpio_cd(host->mmc) ||
+ !mmc_card_is_removable(host->mmc)))
clk_disable_unprepare(host->biu_clk);
return ret;
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
index 6faa63b..b4efc58 100644
--- a/drivers/mmc/host/dw_mmc.h
+++ b/drivers/mmc/host/dw_mmc.h
@@ -127,6 +127,7 @@ struct dw_mci_dma_slave {
* @cmd11_timer: Timer for SD3.0 voltage switch over scheme.
* @cto_timer: Timer for broken command transfer over scheme.
* @dto_timer: Timer for broken data transfer over scheme.
+ * @mmc: The mmc_host representing this dw_mci.
*
* Locking
* =======
@@ -240,6 +241,7 @@ struct dw_mci {
struct fault_attr fail_data_crc;
struct hrtimer fault_timer;
#endif
+ struct mmc_host *mmc;
};
/* DMA ops for Internal/External DMAC interface */
@@ -543,7 +545,6 @@ static inline int dw_mci_runtime_resume(struct device *device) { return -EOPNOTS
/**
* struct dw_mci_slot - MMC slot state
- * @mmc: The mmc_host representing this slot.
* @host: The MMC controller this slot is using.
* @ctype: Card type for this slot.
* @mrq: mmc_request currently being processed or waiting to be
@@ -558,7 +559,6 @@ static inline int dw_mci_runtime_resume(struct device *device) { return -EOPNOTS
* @sdio_id: Number of this slot in the SDIO interrupt registers.
*/
struct dw_mci_slot {
- struct mmc_host *mmc;
struct dw_mci *host;
u32 ctype;
--
2.7.4
next prev parent reply other threads:[~2025-11-20 12:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 10:29 [PATCH 0/13] dw_mmc cleanup Shawn Lin
2025-11-20 10:29 ` [PATCH 01/13] mmc: dw_mmc: Remove unused struct dma_pdata Shawn Lin
2025-11-20 10:29 ` [PATCH 02/13] mmc: dw_mmc: add dw_mci_prepare_desc() for both of 32bit and 64bit DMA Shawn Lin
2025-11-20 10:29 ` [PATCH 03/13] mmc: dw_mmc: Remove vqmmc_enabled from struct dw_mci Shawn Lin
2025-11-25 12:23 ` Ulf Hansson
2025-11-20 10:29 ` [PATCH 04/13] mmc: dw_mmc: Remove unused header files and keep alphabetical order Shawn Lin
2025-11-20 10:29 ` Shawn Lin [this message]
2025-11-20 10:29 ` [PATCH 06/13] mmc: dw_mmc: Let glue drivers to use struct dw_mci as possible Shawn Lin
2025-11-20 10:29 ` [PATCH 07/13] mmc: dw_mmc: Move flags from struct dw_mci_slot to struct dw_mci Shawn Lin
2025-11-20 10:29 ` [PATCH 08/13] mmc: dw_mmc: Remove id from dw_mci_slot Shawn Lin
2025-11-20 10:29 ` [PATCH 09/13] mmc: dw_mmc: Remove sdio_id from struct dw_mci_slot Shawn Lin
2025-11-20 10:29 ` [PATCH 10/13] mmc: dw_mmc: Move clock rate stuff from struct dw_mci_slot to struct dw_mci Shawn Lin
2025-11-20 10:29 ` [PATCH 11/13] mmc: dw_mmc: Remove mrq from struct dw_mci_slot Shawn Lin
2025-11-20 10:29 ` [PATCH 12/13] mmc: dw_mmc: Remove queue from dw_mci Shawn Lin
2025-11-20 10:29 ` [PATCH 13/13] mmc: dw_mmc: Remove struct dw_mci_slot Shawn Lin
2025-11-22 18:40 ` kernel test robot
2025-11-22 19:54 ` kernel test robot
2025-11-20 11:10 ` [PATCH 0/13] dw_mmc cleanup Ulf Hansson
2025-11-20 12:51 ` Shawn Lin
2025-11-25 12:33 ` Ulf Hansson
2025-11-25 14:00 ` Shawn Lin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1763634565-183891-6-git-send-email-shawn.lin@rock-chips.com \
--to=shawn.lin@rock-chips.com \
--cc=jh80.chung@samsung.com \
--cc=linux-mmc@vger.kernel.org \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox