Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58870241 authored by Jaehoon Chung's avatar Jaehoon Chung Committed by Ulf Hansson
Browse files

mmc: dw_mmc: remove the loop about finding slots



dwmmc controller has used the only one slot.
It doesn't need to check the other slots.
Remove the loop about finding slots.

Signed-off-by: default avatarJaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: default avatarShawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent d30a8f7b
Loading
Loading
Loading
Loading
+36 −79
Original line number Diff line number Diff line
@@ -2563,26 +2563,21 @@ static void dw_mci_cmd_interrupt(struct dw_mci *host, u32 status)

static void dw_mci_handle_cd(struct dw_mci *host)
{
	int i;

	for (i = 0; i < host->num_slots; i++) {
	int i = 0;
	struct dw_mci_slot *slot = host->slot[i];

		if (!slot)
			continue;

	if (slot->mmc->ops->card_event)
		slot->mmc->ops->card_event(slot->mmc);
	mmc_detect_change(slot->mmc,
		msecs_to_jiffies(host->pdata->detect_delay_ms));
}
}

static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
{
	struct dw_mci *host = dev_id;
	u32 pending;
	int i;
	int i = 0;
	struct dw_mci_slot *slot = host->slot[i];

	pending = mci_readl(host, MINTSTS); /* read-only mask reg */

@@ -2659,20 +2654,12 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
			dw_mci_handle_cd(host);
		}

		/* Handle SDIO Interrupts */
		for (i = 0; i < host->num_slots; i++) {
			struct dw_mci_slot *slot = host->slot[i];

			if (!slot)
				continue;

		if (pending & SDMMC_INT_SDIO(slot->sdio_id)) {
			mci_writel(host, RINTSTS,
				   SDMMC_INT_SDIO(slot->sdio_id));
			__dw_mci_enable_sdio_irq(slot, 0);
			sdio_signal_irq(slot->mmc);
		}
		}

	}

@@ -3011,37 +2998,31 @@ static void dw_mci_enable_cd(struct dw_mci *host)
{
	unsigned long irqflags;
	u32 temp;
	int i;
	int i = 0;
	struct dw_mci_slot *slot;

	/*
	 * No need for CD if all slots have a non-error GPIO
	 * as well as broken card detection is found.
	 */
	for (i = 0; i < host->num_slots; i++) {
	slot = host->slot[i];
	if (slot->mmc->caps & MMC_CAP_NEEDS_POLL)
		return;

		if (mmc_gpio_get_cd(slot->mmc) < 0)
			break;
	}
	if (i == host->num_slots)
		return;

	if (mmc_gpio_get_cd(slot->mmc) < 0) {
		spin_lock_irqsave(&host->irq_lock, irqflags);
		temp = mci_readl(host, INTMASK);
		temp  |= SDMMC_INT_CD;
		mci_writel(host, INTMASK, temp);
		spin_unlock_irqrestore(&host->irq_lock, irqflags);
	}
}

int dw_mci_probe(struct dw_mci *host)
{
	const struct dw_mci_drv_data *drv_data = host->drv_data;
	int width, i, ret = 0;
	u32 fifo_size;
	int init_slots = 0;

	if (!host->pdata) {
		host->pdata = dw_mci_parse_dt(host);
@@ -3204,13 +3185,6 @@ int dw_mci_probe(struct dw_mci *host)
	if (ret)
		goto err_dmaunmap;

	/*
	 * Even though dwmmc IP is provided the multiple slots,
	 * there is no use case in mmc subsystem.
	 * dwmmc host controller needs to initialize the one slot per an IP.
	 */
	host->num_slots = 1;

	/*
	 * Enable interrupts for command done, data over, data empty,
	 * receive ready and error such as transmit, receive timeout, crc error
@@ -3226,20 +3200,9 @@ int dw_mci_probe(struct dw_mci *host)
		 host->irq, width, fifo_size);

	/* We need at least one slot to succeed */
	for (i = 0; i < host->num_slots; i++) {
		ret = dw_mci_init_slot(host, i);
		if (ret)
	ret = dw_mci_init_slot(host, 0);
	if (ret) {
		dev_dbg(host->dev, "slot %d init failed\n", i);
		else
			init_slots++;
	}

	if (init_slots) {
		dev_info(host->dev, "%d slots initialized\n", init_slots);
	} else {
		dev_dbg(host->dev,
			"attempted to initialize %d slots, but failed on all\n",
			host->num_slots);
		goto err_dmaunmap;
	}

@@ -3267,13 +3230,11 @@ EXPORT_SYMBOL(dw_mci_probe);

void dw_mci_remove(struct dw_mci *host)
{
	int i;
	int i = 0;

	for (i = 0; i < host->num_slots; i++) {
	dev_dbg(host->dev, "remove slot %d\n", i);
	if (host->slot[i])
		dw_mci_cleanup_slot(host->slot[i], i);
	}

	mci_writel(host, RINTSTS, 0xFFFFFFFF);
	mci_writel(host, INTMASK, 0); /* disable all mmc interrupt first */
@@ -3316,8 +3277,9 @@ EXPORT_SYMBOL(dw_mci_runtime_suspend);

int dw_mci_runtime_resume(struct device *dev)
{
	int i, ret = 0;
	int i = 0, ret = 0;
	struct dw_mci *host = dev_get_drvdata(dev);
	struct dw_mci_slot *slot = host->slot[i];

	if (host->cur_slot &&
	    (mmc_can_gpio_cd(host->cur_slot->mmc) ||
@@ -3356,17 +3318,12 @@ int dw_mci_runtime_resume(struct device *dev)
		   DW_MCI_ERROR_FLAGS);
	mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE);

	for (i = 0; i < host->num_slots; i++) {
		struct dw_mci_slot *slot = host->slot[i];

		if (!slot)
			continue;
	if (slot->mmc->pm_flags & MMC_PM_KEEP_POWER)
		dw_mci_set_ios(slot->mmc, &slot->mmc->ios);

	/* Force setup bus to guarantee available clock output */
	dw_mci_setup_bus(slot, true);
	}

	/* Now that slots are all setup, we can enable card detect */
	dw_mci_enable_cd(host);