Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: mxcmmc: Use devm_mmc_alloc_host() helper

Use new function devm_mmc_alloc_host() to simplify the code.

Cc: Shawn Guo <shawnguo@kernel.org>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn>
Link: https://lore.kernel.org/r/eb21038ebc81bd0ba9dab4843dce57e4f431fac0.1748933789.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Binbin Zhou and committed by
Ulf Hansson
c6aa07ac 2a52d0c7

+10 -21
+10 -21
drivers/mmc/host/mxcmmc.c
··· 1005 1005 if (irq < 0) 1006 1006 return irq; 1007 1007 1008 - mmc = mmc_alloc_host(sizeof(*host), &pdev->dev); 1008 + mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(*host)); 1009 1009 if (!mmc) 1010 1010 return -ENOMEM; 1011 1011 1012 1012 host = mmc_priv(mmc); 1013 1013 1014 1014 host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 1015 - if (IS_ERR(host->base)) { 1016 - ret = PTR_ERR(host->base); 1017 - goto out_free; 1018 - } 1015 + if (IS_ERR(host->base)) 1016 + return PTR_ERR(host->base); 1019 1017 1020 1018 host->phys_base = res->start; 1021 1019 1022 1020 ret = mmc_of_parse(mmc); 1023 1021 if (ret) 1024 - goto out_free; 1022 + return ret; 1025 1023 mmc->ops = &mxcmci_ops; 1026 1024 1027 1025 /* For devicetree parsing, the bus width is read from devicetree */ ··· 1052 1054 1053 1055 ret = mmc_regulator_get_supply(mmc); 1054 1056 if (ret) 1055 - goto out_free; 1057 + return ret; 1056 1058 1057 1059 if (!mmc->ocr_avail) { 1058 1060 if (pdata && pdata->ocr_avail) ··· 1068 1070 host->default_irq_mask = 0; 1069 1071 1070 1072 host->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); 1071 - if (IS_ERR(host->clk_ipg)) { 1072 - ret = PTR_ERR(host->clk_ipg); 1073 - goto out_free; 1074 - } 1073 + if (IS_ERR(host->clk_ipg)) 1074 + return PTR_ERR(host->clk_ipg); 1075 1075 1076 1076 host->clk_per = devm_clk_get(&pdev->dev, "per"); 1077 - if (IS_ERR(host->clk_per)) { 1078 - ret = PTR_ERR(host->clk_per); 1079 - goto out_free; 1080 - } 1077 + if (IS_ERR(host->clk_per)) 1078 + return PTR_ERR(host->clk_per); 1081 1079 1082 1080 ret = clk_prepare_enable(host->clk_per); 1083 1081 if (ret) 1084 - goto out_free; 1082 + return ret; 1085 1083 1086 1084 ret = clk_prepare_enable(host->clk_ipg); 1087 1085 if (ret) ··· 1163 1169 out_clk_per_put: 1164 1170 clk_disable_unprepare(host->clk_per); 1165 1171 1166 - out_free: 1167 - mmc_free_host(mmc); 1168 - 1169 1172 return ret; 1170 1173 } 1171 1174 ··· 1181 1190 1182 1191 clk_disable_unprepare(host->clk_per); 1183 1192 clk_disable_unprepare(host->clk_ipg); 1184 - 1185 - mmc_free_host(mmc); 1186 1193 } 1187 1194 1188 1195 static int mxcmci_suspend(struct device *dev)