mmc: meson-gx: use devm_mmc_alloc_host
Use new function devm_mmc_alloc_host() to simplify the code. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Link: https://lore.kernel.org/r/728f159b-885f-c78a-1a3d-f55c245250e1@gmail.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
This commit is contained in:
parent
80df83c2c5
commit
418f7c2de1
@ -1179,7 +1179,7 @@ static int meson_mmc_probe(struct platform_device *pdev)
|
|||||||
struct mmc_host *mmc;
|
struct mmc_host *mmc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mmc = mmc_alloc_host(sizeof(struct meson_host), &pdev->dev);
|
mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(struct meson_host));
|
||||||
if (!mmc)
|
if (!mmc)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
host = mmc_priv(mmc);
|
host = mmc_priv(mmc);
|
||||||
@ -1195,46 +1195,33 @@ static int meson_mmc_probe(struct platform_device *pdev)
|
|||||||
host->vqmmc_enabled = false;
|
host->vqmmc_enabled = false;
|
||||||
ret = mmc_regulator_get_supply(mmc);
|
ret = mmc_regulator_get_supply(mmc);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto free_host;
|
return ret;
|
||||||
|
|
||||||
ret = mmc_of_parse(mmc);
|
ret = mmc_of_parse(mmc);
|
||||||
if (ret) {
|
if (ret)
|
||||||
if (ret != -EPROBE_DEFER)
|
return dev_err_probe(&pdev->dev, ret, "error parsing DT\n");
|
||||||
dev_warn(&pdev->dev, "error parsing DT: %d\n", ret);
|
|
||||||
goto free_host;
|
|
||||||
}
|
|
||||||
|
|
||||||
host->data = (struct meson_mmc_data *)
|
host->data = (struct meson_mmc_data *)
|
||||||
of_device_get_match_data(&pdev->dev);
|
of_device_get_match_data(&pdev->dev);
|
||||||
if (!host->data) {
|
if (!host->data)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto free_host;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = device_reset_optional(&pdev->dev);
|
ret = device_reset_optional(&pdev->dev);
|
||||||
if (ret) {
|
if (ret)
|
||||||
dev_err_probe(&pdev->dev, ret, "device reset failed\n");
|
return dev_err_probe(&pdev->dev, ret, "device reset failed\n");
|
||||||
goto free_host;
|
|
||||||
}
|
|
||||||
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
host->regs = devm_ioremap_resource(&pdev->dev, res);
|
host->regs = devm_ioremap_resource(&pdev->dev, res);
|
||||||
if (IS_ERR(host->regs)) {
|
if (IS_ERR(host->regs))
|
||||||
ret = PTR_ERR(host->regs);
|
return PTR_ERR(host->regs);
|
||||||
goto free_host;
|
|
||||||
}
|
|
||||||
|
|
||||||
host->irq = platform_get_irq(pdev, 0);
|
host->irq = platform_get_irq(pdev, 0);
|
||||||
if (host->irq <= 0) {
|
if (host->irq <= 0)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto free_host;
|
|
||||||
}
|
|
||||||
|
|
||||||
host->pinctrl = devm_pinctrl_get(&pdev->dev);
|
host->pinctrl = devm_pinctrl_get(&pdev->dev);
|
||||||
if (IS_ERR(host->pinctrl)) {
|
if (IS_ERR(host->pinctrl))
|
||||||
ret = PTR_ERR(host->pinctrl);
|
return PTR_ERR(host->pinctrl);
|
||||||
goto free_host;
|
|
||||||
}
|
|
||||||
|
|
||||||
host->pins_clk_gate = pinctrl_lookup_state(host->pinctrl,
|
host->pins_clk_gate = pinctrl_lookup_state(host->pinctrl,
|
||||||
"clk-gate");
|
"clk-gate");
|
||||||
@ -1245,14 +1232,12 @@ static int meson_mmc_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
host->core_clk = devm_clk_get(&pdev->dev, "core");
|
host->core_clk = devm_clk_get(&pdev->dev, "core");
|
||||||
if (IS_ERR(host->core_clk)) {
|
if (IS_ERR(host->core_clk))
|
||||||
ret = PTR_ERR(host->core_clk);
|
return PTR_ERR(host->core_clk);
|
||||||
goto free_host;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = clk_prepare_enable(host->core_clk);
|
ret = clk_prepare_enable(host->core_clk);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto free_host;
|
return ret;
|
||||||
|
|
||||||
ret = meson_mmc_clk_init(host);
|
ret = meson_mmc_clk_init(host);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -1347,8 +1332,6 @@ err_init_clk:
|
|||||||
clk_disable_unprepare(host->mmc_clk);
|
clk_disable_unprepare(host->mmc_clk);
|
||||||
err_core_clk:
|
err_core_clk:
|
||||||
clk_disable_unprepare(host->core_clk);
|
clk_disable_unprepare(host->core_clk);
|
||||||
free_host:
|
|
||||||
mmc_free_host(mmc);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1365,7 +1348,6 @@ static int meson_mmc_remove(struct platform_device *pdev)
|
|||||||
clk_disable_unprepare(host->mmc_clk);
|
clk_disable_unprepare(host->mmc_clk);
|
||||||
clk_disable_unprepare(host->core_clk);
|
clk_disable_unprepare(host->core_clk);
|
||||||
|
|
||||||
mmc_free_host(host->mmc);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user