aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mmc/host/sunxi-mmc.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
index 3601746d37a9..b747d65a7d15 100644
--- a/drivers/mmc/host/sunxi-mmc.c
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -1170,10 +1170,19 @@ static int sunxi_mmc_enable(struct sunxi_mmc_host *host)
1170{ 1170{
1171 int ret; 1171 int ret;
1172 1172
1173 if (!IS_ERR(host->reset)) {
1174 ret = reset_control_reset(host->reset);
1175 if (ret) {
1176 dev_err(host->dev, "Couldn't reset the MMC controller (%d)\n",
1177 ret);
1178 return ret;
1179 }
1180 }
1181
1173 ret = clk_prepare_enable(host->clk_ahb); 1182 ret = clk_prepare_enable(host->clk_ahb);
1174 if (ret) { 1183 if (ret) {
1175 dev_err(dev, "Couldn't enable the bus clocks (%d)\n", ret); 1184 dev_err(host->dev, "Couldn't enable the bus clocks (%d)\n", ret);
1176 return ret; 1185 goto error_assert_reset;
1177 } 1186 }
1178 1187
1179 ret = clk_prepare_enable(host->clk_mmc); 1188 ret = clk_prepare_enable(host->clk_mmc);
@@ -1194,28 +1203,16 @@ static int sunxi_mmc_enable(struct sunxi_mmc_host *host)
1194 goto error_disable_clk_output; 1203 goto error_disable_clk_output;
1195 } 1204 }
1196 1205
1197 if (!IS_ERR(host->reset)) {
1198 ret = reset_control_reset(host->reset);
1199 if (ret) {
1200 dev_err(dev, "Couldn't reset the MMC controller (%d)\n",
1201 ret);
1202 goto error_disable_clk_sample;
1203 }
1204 }
1205
1206 /* 1206 /*
1207 * Sometimes the controller asserts the irq on boot for some reason, 1207 * Sometimes the controller asserts the irq on boot for some reason,
1208 * make sure the controller is in a sane state before enabling irqs. 1208 * make sure the controller is in a sane state before enabling irqs.
1209 */ 1209 */
1210 ret = sunxi_mmc_reset_host(host); 1210 ret = sunxi_mmc_reset_host(host);
1211 if (ret) 1211 if (ret)
1212 goto error_assert_reset; 1212 goto error_disable_clk_sample;
1213 1213
1214 return 0; 1214 return 0;
1215 1215
1216error_assert_reset:
1217 if (!IS_ERR(host->reset))
1218 reset_control_assert(host->reset);
1219error_disable_clk_sample: 1216error_disable_clk_sample:
1220 clk_disable_unprepare(host->clk_sample); 1217 clk_disable_unprepare(host->clk_sample);
1221error_disable_clk_output: 1218error_disable_clk_output:
@@ -1224,6 +1221,9 @@ error_disable_clk_mmc:
1224 clk_disable_unprepare(host->clk_mmc); 1221 clk_disable_unprepare(host->clk_mmc);
1225error_disable_clk_ahb: 1222error_disable_clk_ahb:
1226 clk_disable_unprepare(host->clk_ahb); 1223 clk_disable_unprepare(host->clk_ahb);
1224error_assert_reset:
1225 if (!IS_ERR(host->reset))
1226 reset_control_assert(host->reset);
1227 return ret; 1227 return ret;
1228} 1228}
1229 1229
@@ -1231,13 +1231,13 @@ static void sunxi_mmc_disable(struct sunxi_mmc_host *host)
1231{ 1231{
1232 sunxi_mmc_reset_host(host); 1232 sunxi_mmc_reset_host(host);
1233 1233
1234 if (!IS_ERR(host->reset))
1235 reset_control_assert(host->reset);
1236
1237 clk_disable_unprepare(host->clk_sample); 1234 clk_disable_unprepare(host->clk_sample);
1238 clk_disable_unprepare(host->clk_output); 1235 clk_disable_unprepare(host->clk_output);
1239 clk_disable_unprepare(host->clk_mmc); 1236 clk_disable_unprepare(host->clk_mmc);
1240 clk_disable_unprepare(host->clk_ahb); 1237 clk_disable_unprepare(host->clk_ahb);
1238
1239 if (!IS_ERR(host->reset))
1240 reset_control_assert(host->reset);
1241} 1241}
1242 1242
1243static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host, 1243static int sunxi_mmc_resource_request(struct sunxi_mmc_host *host,