Skip to contentSkip to conversation

mmc: dw_mmc: replace the bus_hz checking point

PATCH Superseded Jaehoon Chung 2 participants 3 messages Jan 28, 2014

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jaehoon Chung

author maintainer
#0 lore raw

PATCH v2 3/8 mmc: dw_mmc: replace the bus_hz checking point

It's right that check immediately whether host->bus_hz is assigned or not. If drv_data->setup_clock is presented, then host->bus_hz should be set at there. When setup_clock didn't present, assigned to value with clk_get_rate().

---
Changelog V2:
- When drv_data->setup_clock is present, set to bus_hz with it.

 drivers/mmc/host/dw_mmc.c |   39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)
drivers/mmc/host/dw_mmc.c +19 -20
index 8193e21..ead2998 100644
@@ -2427,10 +2427,27 @@ int dw_mci_probe(struct dw_mci *host)
 			ret = clk_set_rate(host->ciu_clk, host->pdata->bus_hz);
 			if (ret)
 				dev_warn(host->dev,
-					 "Unable to set bus rate to %ul\n",
+					 "Unable to set bus rate to %uHz\n",
 					 host->pdata->bus_hz);
 		}
-		host->bus_hz = clk_get_rate(host->ciu_clk);
+
+		if (drv_data && drv_data->setup_clock) {
+			ret = drv_data->setup_clock(host);
+			if (ret) {
+				dev_err(host->dev, "implementation specific \"
+					"clock setup failed\n");
+				goto err_clk_ciu;
+			}
+		} else {
+			host->bus_hz = clk_get_rate(host->ciu_clk);
+		}
+	}
+
+	if (!host->bus_hz) {
+		dev_err(host->dev,
+			"Platform data must supply bus speed\n");
+		ret = -ENODEV;
+		goto err_clk_ciu;
 	}
 
 	if (drv_data && drv_data->init) {
@@ -2442,15 +2459,6 @@ int dw_mci_probe(struct dw_mci *host)
 		}
 	}
 
-	if (drv_data && drv_data->setup_clock) {
-		ret = drv_data->setup_clock(host);
-		if (ret) {
-			dev_err(host->dev,
-				"implementation specific clock setup failed\n");
-			goto err_clk_ciu;
-		}
-	}
-
 	host->vmmc = devm_regulator_get_optional(host->dev, "vmmc");
 	if (IS_ERR(host->vmmc)) {
 		ret = PTR_ERR(host->vmmc);
@@ -2469,13 +2477,6 @@ int dw_mci_probe(struct dw_mci *host)
 		}
 	}
 
-	if (!host->bus_hz) {
-		dev_err(host->dev,
-			"Platform data must supply bus speed\n");
-		ret = -ENODEV;
-		goto err_regulator;
-	}
-
 	host->quirks = host->pdata->quirks;
 
 	spin_lock_init(&host->lock);
@@ -2619,8 +2620,6 @@ err_workqueue:
 err_dmaunmap:
 	if (host->use_dma && host->dma_ops->exit)
 		host->dma_ops->exit(host);
-
-err_regulator:
 	if (host->vmmc)
 		regulator_disable(host->vmmc);
 
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 25 lines · Jaehoon Chung

It's right that check immediately whether host->bus_hz is assigned or not. If drv_data->setup_clock is presented, then host->bus_hz should be set at there. When setup_clock didn't present, assigned to value with clk_get_rate().

---
Changelog V2:
- When drv_data->setup_clock is present, set to bus_hz with it.

 drivers/mmc/host/dw_mmc.c |   39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)
drivers/mmc/host/dw_mmc.c +1 -2
index 8193e21..ead2998 100644
@@ -2427,10 +2427,27 @@ int dw_mci_probe(struct dw_mci *host)
 			ret = clk_set_rate(host->ciu_clk, host->pdata->bus_hz);
 			if (ret)
 				dev_warn(host->dev,
-					 "Unable to set bus rate to %ul\n",
+					 "Unable to set bus rate to %uHz\n",
 					 host->pdata->bus_hz);
 		}
-		host->bus_hz = clk_get_rate(host->ciu_clk);

drivers/mmc/host/dw_mmc.c int dw_mci_probe(struct dw_mci *host) · line 2442

Quoted 10 lines
drivers/mmc/host/dw_mmc.c +10 -0
+
+		if (drv_data && drv_data->setup_clock) {
+			ret = drv_data->setup_clock(host);
+			if (ret) {
+				dev_err(host->dev, "implementation specific \"
+					"clock setup failed\n");
+				goto err_clk_ciu;
+			}
+		} else {
+			host->bus_hz = clk_get_rate(host->ciu_clk);

host->bus_hz certainly should be touched at drv_data->setup_clock()? I think origin would be better.
The others is good to me.

Thanks,
Seungwon Jeon

Quoted 56 lines
drivers/mmc/host/dw_mmc.c +8 -19
+		}
+	}
+
+	if (!host->bus_hz) {
+		dev_err(host->dev,
+			"Platform data must supply bus speed\n");
+		ret = -ENODEV;
+		goto err_clk_ciu;
 	}
 
 	if (drv_data && drv_data->init) {
@@ -2442,15 +2459,6 @@ int dw_mci_probe(struct dw_mci *host)
 		}
 	}
 
