linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/4] mmc: sdhci: add quirk for voltage switch callback
Date: Sun, 13 Jul 2014 09:21:36 +0100	[thread overview]
Message-ID: <20140713082136.GJ21766@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1405228870-5088-2-git-send-email-Vincent.Yang@tw.fujitsu.com>

On Sun, Jul 13, 2014 at 01:21:07PM +0800, Vincent Yang wrote:
> @@ -1763,6 +1763,11 @@ static int sdhci_do_start_signal_voltage_switch(struct sdhci_host *host,
>  		ctrl |= SDHCI_CTRL_VDD_180;
>  		sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
>  
> +		/* Some controller need to do more when switching */
> +		if ((host->quirks2 & SDHCI_QUIRK2_VOLTAGE_SWITCH) &&
> +		    host->ops->voltage_switch)
> +			host->ops->voltage_switch(host);
> +

Why do you heed SDHCI_QUIRK2_VOLTAGE_SWITCH?  Isn't populating
ops->voltage_switch enough? to indicate that something needs to be
done?

It would also be better to turn sdhci.c into a library, and have
the platform driver call the appropriate functions in sdhci rather
than having sdhci be a core driver with loads of quirks.  This is
what I've done in my previous series where I changed stuff such as
the set_bus_width(), set_uhs_signaling() and similar callbacks.

So, it probably makes more sense to split
sdhci_do_start_signal_voltage_switch() into a load of smaller library
functions which drivers can call in an appropriate sequence, rather
than having a quirk hook.

The problem with quirk hooks is that what is right for one device
is not right for another device - eventually you end up with lots
of quirk callbacks scattered on every alternate line.  That doesn't
scale.

Experienced kernel programmers know this and this is why words like
"framework" fill those who have encountered this problem with dread.
sdhci.c is a prime example of this kind of design mistake.

-- 
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up
according to speedtest.net.

  reply	other threads:[~2014-07-13  8:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-13  5:21 [PATCH 0/4] mmc: sdhci: adding support for a new Fujitsu sdhci IP Vincent Yang
2014-07-13  5:21 ` [PATCH 1/4] mmc: sdhci: add quirk for voltage switch callback Vincent Yang
2014-07-13  8:21   ` Russell King - ARM Linux [this message]
2014-07-13  9:44     ` Vincent.Yang
2014-07-13  5:21 ` [PATCH 2/4] mmc: sdhci: add quirk for tuning work around Vincent Yang
2014-07-13  5:21 ` [PATCH 3/4] mmc: sdhci: add quirk for single block transactions Vincent Yang
2014-07-13  5:21 ` [PATCH 4/4] mmc: core: hold SD Clock before CMD11 during Signal Vincent Yang
2014-07-13  8:30   ` Russell King - ARM Linux
2014-07-13  9:49     ` Vincent.Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140713082136.GJ21766@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).