Skip to contentSkip to conversation

sdhci: Be more strict with get_min_clock() usage

PATCH New Anton Vorontsov 1 participant 1 message Aug 4, 2009 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw

PATCH 1/1 sdhci: Be more strict with get_min_clock() usage

get_min_clock() makes sense only with NONSTANDARD_CLOCK quirk and when set_clock() callback is specified.

The patch should cause no functional changes, it just makes the code self-documented and avoids any possible misuse of get_min_clock().

---

On Sat, Aug 01, 2009 at 10:04:43AM +0200, Pierre Ossman wrote:
[...]

Quoted 2 lines

Hmm... I don't think this is quite right. Right now you kill the warning without verifying that there is a mechanism to go lower.

[...]

Quoted 10 lines

Review

Quoted 7 lines
(quoted diff) +4 -1
-	mmc->f_min = host->max_clk / 256;
+	if (host->ops->get_min_clock)
+		mmc->f_min = host->ops->get_min_clock(host);
+	else
+		mmc->f_min = host->max_clk / 256;
 	mmc->f_max = host->max_clk;
 	mmc->caps = MMC_CAP_SDIO_IRQ;

You should be checking ops->set_clock and SDHCI_QUIRK_NONSTANDARD_CLOCK here.

Well, it makes no sense to specify .get_min_clock() w/o .set_clock().

But okay, to make things self documented and to avoid misuses, we'd better add these checks.

Thanks Pierre!

 drivers/mmc/host/sdhci.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci.c +2 -1
index fc96f8c..7f7f45b 100644
@@ -1772,7 +1772,8 @@ int sdhci_add_host(struct sdhci_host *host)
 	 * Set host parameters.
 	 */
 	mmc->ops = &sdhci_ops;
-	if (host->ops->get_min_clock)
+	if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK &&
+			host->ops->set_clock && host->ops->get_min_clock)
 		mmc->f_min = host->ops->get_min_clock(host);
 	else
 		mmc->f_min = host->max_clk / 256;
Signature · 1 line
1.6.3.3