linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] mmc: Set suspend/resume bus operations if CONFIG_PM_RUNTIME is used
@ 2012-01-03 22:47 Dmitry Shmidt
  2012-01-04 11:46 ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Shmidt @ 2012-01-03 22:47 UTC (permalink / raw)
  To: linux-mmc

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
---
 drivers/mmc/card/block.c |    2 +-
 drivers/mmc/core/bus.c   |   25 +++++++------------------
 include/linux/mmc/card.h |    2 +-
 3 files changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 1e0e27c..969d49b 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1677,7 +1677,7 @@ static void mmc_blk_remove(struct mmc_card *card)
 }
 
 #ifdef CONFIG_PM
-static int mmc_blk_suspend(struct mmc_card *card, pm_message_t state)
+static int mmc_blk_suspend(struct mmc_card *card)
 {
 	struct mmc_blk_data *part_md;
 	struct mmc_blk_data *md = mmc_get_drvdata(card);
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
index 6be4924..13ca498 100644
--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -122,18 +122,18 @@ static int mmc_bus_remove(struct device *dev)
 	return 0;
 }
 
-static int mmc_bus_suspend(struct device *dev, pm_message_t state)
+static int mmc_bus_pm_suspend(struct device *dev)
 {
 	struct mmc_driver *drv = to_mmc_driver(dev->driver);
 	struct mmc_card *card = mmc_dev_to_card(dev);
 	int ret = 0;
 
 	if (dev->driver && drv->suspend)
-		ret = drv->suspend(card, state);
+		ret = drv->suspend(card);
 	return ret;
 }
 
-static int mmc_bus_resume(struct device *dev)
+static int mmc_bus_pm_resume(struct device *dev)
 {
 	struct mmc_driver *drv = to_mmc_driver(dev->driver);
 	struct mmc_card *card = mmc_dev_to_card(dev);
@@ -145,7 +145,6 @@ static int mmc_bus_resume(struct device *dev)
 }
 
 #ifdef CONFIG_PM_RUNTIME