-	if (drv_data && drv_data->setup_clock) {
-		ret = drv_data->setup_clock(host);
-		if (ret) {
-			dev_err(host->dev,
-				"implementation specific clock setup failed\n");
-			goto err_clk_ciu;
-		}
-	}
-
 	host->vmmc = devm_regulator_get_optional(host->dev, "vmmc");
 	if (IS_ERR(host->vmmc)) {
 		ret = PTR_ERR(host->vmmc);
@@ -2469,13 +2477,6 @@ int dw_mci_probe(struct dw_mci *host)
 		}
 	}
 
-	if (!host->bus_hz) {
-		dev_err(host->dev,
-			"Platform data must supply bus speed\n");
-		ret = -ENODEV;
-		goto err_regulator;
-	}
-
 	host->quirks = host->pdata->quirks;
 
 	spin_lock_init(&host->lock);
@@ -2619,8 +2620,6 @@ err_workqueue:
 err_dmaunmap:
 	if (host->use_dma && host->dma_ops->exit)
 		host->dma_ops->exit(host);
-
-err_regulator:
 	if (host->vmmc)
 		regulator_disable(host->vmmc);
 
--

1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#2 lore raw

Hi Seungwon,

Thanks for review.

Quoted 31 lines · Seungwon Jeon
Quoted 30 lines · Jaehoon Chung

It's right that check immediately whether host->bus_hz is assigned or not. If drv_data->setup_clock is presented, then host->bus_hz should be set at there. When setup_clock didn't present, assigned to value with clk_get_rate().

---
Changelog V2:
- When drv_data->setup_clock is present, set to bus_hz with it.

 drivers/mmc/host/dw_mmc.c |   39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)
drivers/mmc/host/dw_mmc.c +6 -2
index 8193e21..ead2998 100644
@@ -2427,10 +2427,27 @@ int dw_mci_probe(struct dw_mci *host)
 			ret = clk_set_rate(host->ciu_clk, host->pdata->bus_hz);
 			if (ret)
 				dev_warn(host->dev,
-					 "Unable to set bus rate to %ul\n",
+					 "Unable to set bus rate to %uHz\n",
 					 host->pdata->bus_hz);
 		}
-		host->bus_hz = clk_get_rate(host->ciu_clk);
+
+		if (drv_data && drv_data->setup_clock) {
+			ret = drv_data->setup_clock(host);
+			if (ret) {
+				dev_err(host->dev, "implementation specific \"
Quoted 8 lines

drivers/mmc/host/dw_mmc.c int dw_mci_probe(struct dw_mci *host) · line 2442

Quoted 5 lines
drivers/mmc/host/dw_mmc.c +5 -0
+					"clock setup failed\n");
+				goto err_clk_ciu;
+			}
+		} else {
+			host->bus_hz = clk_get_rate(host->ciu_clk);

host->bus_hz certainly should be touched at drv_data->setup_clock()? I think origin would be better.
The others is good to me.

I understood what you mean. Maybe We can change the code at dw_mmc-exynos.c. It's refered to host->ci_clk at dw_mmc-exynos.c.
But If ciu_clk didn't assign, clk's rate didn't get.
How about this? host->bus_hz was already assigned in dw_mmc.c.

drivers/mmc/host/dw_mmc-exynos.c +1 -2
@@ -117,9 +117,8 @@ static int dw_mci_exynos_priv_init(struct dw_mci *host)
 static int dw_mci_exynos_setup_clock(struct dw_mci *host)
 {
 	struct dw_mci_exynos_priv_data *priv = host->priv;
-	unsigned long rate = clk_get_rate(host->ciu_clk);
 
-	host->bus_hz = rate / (priv->ciu_div + 1);
+	host->bus_hz /= (priv->ciu_div + 1);
 	return 0;
 }
 

Best Regards,
Jaehoon Chung

Quoted 62 lines

Thanks,
Seungwon Jeon

Quoted 56 lines
drivers/mmc/host/dw_mmc.c +8 -19
+		}
+	}
+
+	if (!host->bus_hz) {
+		dev_err(host->dev,
+			"Platform data must supply bus speed\n");
+		ret = -ENODEV;
+		goto err_clk_ciu;
 	}
 
 	if (drv_data && drv_data->init) {
@@ -2442,15 +2459,6 @@ int dw_mci_probe(struct dw_mci *host)
 		}
 	}
 
-	if (drv_data && drv_data->setup_clock) {
-		ret = drv_data->setup_clock(host);
-		if (ret) {
-			dev_err(host->dev,
-				"implementation specific clock setup failed\n");
-			goto err_clk_ciu;
-		}
-	}
-
 	host->vmmc = devm_regulator_get_optional(host->dev, "vmmc");
 	if (IS_ERR(host->vmmc)) {
 		ret = PTR_ERR(host->vmmc);
@@ -2469,13 +2477,6 @@ int dw_mci_probe(struct dw_mci *host)
 		}
 	}
 
-	if (!host->bus_hz) {
-		dev_err(host->dev,
-			"Platform data must supply bus speed\n");
-		ret = -ENODEV;
-		goto err_regulator;
-	}
-
 	host->quirks = host->pdata->quirks;
 
 	spin_lock_init(&host->lock);
@@ -2619,8 +2620,6 @@ err_workqueue:
 err_dmaunmap:
 	if (host->use_dma && host->dma_ops->exit)
 		host->dma_ops->exit(host);
-
-err_regulator:
 	if (host->vmmc)
 		regulator_disable(host->vmmc);
 
--

1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html