linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFT][PATCH v3] mmc: change cb710-mmc platform power management to use dev_pm_ops
@ 2014-02-12 21:21 Shuah Khan
  2014-02-13  9:47 ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Shuah Khan @ 2014-02-12 21:21 UTC (permalink / raw)
  To: rjw, mirq-linux, ulf.hansson, chris
  Cc: Shuah Khan, linux-pm, linux-kernel, linux-mmc, shuahkhan

Change cb710-mmc platform driver to register pm ops using dev_pm_ops instead
of legacy pm_ops. The existing legacy suspend/resume routines are identical
and simply clear IRQ mask in the device in case it got undefined during sleep
state. Changed code to collapse suspend and resume into one .pm interface
for suspend and resume which gets installed for suspend, freeze, poweroff,
thaw, restore, and resume states using SIMPLE_DEV_PM_OPS().

Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
---

patch v3: Addresses review comments on patch v2

 drivers/mmc/host/cb710-mmc.c |   40 ++++++++++++++++------------------------
 1 file changed, 16 insertions(+), 24 deletions(-)

diff --git a/drivers/mmc/host/cb710-mmc.c b/drivers/mmc/host/cb710-mmc.c
index 1087b4c..2dc7b2dc 100644
--- a/drivers/mmc/host/cb710-mmc.c
+++ b/drivers/mmc/host/cb710-mmc.c
@@ -662,26 +662,6 @@ static const struct mmc_host_ops cb710_mmc_host = {
 	.get_cd = cb710_mmc_get_cd,
 };
 
