linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/2] MMC removable helper function
@ 2010-09-27  8:42 Matt Fleming
  2010-09-27  8:42 ` [PATCH V2 1/2] mmc: Add helper function to check if a card is removable Matt Fleming
  2010-09-27  8:42 ` [PATCH V2 2/2] mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case Matt Fleming
  0 siblings, 2 replies; 8+ messages in thread
From: Matt Fleming @ 2010-09-27  8:42 UTC (permalink / raw)
  To: Chris Ball
  Cc: Jaehoon Chung, linux-mmc, Kyungmin Park, Marek Szyprowski,
	Andrew Morton, Ben Hutchings, Yunpeng Gao, zhangfei gao

Chris, I've rebased this mmc_assume_removable patch series against
mmc-next and fixed up the compilation breakage with allmodconfig.

Note, I've left your Signed-off-by on Jaehoon's patch because you
modified the patch slightly (and because it's going through your tree
anyway). I hope that's OK.

Jaehoon Chung (1):
  mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case

Matt Fleming (1):
  mmc: Add helper function to check if a card is removable

 drivers/mmc/core/core.c  |    1 +
 drivers/mmc/core/core.h  |    1 -
 drivers/mmc/core/mmc.c   |    2 +-
 drivers/mmc/core/sd.c    |    2 +-
 drivers/mmc/host/sdhci.c |    3 ++-
 include/linux/mmc/host.h |    8 ++++++++
 6 files changed, 13 insertions(+), 4 deletions(-)

-- 
1.7.2.1


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

* [PATCH V2 1/2] mmc: Add helper function to check if a card is removable
  2010-09-27  8:42 [PATCH V2 0/2] MMC removable helper function Matt Fleming
@ 2010-09-27  8:42 ` Matt Fleming
  2010-09-27 10:23   ` Wolfram Sang
  2010-09-27 15:01   ` Chris Ball
  2010-09-27  8:42 ` [PATCH V2 2/2] mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case Matt Fleming
  1 sibling, 2 replies; 8+ messages in thread
From: Matt Fleming @ 2010-09-27  8:42 UTC (permalink / raw)
  To: Chris Ball
  Cc: Jaehoon Chung, linux-mmc, Kyungmin Park, Marek Szyprowski,
	Andrew Morton, Ben Hutchings, Yunpeng Gao, zhangfei gao

There are two checks that need to be made when determining whether a
card is removable. A host controller may set MMC_CAP_NONREMOVABLE if the
controller does not support removing cards (e.g. eMMC), in which case
the card is physically non-removable. Also the 'mmc_assume_removable'
module parameter can be configured at module load time, in which case
the card may be logically non-removable.

A helper function keeps the logic in one place so that code always
checks both conditions.

Because this new function is likely to be called from modules we now
need to export the mmc_assume_removable symbol.

Signed-off-by: Matt Fleming <matt@console-pimps.org>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
---
 drivers/mmc/core/core.c  |    1 +
 drivers/mmc/core/core.h  |    1 -
 drivers/mmc/core/mmc.c   |    2 +-
 drivers/mmc/core/sd.c    |    2 +-
 include/linux/mmc/host.h |    8 ++++++++
 5 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index 5db49b1..7c12612 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -58,6 +58,7 @@ int mmc_assume_removable;
 #else
 int mmc_assume_removable = 1;
 #endif
+EXPORT_SYMBOL(mmc_assume_removable);
 module_param_named(removable, mmc_assume_removable, bool, 0644);
 MODULE_PARM_DESC(
 	removable,
diff --git a/drivers/mmc/core/core.h b/drivers/mmc/core/core.h
index 9d9eef5..a2ca770 100644
--- a/drivers/mmc/core/core.h
+++ b/drivers/mmc/core/core.h
@@ -58,7 +58,6 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr);
 
 /* Module parameters */
 extern int use_spi_crc;
