MMC removable helper function
v2 cover MMC removable helper function
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(-)
Signature · 1 line
1.7.2.1
PATCH v2 1/2 mmc: Add helper function to check if a card is removable
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.
--- 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(-)
drivers/mmc/core/core.c +1 -0
@@ -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,
drivers/mmc/core/core.h +0 -1
@@ -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);
drivers/mmc/core/mmc.c +1 -1
@@ -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;
drivers/mmc/core/sd.c +1 -1
@@ -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;
include/linux/mmc/host.h +8 -0
@@ -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
Signature · 1 line
1.7.2.1
Re: [PATCH V2 1/2] mmc: Add helper function to check if a card is removable
Quoted 10 lines · Matt Fleming
There are two checks that need to be made when determining whether a card is removable. A host controller may set
MMC_CAP_NONREMOVABLEif 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.
Quoted 6 lines
Because this new function is likely to be called from modules we now need to export the
mmc_assume_removablesymbol.Signed-off-by Matt Fleming <[email protected]>Acked-by Kyungmin Park <[email protected]>Tested-by Jaehoon Chung <[email protected]>
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Chris Ball
AppliedRe: [PATCH V2 1/2] mmc: Add helper function to check if a card is removable
In reply to Matt FlemingHi Matt,
Quoted 10 lines · Matt Fleming
There are two checks that need to be made when determining whether a card is removable. A host controller may set
MMC_CAP_NONREMOVABLEif 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.
Quoted 6 lines
Because this new function is likely to be called from modules we now need to export the
mmc_assume_removablesymbol.Signed-off-by Matt Fleming <[email protected]>Acked-by Kyungmin Park <[email protected]>Tested-by Jaehoon Chung <[email protected]>
Applied to mmc-next with Wolfram's ACK and the following style change, thanks very much.
include/linux/mmc/host.h +1 -1
@@ -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
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child
Re: [PATCH V2 1/2] mmc: Add helper function to check if a card is removable
Quoted 3 lines · Chris Ball
Applied to mmc-next with Wolfram's ACK and the following style change, thanks very much.
Thanks Chris!
PATCH v2 2/2 mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case
In reply to Matt FlemingFrom: Jaehoon Chung <[email protected]>
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.
--- drivers/mmc/host/sdhci.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/mmc/host/sdhci.c +2 -1
@@ -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 ;
Signature · 1 line
1.7.2.1
Re: [PATCH V2 2/2] mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case
Quoted 6 lines · Matt Fleming
From: Jaehoon Chung <[email protected]>
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.
Quoted 8 lines
This patch requires cards to be removable before we're willing to set
MMC_CAP_NEEDS_POLL.Signed-off-by Jaehoon Chung <[email protected]>Acked-by Kyungmin Park <[email protected]>Acked-by Matt Fleming <[email protected]>[cjb: modified changelog and code indentation]Signed-off-by Chris Ball <[email protected]>
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Chris Ball
AppliedRe: [PATCH V2 2/2] mmc: sdhci: disable MMC_CAP_NEEDS_POLL in nonremovable case
In reply to Matt FlemingHi Matt,
Quoted 6 lines · Matt Fleming
From: Jaehoon Chung <[email protected]>
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.
Quoted 8 lines
This patch requires cards to be removable before we're willing to set
MMC_CAP_NEEDS_POLL.Signed-off-by Jaehoon Chung <[email protected]>Acked-by Kyungmin Park <[email protected]>Acked-by Matt Fleming <[email protected]>[cjb: modified changelog and code indentation]Signed-off-by Chris Ball <[email protected]>
Thanks, applied to mmc-next with Wolfram's ACK.
- Chris.
Signature · 2 lines
Chris Ball <[email protected]> <http://printf.net/> One Laptop Per Child