-#ifdef CONFIG_PM
-
-static int cb710_mmc_suspend(struct platform_device *pdev, pm_message_t state)
-{
-	struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
-
-	cb710_mmc_enable_irq(slot, 0, ~0);
-	return 0;
-}
-
-static int cb710_mmc_resume(struct platform_device *pdev)
-{
-	struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
-
-	cb710_mmc_enable_irq(slot, 0, ~0);
-	return 0;
-}
-
-#endif /* CONFIG_PM */
-
 static int cb710_mmc_init(struct platform_device *pdev)
 {
 	struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
@@ -762,14 +742,26 @@ static int cb710_mmc_exit(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int cb710_mmc_suspend_resume(struct device *dev)
+{
+	struct cb710_slot *slot = cb710_pdev_to_slot(to_platform_device(dev));
+
+	cb710_mmc_enable_irq(slot, 0, ~0);
+	return 0;
+}
+#else
+#define cb710_mmc_suspend_resume NULL
+#endif
+
+static SIMPLE_DEV_PM_OPS(cb710_mmc_dev_pm_ops, cb710_mmc_suspend_resume,
+			 cb710_mmc_suspend_resume);
+
 static struct platform_driver cb710_mmc_driver = {
 	.driver.name = "cb710-mmc",
 	.probe = cb710_mmc_init,
 	.remove = cb710_mmc_exit,
-#ifdef CONFIG_PM
-	.suspend = cb710_mmc_suspend,
-	.resume = cb710_mmc_resume,
-#endif
+	.driver.pm = &cb710_mmc_dev_pm_ops,
 };
 
 module_platform_driver(cb710_mmc_driver);
-- 
1.7.10.4


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

* Re: [RFT][PATCH v3] mmc: change cb710-mmc platform power management to use dev_pm_ops
  2014-02-12 21:21 [RFT][PATCH v3] mmc: change cb710-mmc platform power management to use dev_pm_ops Shuah Khan
@ 2014-02-13  9:47 ` Ulf Hansson
  2014-02-13 13:49   ` Shuah Khan
  0 siblings, 1 reply; 4+ messages in thread
From: Ulf Hansson @ 2014-02-13  9:47 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Rafael J. Wysocki, mirq-linux, Chris Ball, linux-pm,
	linux-kernel, linux-mmc, Shuah Khan

On 12 February 2014 22:21, Shuah Khan <shuah.kh@samsung.com> wrote:
> Change cb710-mmc platform driver to register pm ops using dev_pm_ops instead
> of legacy pm_ops. The existing legacy suspend/resume routines are identical
> and simply clear IRQ mask in the device in case it got undefined during sleep
> state. Changed code to collapse suspend and resume into one .pm interface
> for suspend and resume which gets installed for suspend, freeze, poweroff,
> thaw, restore, and resume states using SIMPLE_DEV_PM_OPS().
>
> Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
> ---
>
> patch v3: Addresses review comments on patch v2
>
>  drivers/mmc/host/cb710-mmc.c |   40 ++++++++++++++++------------------------
>  1 file changed, 16 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/mmc/host/cb710-mmc.c b/drivers/mmc/host/cb710-mmc.c
> index 1087b4c..2dc7b2dc 100644
> --- a/drivers/mmc/host/cb710-mmc.c
> +++ b/drivers/mmc/host/cb710-mmc.c
> @@ -662,26 +662,6 @@ static const struct mmc_host_ops cb710_mmc_host = {
>         .get_cd = cb710_mmc_get_cd,
>  };
>
> -#ifdef CONFIG_PM
> -
> -static int cb710_mmc_suspend(struct platform_device *pdev, pm_message_t state)
> -{
> -       struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
> -
> -       cb710_mmc_enable_irq(slot, 0, ~0);
> -       return 0;
> -}
> -
> -static int cb710_mmc_resume(struct platform_device *pdev)
> -{
> -       struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
> -
> -       cb710_mmc_enable_irq(slot, 0, ~0);
> -       return 0;
> -}
> -
> -#endif /* CONFIG_PM */
> -
>  static int cb710_mmc_init(struct platform_device *pdev)
>  {
>         struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
> @@ -762,14 +742,26 @@ static int cb710_mmc_exit(struct platform_device *pdev)
>         return 0;
>  }
>
> +#ifdef CONFIG_PM_SLEEP
> +static int cb710_mmc_suspend_resume(struct device *dev)
> +{
> +       struct cb710_slot *slot = cb710_pdev_to_slot(to_platform_device(dev));
> +
> +       cb710_mmc_enable_irq(slot, 0, ~0);
> +       return 0;
> +}
> +#else
> +#define cb710_mmc_suspend_resume NULL

You don't need this. The macro will handle this for you.

Kind regards
Ulf Hansson

> +#endif
> +
> +static SIMPLE_DEV_PM_OPS(cb710_mmc_dev_pm_ops, cb710_mmc_suspend_resume,
> +                        cb710_mmc_suspend_resume);
> +
>  static struct platform_driver cb710_mmc_driver = {
>         .driver.name = "cb710-mmc",
>         .probe = cb710_mmc_init,
>         .remove = cb710_mmc_exit,
> -#ifdef CONFIG_PM
> -       .suspend = cb710_mmc_suspend,
> -       .resume = cb710_mmc_resume,
> -#endif
> +       .driver.pm = &cb710_mmc_dev_pm_ops,
>  };
>
>  module_platform_driver(cb710_mmc_driver);
> --
> 1.7.10.4
>

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

* Re: [RFT][PATCH v3] mmc: change cb710-mmc platform power management to use dev_pm_ops
  2014-02-13  9:47 ` Ulf Hansson
@ 2014-02-13 13:49   ` Shuah Khan
  2014-02-14 14:32     ` Ulf Hansson
  0 siblings, 1 reply; 4+ messages in thread
From: Shuah Khan @ 2014-02-13 13:49 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Rafael J. Wysocki, mirq-linux, Chris Ball, linux-pm,
	linux-kernel, linux-mmc, Shuah Khan, Shuah Khan

On 02/13/2014 02:47 AM, Ulf Hansson wrote:
> On 12 February 2014 22:21, Shuah Khan <shuah.kh@samsung.com> wrote:
>> Change cb710-mmc platform driver to register pm ops using dev_pm_ops instead
>> of legacy pm_ops. The existing legacy suspend/resume routines are identical
>> and simply clear IRQ mask in the device in case it got undefined during sleep
>> state. Changed code to collapse suspend and resume into one .pm interface
>> for suspend and resume which gets installed for suspend, freeze, poweroff,
>> thaw, restore, and resume states using SIMPLE_DEV_PM_OPS().
>>
>> Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
>> ---
>>
>> patch v3: Addresses review comments on patch v2
>>
>>   drivers/mmc/host/cb710-mmc.c |   40 ++++++++++++++++------------------------
>>   1 file changed, 16 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/mmc/host/cb710-mmc.c b/drivers/mmc/host/cb710-mmc.c
>> index 1087b4c..2dc7b2dc 100644
>> --- a/drivers/mmc/host/cb710-mmc.c
>> +++ b/drivers/mmc/host/cb710-mmc.c
>> @@ -662,26 +662,6 @@ static const struct mmc_host_ops cb710_mmc_host = {
>>          .get_cd = cb710_mmc_get_cd,
>>   };
>>
>> -#ifdef CONFIG_PM
>> -
>> -static int cb710_mmc_suspend(struct platform_device *pdev, pm_message_t state)
>> -{
>> -       struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
>> -
>> -       cb710_mmc_enable_irq(slot, 0, ~0);
>> -       return 0;
>> -}
>> -
>> -static int cb710_mmc_resume(struct platform_device *pdev)
>> -{
>> -       struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
>> -
>> -       cb710_mmc_enable_irq(slot, 0, ~0);
>> -       return 0;
>> -}
>> -
>> -#endif /* CONFIG_PM */
>> -
>>   static int cb710_mmc_init(struct platform_device *pdev)
>>   {
>>          struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
>> @@ -762,14 +742,26 @@ static int cb710_mmc_exit(struct platform_device *pdev)
>>          return 0;
>>   }
>>
>> +#ifdef CONFIG_PM_SLEEP
>> +static int cb710_mmc_suspend_resume(struct device *dev)
>> +{
>> +       struct cb710_slot *slot = cb710_pdev_to_slot(to_platform_device(dev));
>> +
>> +       cb710_mmc_enable_irq(slot, 0, ~0);
>> +       return 0;
>> +}
>> +#else
>> +#define cb710_mmc_suspend_resume NULL
>
> You don't need this. The macro will handle this for you.
>

Without this compiles fail when CONFIG_PM_SLEEP is not defined.

-- Shuah


-- 
Shuah Khan
Senior Linux Kernel Developer - Open Source Group
Samsung Research America(Silicon Valley)
shuah.kh@samsung.com | (970) 672-0658

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

* Re: [RFT][PATCH v3] mmc: change cb710-mmc platform power management to use dev_pm_ops
  2014-02-13 13:49   ` Shuah Khan
@ 2014-02-14 14:32     ` Ulf Hansson
  0 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2014-02-14 14:32 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Rafael J. Wysocki, mirq-linux, Chris Ball, linux-pm,
	linux-kernel, linux-mmc, Shuah Khan

On 13 February 2014 14:49, Shuah Khan <shuah.kh@samsung.com> wrote:
> On 02/13/2014 02:47 AM, Ulf Hansson wrote:
>>
>> On 12 February 2014 22:21, Shuah Khan <shuah.kh@samsung.com> wrote:
>>>
>>> Change cb710-mmc platform driver to register pm ops using dev_pm_ops
>>> instead
>>> of legacy pm_ops. The existing legacy suspend/resume routines are
>>> identical
>>> and simply clear IRQ mask in the device in case it got undefined during
>>> sleep
>>> state. Changed code to collapse suspend and resume into one .pm interface
>>> for suspend and resume which gets installed for suspend, freeze,
>>> poweroff,
>>> thaw, restore, and resume states using SIMPLE_DEV_PM_OPS().
>>>
>>> Signed-off-by: Shuah Khan <shuah.kh@samsung.com>
>>> ---
>>>
>>> patch v3: Addresses review comments on patch v2
>>>
>>>   drivers/mmc/host/cb710-mmc.c |   40
>>> ++++++++++++++++------------------------
>>>   1 file changed, 16 insertions(+), 24 deletions(-)
>>>
>>> diff --git a/drivers/mmc/host/cb710-mmc.c b/drivers/mmc/host/cb710-mmc.c
>>> index 1087b4c..2dc7b2dc 100644
>>> --- a/drivers/mmc/host/cb710-mmc.c
>>> +++ b/drivers/mmc/host/cb710-mmc.c
>>> @@ -662,26 +662,6 @@ static const struct mmc_host_ops cb710_mmc_host = {
>>>          .get_cd = cb710_mmc_get_cd,
>>>   };
>>>
>>> -#ifdef CONFIG_PM
>>> -
>>> -static int cb710_mmc_suspend(struct platform_device *pdev, pm_message_t
>>> state)
>>> -{
>>> -       struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
>>> -
>>> -       cb710_mmc_enable_irq(slot, 0, ~0);
>>> -       return 0;
>>> -}
>>> -
>>> -static int cb710_mmc_resume(struct platform_device *pdev)
>>> -{
>>> -       struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
>>> -
>>> -       cb710_mmc_enable_irq(slot, 0, ~0);
>>> -       return 0;
>>> -}
>>> -
>>> -#endif /* CONFIG_PM */
>>> -
>>>   static int cb710_mmc_init(struct platform_device *pdev)
>>>   {
>>>          struct cb710_slot *slot = cb710_pdev_to_slot(pdev);
>>> @@ -762,14 +742,26 @@ static int cb710_mmc_exit(struct platform_device
>>> *pdev)
>>>          return 0;
>>>   }
>>>
>>> +#ifdef CONFIG_PM_SLEEP
>>> +static int cb710_mmc_suspend_resume(struct device *dev)
>>> +{
>>> +       struct cb710_slot *slot =
>>> cb710_pdev_to_slot(to_platform_device(dev));
>>> +
>>> +       cb710_mmc_enable_irq(slot, 0, ~0);
>>> +       return 0;
>>> +}
>>> +#
>>> +#define cb710_mmc_suspend_resume NULL
>>
>>
>> You don't need this. The macro will handle this for you.
>>
>
> Without this compiles fail when CONFIG_PM_SLEEP is not defined.

No it won't. You can remove the #else statement.

The functions don't have to be defined for !CONFIG_PM_SLEEP, since the
macro will handle that.

Kind regards
Ulf Hansson

>
> -- Shuah
>
>
> --
> Shuah Khan
> Senior Linux Kernel Developer - Open Source Group
> Samsung Research America(Silicon Valley)
> shuah.kh@samsung.com | (970) 672-0658

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

end of thread, other threads:[~2014-02-14 14:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-12 21:21 [RFT][PATCH v3] mmc: change cb710-mmc platform power management to use dev_pm_ops Shuah Khan
2014-02-13  9:47 ` Ulf Hansson
2014-02-13 13:49   ` Shuah Khan
2014-02-14 14:32     ` 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).