Commit 7a2fa8ee authored by Rosen Penev's avatar Rosen Penev Committed by Ulf Hansson
Browse files

mmc: mtk-sd: use devm_mmc_alloc_host



Allows removing several gotos.

Also fixed some wrong ones.

Added dev_err_probe where EPROBE_DEFER is possible.

Signed-off-by: default avatarRosen Penev <rosenp@gmail.com>
Link: https://lore.kernel.org/r/20240930224919.355359-2-rosenp@gmail.com


Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent c0d5538c
Loading
Loading
Loading
Loading
+20 −35
Original line number Diff line number Diff line
@@ -2761,20 +2761,18 @@ static int msdc_drv_probe(struct platform_device *pdev)
	}

	/* Allocate MMC host for this device */
	mmc = mmc_alloc_host(sizeof(struct msdc_host), &pdev->dev);
	mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(struct msdc_host));
	if (!mmc)
		return -ENOMEM;

	host = mmc_priv(mmc);
	ret = mmc_of_parse(mmc);
	if (ret)
		goto host_free;
		return ret;

	host->base = devm_platform_ioremap_resource(pdev, 0);
	if (IS_ERR(host->base)) {
		ret = PTR_ERR(host->base);
		goto host_free;
	}
	if (IS_ERR(host->base))
		return PTR_ERR(host->base);

	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
	if (res) {
@@ -2785,18 +2783,16 @@ static int msdc_drv_probe(struct platform_device *pdev)

	ret = mmc_regulator_get_supply(mmc);
	if (ret)
		goto host_free;
		return ret;

	ret = msdc_of_clock_parse(pdev, host);
	if (ret)
		goto host_free;
		return ret;

	host->reset = devm_reset_control_get_optional_exclusive(&pdev->dev,
								"hrst");
	if (IS_ERR(host->reset)) {
		ret = PTR_ERR(host->reset);
		goto host_free;
	}
	if (IS_ERR(host->reset))
		return PTR_ERR(host->reset);

	/* only eMMC has crypto property */
	if (!(mmc->caps2 & MMC_CAP2_NO_MMC)) {
@@ -2808,30 +2804,24 @@ static int msdc_drv_probe(struct platform_device *pdev)
	}

	host->irq = platform_get_irq(pdev, 0);
	if (host->irq < 0) {
		ret = host->irq;
		goto host_free;
	}
	if (host->irq < 0)
		return host->irq;

	host->pinctrl = devm_pinctrl_get(&pdev->dev);
	if (IS_ERR(host->pinctrl)) {
		ret = PTR_ERR(host->pinctrl);
		dev_err(&pdev->dev, "Cannot find pinctrl!\n");
		goto host_free;
	}
	if (IS_ERR(host->pinctrl))
		return dev_err_probe(&pdev->dev, PTR_ERR(host->pinctrl),
				     "Cannot find pinctrl");

	host->pins_default = pinctrl_lookup_state(host->pinctrl, "default");
	if (IS_ERR(host->pins_default)) {
		ret = PTR_ERR(host->pins_default);
		dev_err(&pdev->dev, "Cannot find pinctrl default!\n");
		goto host_free;
		return PTR_ERR(host->pins_default);
	}

	host->pins_uhs = pinctrl_lookup_state(host->pinctrl, "state_uhs");
	if (IS_ERR(host->pins_uhs)) {
		ret = PTR_ERR(host->pins_uhs);
		dev_err(&pdev->dev, "Cannot find pinctrl uhs!\n");
		goto host_free;
		return PTR_ERR(host->pins_uhs);
	}

	/* Support for SDIO eint irq ? */
@@ -2920,14 +2910,14 @@ static int msdc_drv_probe(struct platform_device *pdev)
					     GFP_KERNEL);
		if (!host->cq_host) {
			ret = -ENOMEM;
			goto host_free;
			goto release_mem;
		}
		host->cq_host->caps |= CQHCI_TASK_DESC_SZ_128;
		host->cq_host->mmio = host->base + 0x800;
		host->cq_host->ops = &msdc_cmdq_ops;
		ret = cqhci_init(host->cq_host, mmc, true);
		if (ret)
			goto host_free;
			goto release_mem;
		mmc->max_segs = 128;
		/* cqhci 16bit length */
		/* 0 size, means 65536 so we don't have to -1 here */
@@ -2979,9 +2969,6 @@ static int msdc_drv_probe(struct platform_device *pdev)
		dma_free_coherent(&pdev->dev,
				  MAX_BD_NUM * sizeof(struct mt_bdma_desc),
				  host->dma.bd, host->dma.bd_addr);
host_free:
	mmc_free_host(mmc);

	return ret;
}

@@ -3007,8 +2994,6 @@ static void msdc_drv_remove(struct platform_device *pdev)
			host->dma.gpd, host->dma.gpd_addr);
	dma_free_coherent(&pdev->dev, MAX_BD_NUM * sizeof(struct mt_bdma_desc),
			  host->dma.bd, host->dma.bd_addr);

	mmc_free_host(mmc);
}

static void msdc_save_reg(struct msdc_host *host)