Merge "Revert "msm: dma: Use clk_prepare and clk_unprepare"" into msm-3.0
diff --git a/arch/arm/mach-msm/dma.c b/arch/arm/mach-msm/dma.c
index d433b9e..cee6b17 100644
--- a/arch/arm/mach-msm/dma.c
+++ b/arch/arm/mach-msm/dma.c
@@ -73,6 +73,7 @@
};
static void msm_dmov_clock_work(struct work_struct *);
+static int msm_dmov_clk_toggle(int, int);
#ifdef CONFIG_ARCH_MSM8X60
@@ -230,40 +231,40 @@
#define PRINT_FLOW(format, args...) \
MSM_DMOV_DPRINTF(MSM_DMOV_PRINT_FLOW, format, args);
-static int msm_dmov_clk_on(int adm)
+static int msm_dmov_clk_toggle(int adm, int on)
{
- int ret;
+ int ret = 0;
- ret = clk_prepare_enable(dmov_conf[adm].clk);
- if (ret)
- return ret;
- if (dmov_conf[adm].pclk) {
- ret = clk_prepare_enable(dmov_conf[adm].pclk);
- if (ret) {
- clk_disable_unprepare(dmov_conf[adm].clk);
- return ret;
+ if (on) {
+ ret = clk_enable(dmov_conf[adm].clk);
+ if (ret)
+ goto err;
+ if (dmov_conf[adm].pclk) {
+ ret = clk_enable(dmov_conf[adm].pclk);
+ if (ret) {
+ clk_disable(dmov_conf[adm].clk);
+ goto err;
+ }
}
- }
- if (dmov_conf[adm].ebiclk) {
- ret = clk_prepare_enable(dmov_conf[adm].ebiclk);
- if (ret) {
- if (dmov_conf[adm].pclk)
- clk_disable_unprepare(dmov_conf[adm].pclk);
- clk_disable_unprepare(dmov_conf[adm].clk);
+ if (dmov_conf[adm].ebiclk) {
+ ret = clk_enable(dmov_conf[adm].ebiclk);
+ if (ret) {
+ if (dmov_conf[adm].pclk)
+ clk_disable(dmov_conf[adm].pclk);
+ clk_disable(dmov_conf[adm].clk);
+ }
}
+ } else {
+ clk_disable(dmov_conf[adm].clk);
+ if (dmov_conf[adm].pclk)
+ clk_disable(dmov_conf[adm].pclk);
+ if (dmov_conf[adm].ebiclk)
+ clk_disable(dmov_conf[adm].ebiclk);
}
+err:
return ret;
}
-static void msm_dmov_clk_off(int adm)
-{
- clk_disable_unprepare(dmov_conf[adm].clk);
- if (dmov_conf[adm].pclk)
- clk_disable_unprepare(dmov_conf[adm].pclk);
- if (dmov_conf[adm].ebiclk)
- clk_disable_unprepare(dmov_conf[adm].ebiclk);
-}
-
static void msm_dmov_clock_work(struct work_struct *work)
{
struct msm_dmov_conf *conf =
@@ -272,7 +273,7 @@
mutex_lock(&conf->lock);
if (conf->clk_ctl == CLK_TO_BE_DIS) {
BUG_ON(conf->channel_active);
- msm_dmov_clk_off(adm);
+ msm_dmov_clk_toggle(adm, 0);
conf->clk_ctl = CLK_DIS;
}
mutex_unlock(&conf->lock);
@@ -319,7 +320,7 @@
mutex_lock(&dmov_conf[adm].lock);
if (dmov_conf[adm].clk_ctl == CLK_DIS) {
- status = msm_dmov_clk_on(adm);
+ status = msm_dmov_clk_toggle(adm, 1);
if (status != 0)
goto error;
} else if (dmov_conf[adm].clk_ctl == CLK_TO_BE_DIS)
@@ -582,7 +583,7 @@
if (dmov_conf[adm].clk_ctl == CLK_TO_BE_DIS) {
BUG_ON(dmov_conf[adm].channel_active);
cancel_delayed_work_sync(&dmov_conf[adm].work);
- msm_dmov_clk_off(adm);
+ msm_dmov_clk_toggle(adm, 0);
dmov_conf[adm].clk_ctl = CLK_DIS;
}
mutex_unlock(&dmov_conf[adm].lock);
@@ -713,7 +714,7 @@
PRINT_ERROR("Requesting ADM%d clocks failed\n", adm);
goto out_irq;
}
- ret = msm_dmov_clk_on(adm);
+ ret = msm_dmov_clk_toggle(adm, 1);
if (ret) {
PRINT_ERROR("Enabling ADM%d clocks failed\n", adm);
goto out_irq;
@@ -730,7 +731,7 @@
DMOV_REG(DMOV_RSLT_CONF(i), adm));
}
wmb();
- msm_dmov_clk_off(adm);
+ msm_dmov_clk_toggle(adm, 0);
return ret;
out_irq:
free_irq(dmov_conf[adm].irq, NULL);