public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sdhci: Be more strict with get_min_clock() usage
       [not found] ` <20090801100443.7a5c2f86@mjolnir.ossman.eu>
@ 2009-08-04 17:20   ` Anton Vorontsov
  0 siblings, 0 replies; only message in thread
From: Anton Vorontsov @ 2009-08-04 17:20 UTC (permalink / raw)
  To: Pierre Ossman
  Cc: akpm, drzeus, ian, matt, roberto.foglietta, linux-kernel,
	sdhci-devel

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().

Suggested-by: Pierre Ossman <pierre@ossman.eu>
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---

On Sat, Aug 01, 2009 at 10:04:43AM +0200, Pierre Ossman wrote:
[...]
> 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.
[...]
> > -	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(-)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index fc96f8c..7f7f45b 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -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;
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-08-04 17:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200907292204.n6TM4GGQ019192@imap1.linux-foundation.org>
     [not found] ` <20090801100443.7a5c2f86@mjolnir.ossman.eu>
2009-08-04 17:20   ` [PATCH] sdhci: Be more strict with get_min_clock() usage Anton Vorontsov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox