linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: akpm@linux-foundation.org (Andrew Morton)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/3] sdhci-s3c: add support for new card detection methods
Date: Fri, 9 Jul 2010 14:24:40 -0700	[thread overview]
Message-ID: <20100709142440.3ce31714.akpm@linux-foundation.org> (raw)
In-Reply-To: <1276670996-17729-4-git-send-email-m.szyprowski@samsung.com>

On Wed, 16 Jun 2010 08:49:56 +0200
Marek Szyprowski <m.szyprowski@samsung.com> wrote:

> On some Samsung SoCs not all SDHCI controllers have card detect (CD)
> line. For some embedded designs it is not even needed, because ususally
> the device (like SDIO flash memory or wifi controller) is permanently
> wired to the controller. There are also systems which have a card detect
> line connected to some of the external interrupt lines or the presence
> of the card depends on some other actions (like enabling a power
> regulator).
> 
> This patch adds support for all these cases. The following card
> detection methods are possible:
> 
> 1. internal sdhci host card detect line
> 2. external event
> 3. external gpio interrupt
> 4. no card detect line, controller will poll for the card
> 5. no card detect line, card is permanently wired to the controller
> (once detected host won't poll it any more)
> 
> By default, all existing code would use method #1, what is compatible
> with the previous version of the driver.
> 
> In case of external event, two callbacks must be provided in platdata:
> ext_cd_init and ext_cd_cleanup. Both of them get a callback to a
> function that notifies the s3c-sdhci host contoller as their argument.
> That callback function should be called from the even dispatcher to let
> host notice the card insertion/removal.
> 
> In case of external gpio interrupt, a gpio pin number must be provided
> in platdata (ext_cd_gpio parameter), as well as the information about
> the polarity of that gpio pin (ext_cd_gpio_invert). By default
> (ext_cd_gpio_invert == 0) gpio value 0 means 'card has been removed',
> but this can be changed to 'card has been removed' when
> ext_cd_gpio_invert == 1.
> 
> This patch adds changes to sdhci-s3c driver.
> 
> ...
>  
> +static void sdhci_s3c_notify_change(struct platform_device *dev, int state)
> +{
> +	struct sdhci_host *host;
> +	unsigned long flags;
> +
> +	local_irq_save(flags);
> +	host = platform_get_drvdata(dev);
> +	if (host) {
> +		if (state) {
> +			dev_dbg(&dev->dev, "card inserted.\n");
> +			host->flags &= ~SDHCI_DEVICE_DEAD;
> +			host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
> +			tasklet_schedule(&host->card_tasklet);
> +		} else {
> +			dev_dbg(&dev->dev, "card removed.\n");
> +			host->flags |= SDHCI_DEVICE_DEAD;
> +			host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
> +			tasklet_schedule(&host->card_tasklet);
> +		}
> +	}
> +	local_irq_restore(flags);
> +}

What's the local_irq_save() there for?

Presumably it is for local-cpu-only protection of some data.  But which
data is it there to protect?

It doesn't provide protection on SMP systems and if I'm guessing
correctly about why it was added, it would be much better to use
spin_lock_irq[save]() here.  That sets a better example, it means the
code has a hope of working correctly on SMP systems and will devolve to
local_irq_save() on UP kernels anyway.

  reply	other threads:[~2010-07-09 21:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-16  6:49 [PATCH v2] SDHCI-S3C fixes and enhancements (driver specific code) Marek Szyprowski
2010-06-16  6:49 ` [PATCH 1/3] sdhci-s3c: add missing remove function Marek Szyprowski
2010-07-09 21:26   ` Andrew Morton
2010-07-12 11:04     ` Marek Szyprowski
2010-07-12 23:52       ` Andrew Morton
2010-06-16  6:49 ` [PATCH 2/3] sdhci-s3c: add support for the non standard minimal clock value Marek Szyprowski
2010-07-09 21:19   ` Andrew Morton
2010-07-12 10:16     ` Marek Szyprowski
2010-06-16  6:49 ` [PATCH 3/3] sdhci-s3c: add support for new card detection methods Marek Szyprowski
2010-07-09 21:24   ` Andrew Morton [this message]
2010-07-12 11:04     ` Marek Szyprowski
2010-07-12 12:59     ` [PATCH v3] " Marek Szyprowski
2010-07-06  5:29 ` [PATCH v2] SDHCI-S3C fixes and enhancements (driver specific code) Kyungmin Park

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=20100709142440.3ce31714.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --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).