All of lore.kernel.org
 help / color / mirror / Atom feed
* sdhci: Best Practice Question
@ 2010-09-25 20:08 Philip Rakity
  2010-09-26  0:43 ` [PATCH] sdhci: sepearate get_ro into code that calls platform and helper Philip Rakity
  2010-09-26 16:40 ` sdhci: Best Practice Question Chris Ball
  0 siblings, 2 replies; 5+ messages in thread
From: Philip Rakity @ 2010-09-25 20:08 UTC (permalink / raw)
  To: linux-mmc@vger.kernel.org

and a 
host->ops-> get_max_clock()
function that is used to set the max clock.  The code snippet is below


	host->max_clk =
		(caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT;
	host->max_clk *= 1000000;
	if (host->max_clk == 0 || host->quirks &
			SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN) {
		if (!host->ops->get_max_clock) {
			printk(KERN_ERR
			       "%s: Hardware doesn't specify base clock "
			       "frequency.\n", mmc_hostname(mmc));
			return -ENODEV;
		}
		host->max_clk = host->ops->get_max_clock(host);
	}


The quirk seems redundant since this could be coded as follows to remove the need for the quirk

> +	if (host->ops->get_max_clock)
> 		host->max_clk = host->ops->get_max_clock(host);
> +	else {
> +		host->max_clk =
> +			(caps & SDHCI_CLOCK_BASE_MASK) 
> +				>> SDHCI_CLOCK_BASE_SHIFT;
> +		host->max_clk *= 1000000;
> +	}
> +
> +	if (host->max_clk == 0) {
> +		printk(KERN_ERR
> +		       "%s: Hardware doesn't specify base clock "
> +		       "frequency.\n", mmc_hostname(mmc));
> +		return -ENODEV;
> 	}
> 


This approach was not used since it was felt a quirk was needed.

http://kerneltrap.org/mailarchive/linux-kernel/2010/2/19/4540115

but the quirk redundant and it requires two items be set; the quirk and the callback.
Defining the quirk and not the callback is meaningless.  

The change proposed by Richard Zhu for handling write protect uses only a callback.

<snip>
static int sdhci_get_ro(struct mmc_host *mmc)
{
	struct sdhci_host *host;
	unsigned long flags;
	int present;

	host = mmc_priv(mmc);

	if (host->ops->get_ro)
		return host->ops->get_ro(host);

	spin_lock_irqsave(&host->lock, flags);

<end snip>

What is the correct practice?  

Philip

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-09-26 16:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-25 20:08 sdhci: Best Practice Question Philip Rakity
2010-09-26  0:43 ` [PATCH] sdhci: sepearate get_ro into code that calls platform and helper Philip Rakity
2010-09-26  0:44   ` [PATCH] sdhci: seperate out reset so if platform specific helper exists it is called Philip Rakity
2010-09-26 16:45     ` [RFC] sdhci: SDHCI_QUIRK_BROKEN_CARD_DETECTION Philip Rakity
2010-09-26 16:40 ` sdhci: Best Practice Question Chris Ball

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.