-
 static int mmc_runtime_suspend(struct device *dev)
 {
 	struct mmc_card *card = mmc_dev_to_card(dev);
@@ -164,21 +163,13 @@ static int mmc_runtime_idle(struct device *dev)
 {
 	return pm_runtime_suspend(dev);
 }
+#endif /* CONFIG_PM_RUNTIME */
 
 static const struct dev_pm_ops mmc_bus_pm_ops = {
-	.runtime_suspend	= mmc_runtime_suspend,
-	.runtime_resume		= mmc_runtime_resume,
-	.runtime_idle		= mmc_runtime_idle,
+	SET_SYSTEM_SLEEP_PM_OPS(mmc_bus_pm_suspend, mmc_bus_pm_resume)
+	SET_RUNTIME_PM_OPS(mmc_runtime_suspend, mmc_runtime_resume, mmc_runtime_idle)
 };
 
-#define MMC_PM_OPS_PTR	(&mmc_bus_pm_ops)
-
-#else /* !CONFIG_PM_RUNTIME */
-
-#define MMC_PM_OPS_PTR	NULL
-
-#endif /* !CONFIG_PM_RUNTIME */
-
 static struct bus_type mmc_bus_type = {
 	.name		= "mmc",
 	.dev_attrs	= mmc_dev_attrs,
@@ -186,9 +177,7 @@ static struct bus_type mmc_bus_type = {
 	.uevent		= mmc_bus_uevent,
 	.probe		= mmc_bus_probe,
 	.remove		= mmc_bus_remove,
-	.suspend	= mmc_bus_suspend,
-	.resume		= mmc_bus_resume,
-	.pm		= MMC_PM_OPS_PTR,
+	.pm		= &mmc_bus_pm_ops,
 };
 
 int mmc_register_bus(void)
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index c8ef9bc..80caf1d 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -455,7 +455,7 @@ struct mmc_driver {
 	struct device_driver drv;
 	int (*probe)(struct mmc_card *);
 	void (*remove)(struct mmc_card *);
-	int (*suspend)(struct mmc_card *, pm_message_t);
+	int (*suspend)(struct mmc_card *);
 	int (*resume)(struct mmc_card *);
 };
 
-- 
1.7.3.1


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

* Re: [PATCH V2] mmc: Set suspend/resume bus operations if CONFIG_PM_RUNTIME is used
  2012-01-03 22:47 [PATCH V2] mmc: Set suspend/resume bus operations if CONFIG_PM_RUNTIME is used Dmitry Shmidt
@ 2012-01-04 11:46 ` Ulf Hansson
  2012-01-05 20:32   ` Dmitry Shmidt
  0 siblings, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2012-01-04 11:46 UTC (permalink / raw)
  To: Dmitry Shmidt; +Cc: linux-mmc@vger.kernel.org

Dmitry Shmidt wrote:
> Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
> ---
>  drivers/mmc/card/block.c |    2 +-
>  drivers/mmc/core/bus.c   |   25 +++++++------------------
>  include/linux/mmc/card.h |    2 +-
>  3 files changed, 9 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 1e0e27c..969d49b 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -1677,7 +1677,7 @@ static void mmc_blk_remove(struct mmc_card *card)
>  }
>  
>  #ifdef CONFIG_PM

Should not this be:
#ifdef CONFIG_PM_SLEEP


> -static int mmc_blk_suspend(struct mmc_card *card, pm_message_t state)
> +static int mmc_blk_suspend(struct mmc_card *card)
>  {
>  	struct mmc_blk_data *part_md;
>  	struct mmc_blk_data *md = mmc_get_drvdata(card);
> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
> index 6be4924..13ca498 100644
> --- a/drivers/mmc/core/bus.c
> +++ b/drivers/mmc/core/bus.c
> @@ -122,18 +122,18 @@ static int mmc_bus_remove(struct device *dev)
>  	return 0;
>  }
>  

Should we not add #ifdef CONFIG_PM_SLEEP around 
mmc_bus_pm_resume|suspend below as well?

> -static int mmc_bus_suspend(struct device *dev, pm_message_t state)
> +static int mmc_bus_pm_suspend(struct device *dev)
>  {
>  	struct mmc_driver *drv = to_mmc_driver(dev->driver);
>  	struct mmc_card *card = mmc_dev_to_card(dev);
>  	int ret = 0;
>  
>  	if (dev->driver && drv->suspend)
> -		ret = drv->suspend(card, state);
> +		ret = drv->suspend(card);
>  	return ret;
>  }
>  
> -static int mmc_bus_resume(struct device *dev)
> +static int mmc_bus_pm_resume(struct device *dev)
>  {
>  	struct mmc_driver *drv = to_mmc_driver(dev->driver);
>  	struct mmc_card *card = mmc_dev_to_card(dev);
> @@ -145,7 +145,6 @@ static int mmc_bus_resume(struct device *dev)
>  }
>  
>  #ifdef CONFIG_PM_RUNTIME
> -
>  static int mmc_runtime_suspend(struct device *dev)
>  {
>  	struct mmc_card *card = mmc_dev_to_card(dev);
> @@ -164,21 +163,13 @@ static int mmc_runtime_idle(struct device *dev)
>  {
>  	return pm_runtime_suspend(dev);
>  }

While you are doing this clean up, you could also remove the 
mmc_runtime_idle function and instead directly in SET_RUNTIME_PM_OPS use
pm_generic_runtime_idle, which will do the same thing.

> +#endif /* CONFIG_PM_RUNTIME */
>  
>  static const struct dev_pm_ops mmc_bus_pm_ops = {
> -	.runtime_suspend	= mmc_runtime_suspend,
> -	.runtime_resume		= mmc_runtime_resume,
> -	.runtime_idle		= mmc_runtime_idle,
> +	SET_SYSTEM_SLEEP_PM_OPS(mmc_bus_pm_suspend, mmc_bus_pm_resume)
> +	SET_RUNTIME_PM_OPS(mmc_runtime_suspend, mmc_runtime_resume, mmc_runtime_idle)
>  };
>  
> -#define MMC_PM_OPS_PTR	(&mmc_bus_pm_ops)
> -
> -#else /* !CONFIG_PM_RUNTIME */
> -
> -#define MMC_PM_OPS_PTR	NULL
> -
> -#endif /* !CONFIG_PM_RUNTIME */
> -
>  static struct bus_type mmc_bus_type = {
>  	.name		= "mmc",
>  	.dev_attrs	= mmc_dev_attrs,
> @@ -186,9 +177,7 @@ static struct bus_type mmc_bus_type = {
>  	.uevent		= mmc_bus_uevent,
>  	.probe		= mmc_bus_probe,
>  	.remove		= mmc_bus_remove,
> -	.suspend	= mmc_bus_suspend,
> -	.resume		= mmc_bus_resume,
> -	.pm		= MMC_PM_OPS_PTR,
> +	.pm		= &mmc_bus_pm_ops,
>  };
>  
>  int mmc_register_bus(void)
> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
> index c8ef9bc..80caf1d 100644
> --- a/include/linux/mmc/card.h
> +++ b/include/linux/mmc/card.h
> @@ -455,7 +455,7 @@ struct mmc_driver {
>  	struct device_driver drv;
>  	int (*probe)(struct mmc_card *);
>  	void (*remove)(struct mmc_card *);
> -	int (*suspend)(struct mmc_card *, pm_message_t);
> +	int (*suspend)(struct mmc_card *);
>  	int (*resume)(struct mmc_card *);
>  };
>  

Br
Ulf Hansson

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

* Re: [PATCH V2] mmc: Set suspend/resume bus operations if CONFIG_PM_RUNTIME is used
  2012-01-04 11:46 ` Ulf Hansson
@ 2012-01-05 20:32   ` Dmitry Shmidt
  2012-01-09 11:34     ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Shmidt @ 2012-01-05 20:32 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: linux-mmc@vger.kernel.org

On Wed, Jan 4, 2012 at 3:46 AM, Ulf Hansson <ulf.hansson@stericsson.com> wrote:
> Dmitry Shmidt wrote:
>>
>> Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
>> ---
>>  drivers/mmc/card/block.c |    2 +-
>>  drivers/mmc/core/bus.c   |   25 +++++++------------------
>>  include/linux/mmc/card.h |    2 +-
>>  3 files changed, 9 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>> index 1e0e27c..969d49b 100644
>> --- a/drivers/mmc/card/block.c
>> +++ b/drivers/mmc/card/block.c
>> @@ -1677,7 +1677,7 @@ static void mmc_blk_remove(struct mmc_card *card)
>>  }
>>  #ifdef CONFIG_PM
>
>
> Should not this be:
> #ifdef CONFIG_PM_SLEEP

No, I didn't change this code.  #ifdef CONFIG_PM is original line.

>
>
>
>> -static int mmc_blk_suspend(struct mmc_card *card, pm_message_t state)
>> +static int mmc_blk_suspend(struct mmc_card *card)
>>  {
>>        struct mmc_blk_data *part_md;
>>        struct mmc_blk_data *md = mmc_get_drvdata(card);
>> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
>> index 6be4924..13ca498 100644
>> --- a/drivers/mmc/core/bus.c
>> +++ b/drivers/mmc/core/bus.c
>> @@ -122,18 +122,18 @@ static int mmc_bus_remove(struct device *dev)
>>        return 0;
>>  }
>>
>
>
> Should we not add #ifdef CONFIG_PM_SLEEP around mmc_bus_pm_resume|suspend
> below as well?
>

No, v3.2-rc7 code is using CONFIG_PM. Am I missing something ?

>
>> -static int mmc_bus_suspend(struct device *dev, pm_message_t state)
>> +static int mmc_bus_pm_suspend(struct device *dev)
>>  {
>>        struct mmc_driver *drv = to_mmc_driver(dev->driver);
>>        struct mmc_card *card = mmc_dev_to_card(dev);
>>        int ret = 0;
>>        if (dev->driver && drv->suspend)
>> -               ret = drv->suspend(card, state);
>> +               ret = drv->suspend(card);
>>        return ret;
>>  }
>>  -static int mmc_bus_resume(struct device *dev)
>> +static int mmc_bus_pm_resume(struct device *dev)
>>  {
>>        struct mmc_driver *drv = to_mmc_driver(dev->driver);
>>        struct mmc_card *card = mmc_dev_to_card(dev);
>> @@ -145,7 +145,6 @@ static int mmc_bus_resume(struct device *dev)
>>  }
>>  #ifdef CONFIG_PM_RUNTIME
>> -
>>  static int mmc_runtime_suspend(struct device *dev)
>>  {
>>        struct mmc_card *card = mmc_dev_to_card(dev);
>> @@ -164,21 +163,13 @@ static int mmc_runtime_idle(struct device *dev)
>>  {
>>        return pm_runtime_suspend(dev);
>>  }
>
>
> While you are doing this clean up, you could also remove the
> mmc_runtime_idle function and instead directly in SET_RUNTIME_PM_OPS use
> pm_generic_runtime_idle, which will do the same thing.
>
>
>> +#endif /* CONFIG_PM_RUNTIME */
>>  static const struct dev_pm_ops mmc_bus_pm_ops = {
>> -       .runtime_suspend        = mmc_runtime_suspend,
>> -       .runtime_resume         = mmc_runtime_resume,
>> -       .runtime_idle           = mmc_runtime_idle,
>> +       SET_SYSTEM_SLEEP_PM_OPS(mmc_bus_pm_suspend, mmc_bus_pm_resume)
>> +       SET_RUNTIME_PM_OPS(mmc_runtime_suspend, mmc_runtime_resume,
>> mmc_runtime_idle)
>>  };
>>  -#define MMC_PM_OPS_PTR        (&mmc_bus_pm_ops)
>> -
>> -#else /* !CONFIG_PM_RUNTIME */
>> -
>> -#define MMC_PM_OPS_PTR NULL
>> -
>> -#endif /* !CONFIG_PM_RUNTIME */
>> -
>>  static struct bus_type mmc_bus_type = {
>>        .name           = "mmc",
>>        .dev_attrs      = mmc_dev_attrs,
>> @@ -186,9 +177,7 @@ static struct bus_type mmc_bus_type = {
>>        .uevent         = mmc_bus_uevent,
>>        .probe          = mmc_bus_probe,
>>        .remove         = mmc_bus_remove,
>> -       .suspend        = mmc_bus_suspend,
>> -       .resume         = mmc_bus_resume,
>> -       .pm             = MMC_PM_OPS_PTR,
>> +       .pm             = &mmc_bus_pm_ops,
>>  };
>>  int mmc_register_bus(void)
>> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
>> index c8ef9bc..80caf1d 100644
>> --- a/include/linux/mmc/card.h
>> +++ b/include/linux/mmc/card.h
>> @@ -455,7 +455,7 @@ struct mmc_driver {
>>        struct device_driver drv;
>>        int (*probe)(struct mmc_card *);
>>        void (*remove)(struct mmc_card *);
>> -       int (*suspend)(struct mmc_card *, pm_message_t);
>> +       int (*suspend)(struct mmc_card *);
>>        int (*resume)(struct mmc_card *);
>>  };
>>
>
>
> Br
> Ulf Hansson

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

* Re: [PATCH V2] mmc: Set suspend/resume bus operations if CONFIG_PM_RUNTIME is used
  2012-01-05 20:32   ` Dmitry Shmidt
@ 2012-01-09 11:34     ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2012-01-09 11:34 UTC (permalink / raw)
  To: Dmitry Shmidt; +Cc: linux-mmc@vger.kernel.org

Hi Dimitry,

I tried to clarify my comments below.

BR
Ulf Hansson

Dmitry Shmidt wrote:
> On Wed, Jan 4, 2012 at 3:46 AM, Ulf Hansson <ulf.hansson@stericsson.com> wrote:
>> Dmitry Shmidt wrote:
>>> Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
>>> ---
>>>  drivers/mmc/card/block.c |    2 +-
>>>  drivers/mmc/core/bus.c   |   25 +++++++------------------
>>>  include/linux/mmc/card.h |    2 +-
>>>  3 files changed, 9 insertions(+), 20 deletions(-)
>>>
>>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>>> index 1e0e27c..969d49b 100644
>>> --- a/drivers/mmc/card/block.c
>>> +++ b/drivers/mmc/card/block.c
>>> @@ -1677,7 +1677,7 @@ static void mmc_blk_remove(struct mmc_card *card)
>>>  }
>>>  #ifdef CONFIG_PM
>>
>> Should not this be:
>> #ifdef CONFIG_PM_SLEEP
> 
> No, I didn't change this code.  #ifdef CONFIG_PM is original line.

Using "SET_SYSTEM_SLEEP_PM_OPS" requires the CONFIG_PM_SLEEP to be set, 
otherwise you will not be setting any suspend/resume functions.

> 
>>
>>
>>> -static int mmc_blk_suspend(struct mmc_card *card, pm_message_t state)
>>> +static int mmc_blk_suspend(struct mmc_card *card)
>>>  {
>>>        struct mmc_blk_data *part_md;
>>>        struct mmc_blk_data *md = mmc_get_drvdata(card);
>>> diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c
>>> index 6be4924..13ca498 100644
>>> --- a/drivers/mmc/core/bus.c
>>> +++ b/drivers/mmc/core/bus.c
>>> @@ -122,18 +122,18 @@ static int mmc_bus_remove(struct device *dev)
>>>        return 0;
>>>  }
>>>
>>
>> Should we not add #ifdef CONFIG_PM_SLEEP around mmc_bus_pm_resume|suspend
>> below as well?
>>
> 
> No, v3.2-rc7 code is using CONFIG_PM. Am I missing something ?

See comment above.

> 
>>> -static int mmc_bus_suspend(struct device *dev, pm_message_t state)
>>> +static int mmc_bus_pm_suspend(struct device *dev)
>>>  {
>>>        struct mmc_driver *drv = to_mmc_driver(dev->driver);
>>>        struct mmc_card *card = mmc_dev_to_card(dev);
>>>        int ret = 0;
>>>        if (dev->driver && drv->suspend)
>>> -               ret = drv->suspend(card, state);
>>> +               ret = drv->suspend(card);
>>>        return ret;
>>>  }
>>>  -static int mmc_bus_resume(struct device *dev)
>>> +static int mmc_bus_pm_resume(struct device *dev)
>>>  {
>>>        struct mmc_driver *drv = to_mmc_driver(dev->driver);
>>>        struct mmc_card *card = mmc_dev_to_card(dev);
>>> @@ -145,7 +145,6 @@ static int mmc_bus_resume(struct device *dev)
>>>  }
>>>  #ifdef CONFIG_PM_RUNTIME
>>> -
>>>  static int mmc_runtime_suspend(struct device *dev)
>>>  {
>>>        struct mmc_card *card = mmc_dev_to_card(dev);
>>> @@ -164,21 +163,13 @@ static int mmc_runtime_idle(struct device *dev)
>>>  {
>>>        return pm_runtime_suspend(dev);
>>>  }
>>
>> While you are doing this clean up, you could also remove the
>> mmc_runtime_idle function and instead directly in SET_RUNTIME_PM_OPS use
>> pm_generic_runtime_idle, which will do the same thing.
>>
>>
>>> +#endif /* CONFIG_PM_RUNTIME */
>>>  static const struct dev_pm_ops mmc_bus_pm_ops = {
>>> -       .runtime_suspend        = mmc_runtime_suspend,
>>> -       .runtime_resume         = mmc_runtime_resume,
>>> -       .runtime_idle           = mmc_runtime_idle,
>>> +       SET_SYSTEM_SLEEP_PM_OPS(mmc_bus_pm_suspend, mmc_bus_pm_resume)
>>> +       SET_RUNTIME_PM_OPS(mmc_runtime_suspend, mmc_runtime_resume,
>>> mmc_runtime_idle)
>>>  };
>>>  -#define MMC_PM_OPS_PTR        (&mmc_bus_pm_ops)
>>> -
>>> -#else /* !CONFIG_PM_RUNTIME */
>>> -
>>> -#define MMC_PM_OPS_PTR NULL
>>> -
>>> -#endif /* !CONFIG_PM_RUNTIME */
>>> -
>>>  static struct bus_type mmc_bus_type = {
>>>        .name           = "mmc",
>>>        .dev_attrs      = mmc_dev_attrs,
>>> @@ -186,9 +177,7 @@ static struct bus_type mmc_bus_type = {
>>>        .uevent         = mmc_bus_uevent,
>>>        .probe          = mmc_bus_probe,
>>>        .remove         = mmc_bus_remove,
>>> -       .suspend        = mmc_bus_suspend,
>>> -       .resume         = mmc_bus_resume,
>>> -       .pm             = MMC_PM_OPS_PTR,
>>> +       .pm             = &mmc_bus_pm_ops,
>>>  };
>>>  int mmc_register_bus(void)
>>> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
>>> index c8ef9bc..80caf1d 100644
>>> --- a/include/linux/mmc/card.h
>>> +++ b/include/linux/mmc/card.h
>>> @@ -455,7 +455,7 @@ struct mmc_driver {
>>>        struct device_driver drv;
>>>        int (*probe)(struct mmc_card *);
>>>        void (*remove)(struct mmc_card *);
>>> -       int (*suspend)(struct mmc_card *, pm_message_t);
>>> +       int (*suspend)(struct mmc_card *);
>>>        int (*resume)(struct mmc_card *);
>>>  };
>>>
>>
>> Br
>> Ulf Hansson
> 


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

end of thread, other threads:[~2012-01-09 11:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-03 22:47 [PATCH V2] mmc: Set suspend/resume bus operations if CONFIG_PM_RUNTIME is used Dmitry Shmidt
2012-01-04 11:46 ` Ulf Hansson
2012-01-05 20:32   ` Dmitry Shmidt
2012-01-09 11:34     ` Ulf Hansson

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