-extern int mmc_assume_removable;
 
 /* Debugfs information for hosts and cards */
 void mmc_add_host_debugfs(struct mmc_host *host);
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 6909a54..6570c03 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -685,7 +685,7 @@ static void mmc_attach_bus_ops(struct mmc_host *host)
 {
 	const struct mmc_bus_ops *bus_ops;
 
-	if (host->caps & MMC_CAP_NONREMOVABLE || !mmc_assume_removable)
+	if (!mmc_card_is_removable(host))
 		bus_ops = &mmc_ops_unsafe;
 	else
 		bus_ops = &mmc_ops;
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c
index 0f52410..bc745e1 100644
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -750,7 +750,7 @@ static void mmc_sd_attach_bus_ops(struct mmc_host *host)
 {
 	const struct mmc_bus_ops *bus_ops;
 
-	if (host->caps & MMC_CAP_NONREMOVABLE || !mmc_assume_removable)
+	if (!mmc_card_is_removable(host))
 		bus_ops = &mmc_sd_ops_unsafe;
 	else
 		bus_ops = &mmc_sd_ops;
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index ded4017..23a4864 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -267,5 +267,13 @@ static inline void mmc_set_disable_delay(struct mmc_host *host,
 	host->disable_delay = disable_delay;
 }
 
+/* Module parameter */
+extern int mmc_assume_removable;
+
+static inline int mmc_card_is_removable(struct mmc_host *host)
+{
+	return (!(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable);
+}
+
 #endif
 
-- 
1.7.2.1


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

* [PATCH V2 2/2] mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case
  2010-09-27  8:42 [PATCH V2 0/2] MMC removable helper function Matt Fleming
  2010-09-27  8:42 ` [PATCH V2 1/2] mmc: Add helper function to check if a card is removable Matt Fleming
@ 2010-09-27  8:42 ` Matt Fleming
  2010-09-27 10:23   ` Wolfram Sang
  2010-09-27 15:02   ` Chris Ball
  1 sibling, 2 replies; 8+ messages in thread
From: Matt Fleming @ 2010-09-27  8:42 UTC (permalink / raw)
  Cc: Jaehoon Chung, linux-mmc, Kyungmin Park, Marek Szyprowski,
	Andrew Morton, Ben Hutchings, Yunpeng Gao, zhangfei gao,
	Chris Ball

From: Jaehoon Chung <jh80.chung@samsung.com>

When a controller requires SDHCI_QUIRK_BROKEN_CARD_DETECTION, we poll
for card insertion/removal, and that creates interrupts.  There's no
need to be doing this if we have a non-removable card.

This patch requires cards to be removable before we're willing to set
MMC_CAP_NEEDS_POLL.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Matt Fleming <matt@console-pimps.org>
[cjb: modified changelog and code indentation]
Signed-off-by: Chris Ball <cjb@laptop.org>
---
 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 5928b0a..d851315 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1847,7 +1847,8 @@ int sdhci_add_host(struct sdhci_host *host)
 	if (caps & SDHCI_CAN_DO_HISPD)
 		mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
 
-	if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
+	if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
+	    mmc_card_is_removable(mmc))
 		mmc->caps |= MMC_CAP_NEEDS_POLL;
 
 	mmc->ocr_avail = 0;
-- 
1.7.2.1


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

* Re: [PATCH V2 1/2] mmc: Add helper function to check if a card is removable
  2010-09-27  8:42 ` [PATCH V2 1/2] mmc: Add helper function to check if a card is removable Matt Fleming
@ 2010-09-27 10:23   ` Wolfram Sang
  2010-09-27 15:01   ` Chris Ball
  1 sibling, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2010-09-27 10:23 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Chris Ball, Jaehoon Chung, linux-mmc, Kyungmin Park,
	Marek Szyprowski, Andrew Morton, Ben Hutchings, Yunpeng Gao,
	zhangfei gao

[-- Attachment #1: Type: text/plain, Size: 1079 bytes --]

On Mon, Sep 27, 2010 at 09:42:19AM +0100, Matt Fleming wrote:
> There are two checks that need to be made when determining whether a
> card is removable. A host controller may set MMC_CAP_NONREMOVABLE if the
> controller does not support removing cards (e.g. eMMC), in which case
> the card is physically non-removable. Also the 'mmc_assume_removable'
> module parameter can be configured at module load time, in which case
> the card may be logically non-removable.
> 
> A helper function keeps the logic in one place so that code always
> checks both conditions.
> 
> Because this new function is likely to be called from modules we now
> need to export the mmc_assume_removable symbol.
> 
> Signed-off-by: Matt Fleming <matt@console-pimps.org>
> Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
> Tested-by: Jaehoon Chung <jh80.chung@samsung.com>

Acked-by: Wolfram Sang <w.sang@pengutronix.de>

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH V2 2/2] mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case
  2010-09-27  8:42 ` [PATCH V2 2/2] mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case Matt Fleming
@ 2010-09-27 10:23   ` Wolfram Sang
  2010-09-27 15:02   ` Chris Ball
  1 sibling, 0 replies; 8+ messages in thread
From: Wolfram Sang @ 2010-09-27 10:23 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Chris Ball, Jaehoon Chung, linux-mmc, Kyungmin Park,
	Marek Szyprowski, Andrew Morton, Ben Hutchings, Yunpeng Gao,
	zhangfei gao

[-- Attachment #1: Type: text/plain, Size: 890 bytes --]

On Mon, Sep 27, 2010 at 09:42:20AM +0100, Matt Fleming wrote:
> From: Jaehoon Chung <jh80.chung@samsung.com>
> 
> When a controller requires SDHCI_QUIRK_BROKEN_CARD_DETECTION, we poll
> for card insertion/removal, and that creates interrupts.  There's no
> need to be doing this if we have a non-removable card.
> 
> This patch requires cards to be removable before we're willing to set
> MMC_CAP_NEEDS_POLL.
> 
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
> Acked-by: Matt Fleming <matt@console-pimps.org>
> [cjb: modified changelog and code indentation]
> Signed-off-by: Chris Ball <cjb@laptop.org>

Acked-by: Wolfram Sang <w.sang@pengutronix.de>

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH V2 1/2] mmc: Add helper function to check if a card is removable
  2010-09-27  8:42 ` [PATCH V2 1/2] mmc: Add helper function to check if a card is removable Matt Fleming
  2010-09-27 10:23   ` Wolfram Sang
@ 2010-09-27 15:01   ` Chris Ball
  2010-09-27 15:02     ` Matt Fleming
  1 sibling, 1 reply; 8+ messages in thread
From: Chris Ball @ 2010-09-27 15:01 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Jaehoon Chung, linux-mmc, Kyungmin Park, Marek Szyprowski,
	Andrew Morton, Ben Hutchings, Yunpeng Gao, zhangfei gao

Hi Matt,

On Mon, Sep 27, 2010 at 09:42:19AM +0100, Matt Fleming wrote:
> There are two checks that need to be made when determining whether a
> card is removable. A host controller may set MMC_CAP_NONREMOVABLE if the
> controller does not support removing cards (e.g. eMMC), in which case
> the card is physically non-removable. Also the 'mmc_assume_removable'
> module parameter can be configured at module load time, in which case
> the card may be logically non-removable.
> 
> A helper function keeps the logic in one place so that code always
> checks both conditions.
> 
> Because this new function is likely to be called from modules we now
> need to export the mmc_assume_removable symbol.
> 
> Signed-off-by: Matt Fleming <matt@console-pimps.org>
> Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
> Tested-by: Jaehoon Chung <jh80.chung@samsung.com>

Applied to mmc-next with Wolfram's ACK and the following style change,
thanks very much.

diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 23a4864..2e0fe62 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -272,7 +272,7 @@ extern int mmc_assume_removable;
 
 static inline int mmc_card_is_removable(struct mmc_host *host)
 {
-	return (!(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable);
+	return !(host->caps & MMC_CAP_NONREMOVABLE) && mmc_assume_removable;
 }
 
 #endif
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

* Re: [PATCH V2 2/2] mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case
  2010-09-27  8:42 ` [PATCH V2 2/2] mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case Matt Fleming
  2010-09-27 10:23   ` Wolfram Sang
@ 2010-09-27 15:02   ` Chris Ball
  1 sibling, 0 replies; 8+ messages in thread
From: Chris Ball @ 2010-09-27 15:02 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Jaehoon Chung, linux-mmc, Kyungmin Park, Marek Szyprowski,
	Andrew Morton, Ben Hutchings, Yunpeng Gao, zhangfei gao

Hi Matt,

On Mon, Sep 27, 2010 at 09:42:20AM +0100, Matt Fleming wrote:
> From: Jaehoon Chung <jh80.chung@samsung.com>
> 
> When a controller requires SDHCI_QUIRK_BROKEN_CARD_DETECTION, we poll
> for card insertion/removal, and that creates interrupts.  There's no
> need to be doing this if we have a non-removable card.
> 
> This patch requires cards to be removable before we're willing to set
> MMC_CAP_NEEDS_POLL.
> 
> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
> Acked-by: Matt Fleming <matt@console-pimps.org>
> [cjb: modified changelog and code indentation]
> Signed-off-by: Chris Ball <cjb@laptop.org>

Thanks, applied to mmc-next with Wolfram's ACK.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>
One Laptop Per Child

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

* Re: [PATCH V2 1/2] mmc: Add helper function to check if a card is removable
  2010-09-27 15:01   ` Chris Ball
@ 2010-09-27 15:02     ` Matt Fleming
  0 siblings, 0 replies; 8+ messages in thread
From: Matt Fleming @ 2010-09-27 15:02 UTC (permalink / raw)
  To: Chris Ball
  Cc: Jaehoon Chung, linux-mmc, Kyungmin Park, Marek Szyprowski,
	Andrew Morton, Ben Hutchings, Yunpeng Gao, zhangfei gao

On Mon, Sep 27, 2010 at 04:01:32PM +0100, Chris Ball wrote:
> 
> Applied to mmc-next with Wolfram's ACK and the following style change,
> thanks very much.

Thanks Chris!

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

end of thread, other threads:[~2010-09-27 15:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-27  8:42 [PATCH V2 0/2] MMC removable helper function Matt Fleming
2010-09-27  8:42 ` [PATCH V2 1/2] mmc: Add helper function to check if a card is removable Matt Fleming
2010-09-27 10:23   ` Wolfram Sang
2010-09-27 15:01   ` Chris Ball
2010-09-27 15:02     ` Matt Fleming
2010-09-27  8:42 ` [PATCH V2 2/2] mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case Matt Fleming
2010-09-27 10:23   ` Wolfram Sang
2010-09-27 15:02   ` Chris Ball

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