diff mbox

[V2,1/4] mmc: sdhci: Do not unnecessarily enable wakeup for card detect interrupt

Message ID 1518612992-4951-2-git-send-email-adrian.hunter@intel.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Adrian Hunter Feb. 14, 2018, 12:56 p.m. UTC
Do not unnecessarily enable card detect wakeup in the cases that the card
is not removable or a GPIO is used for card detect.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/mmc/host/sdhci.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Ulf Hansson Feb. 27, 2018, 8:14 a.m. UTC | #1
On 14 February 2018 at 13:56, Adrian Hunter <adrian.hunter@intel.com> wrote:
> Do not unnecessarily enable card detect wakeup in the cases that the card
> is not removable or a GPIO is used for card detect.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  drivers/mmc/host/sdhci.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 2020e57ffa7e..c2653347bb5e 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2899,6 +2899,14 @@ static irqreturn_t sdhci_thread_irq(int irq, void *dev_id)
>  \*****************************************************************************/
>
>  #ifdef CONFIG_PM
> +
> +static bool sdhci_cd_irq_can_wakeup(struct sdhci_host *host)
> +{
> +       return mmc_card_is_removable(host->mmc) &&
> +              !(host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
> +              host->mmc->slot.cd_irq < 0;

We have mmc_can_gpio_cd(), I guess it it should be sufficient to add
that check!?

> +}
> +
>  /*
>   * To enable wakeup events, the corresponding events have to be enabled in
>   * the Interrupt Status Enable register too. See 'Table 1-6: Wakeup Signal
> @@ -2915,7 +2923,7 @@ static bool sdhci_enable_irq_wakeups(struct sdhci_host *host)
>         u8 wake_val = 0;
>         u8 val;
>
> -       if (!(host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)) {
> +       if (sdhci_cd_irq_can_wakeup(host)) {
>                 wake_val |= SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE;
>                 irq_val |= SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE;
>         }
> --
> 1.9.1
>

Kind regards
Uffe
Adrian Hunter Feb. 27, 2018, 8:44 a.m. UTC | #2
On 27/02/18 10:14, Ulf Hansson wrote:
> On 14 February 2018 at 13:56, Adrian Hunter <adrian.hunter@intel.com> wrote:
>> Do not unnecessarily enable card detect wakeup in the cases that the card
>> is not removable or a GPIO is used for card detect.
>>
>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
>> ---
>>  drivers/mmc/host/sdhci.c | 10 +++++++++-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
>> index 2020e57ffa7e..c2653347bb5e 100644
>> --- a/drivers/mmc/host/sdhci.c
>> +++ b/drivers/mmc/host/sdhci.c
>> @@ -2899,6 +2899,14 @@ static irqreturn_t sdhci_thread_irq(int irq, void *dev_id)
>>  \*****************************************************************************/
>>
>>  #ifdef CONFIG_PM
>> +
>> +static bool sdhci_cd_irq_can_wakeup(struct sdhci_host *host)
>> +{
>> +       return mmc_card_is_removable(host->mmc) &&
>> +              !(host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
>> +              host->mmc->slot.cd_irq < 0;
> 
> We have mmc_can_gpio_cd(), I guess it it should be sufficient to add
> that check!?

Can substitute mmc_can_gpio_cd() for 'host->mmc->slot.cd_irq < 0'.  The
other checks are needed.

> 
>> +}
>> +
>>  /*
>>   * To enable wakeup events, the corresponding events have to be enabled in
>>   * the Interrupt Status Enable register too. See 'Table 1-6: Wakeup Signal
>> @@ -2915,7 +2923,7 @@ static bool sdhci_enable_irq_wakeups(struct sdhci_host *host)
>>         u8 wake_val = 0;
>>         u8 val;
>>
>> -       if (!(host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)) {
>> +       if (sdhci_cd_irq_can_wakeup(host)) {
>>                 wake_val |= SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE;
>>                 irq_val |= SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE;
>>         }
>> --
>> 1.9.1
>>
> 
> Kind regards
> Uffe
>
diff mbox

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 2020e57ffa7e..c2653347bb5e 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2899,6 +2899,14 @@  static irqreturn_t sdhci_thread_irq(int irq, void *dev_id)
 \*****************************************************************************/
 
 #ifdef CONFIG_PM
+
+static bool sdhci_cd_irq_can_wakeup(struct sdhci_host *host)
+{
+	return mmc_card_is_removable(host->mmc) &&
+	       !(host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) &&
+	       host->mmc->slot.cd_irq < 0;
+}
+
 /*
  * To enable wakeup events, the corresponding events have to be enabled in
  * the Interrupt Status Enable register too. See 'Table 1-6: Wakeup Signal
@@ -2915,7 +2923,7 @@  static bool sdhci_enable_irq_wakeups(struct sdhci_host *host)
 	u8 wake_val = 0;
 	u8 val;
 
-	if (!(host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)) {
+	if (sdhci_cd_irq_can_wakeup(host)) {
 		wake_val |= SDHCI_WAKE_ON_INSERT | SDHCI_WAKE_ON_REMOVE;
 		irq_val |= SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE;
 	}