diff mbox

[2/2] mmc: mxcmmc: Convert to SIMPLE_DEV_PM_OPS

Message ID 1393080372-6760-2-git-send-email-shc_work@mail.ru (mailing list archive)
State New, archived
Headers show

Commit Message

Alexander Shiyan Feb. 22, 2014, 2:46 p.m. UTC
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
---
 drivers/mmc/host/mxcmmc.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

Comments

Fabio Estevam Feb. 22, 2014, 2:51 p.m. UTC | #1
On Sat, Feb 22, 2014 at 11:46 AM, Alexander Shiyan <shc_work@mail.ru> wrote:
> Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> ---
>  drivers/mmc/host/mxcmmc.c | 13 +++----------
>  1 file changed, 3 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
> index 84d630e..86401c0 100644
> --- a/drivers/mmc/host/mxcmmc.c
> +++ b/drivers/mmc/host/mxcmmc.c
> @@ -1220,8 +1220,7 @@ static int mxcmci_remove(struct platform_device *pdev)
>         return 0;
>  }
>
> -#ifdef CONFIG_PM
> -static int mxcmci_suspend(struct device *dev)

Doesn't this need to be protected by CONFIG_PM_SLEEP?
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Shiyan Feb. 22, 2014, 2:57 p.m. UTC | #2
???????, 22 ??????? 2014, 11:51 -03:00 ?? Fabio Estevam <festevam@gmail.com>:
> On Sat, Feb 22, 2014 at 11:46 AM, Alexander Shiyan <shc_work@mail.ru> wrote:
> > Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
> > ---
> >  drivers/mmc/host/mxcmmc.c | 13 +++----------
> >  1 file changed, 3 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
> > index 84d630e..86401c0 100644
> > --- a/drivers/mmc/host/mxcmmc.c
> > +++ b/drivers/mmc/host/mxcmmc.c
> > @@ -1220,8 +1220,7 @@ static int mxcmci_remove(struct platform_device *pdev)
> >         return 0;
> >  }
> >
> > -#ifdef CONFIG_PM
> > -static int mxcmci_suspend(struct device *dev)
> 
> Doesn't this need to be protected by CONFIG_PM_SLEEP?

No, this already protected by SIMPLE_DEV_PM_OPS(),
see include/linux/pm.h.

---
Fabio Estevam Feb. 22, 2014, 2:59 p.m. UTC | #3
On Sat, Feb 22, 2014 at 11:57 AM, Alexander Shiyan <shc_work@mail.ru> wrote:
> ???????, 22 ??????? 2014, 11:51 -03:00 ?? Fabio Estevam <festevam@gmail.com>:
>> On Sat, Feb 22, 2014 at 11:46 AM, Alexander Shiyan <shc_work@mail.ru> wrote:
>> > Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
>> > ---
>> >  drivers/mmc/host/mxcmmc.c | 13 +++----------
>> >  1 file changed, 3 insertions(+), 10 deletions(-)
>> >
>> > diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
>> > index 84d630e..86401c0 100644
>> > --- a/drivers/mmc/host/mxcmmc.c
>> > +++ b/drivers/mmc/host/mxcmmc.c
>> > @@ -1220,8 +1220,7 @@ static int mxcmci_remove(struct platform_device *pdev)
>> >         return 0;
>> >  }
>> >
>> > -#ifdef CONFIG_PM
>> > -static int mxcmci_suspend(struct device *dev)
>>
>> Doesn't this need to be protected by CONFIG_PM_SLEEP?
>
> No, this already protected by SIMPLE_DEV_PM_OPS(),
> see include/linux/pm.h.

but then you would get a warning saying that "mxcmci_suspend/resume"
are defined by not used" when CONFIG_PM_SLEEP=n
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alexander Shiyan Feb. 22, 2014, 3:02 p.m. UTC | #4
0KHRg9Cx0LHQvtGC0LAsIDIyINGE0LXQstGA0LDQu9GPIDIwMTQsIDExOjU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ICByZXR1cm4gMDsKPiA+PiA+ICB9Cj4gPj4gPgo+
ID4+ID4gLSNpZmRlZiBDT05GSUdfUE0KPiA+PiA+IC1zdGF0aWMgaW50IG14Y21jaV9zdXNwZW5k
KHN0cnVjdCBkZXZpY2UgKmRldikKPiA+Pgo+ID4+IERvZXNuJ3QgdGhpcyBuZWVkIHRvIGJlIHBy
b3RlY3RlZCBieSBDT05GSUdfUE1fU0xFRVA/Cj4gPgo+ID4gTm8sIHRoaXMgYWxyZWFkeSBwcm90
ZWN0ZWQgYnkgU0lNUExFX0RFVl9QTV9PUFMoKSwKPiA+IHNlZSBpbmNsdWRlL2xpbnV4L3BtLmgu
Cj4gCj4gYnV0IHRoZW4geW91IHdvdWxkIGdldCBhIHdhcm5pbmcgc2F5aW5nIHRoYXQgIm14Y21j
aV9zdXNwZW5kL3Jlc3VtZSIKPiBhcmUgZGVmaW5lZCBieSBub3QgdXNlZCIgd2hlbiBDT05GSUdf
UE1fU0xFRVA9bgoKUGxlYXNlIHNlZSB0aGUgcGF0Y2ggZmlyc3QsCnRoaXMgd2FybmluZ3MgaXMg
YXZvaWRlZCBieSAiX19tYXliZV91bnVzZWQiIGF0dHJpYnV0ZXMuCgotLS0K
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Fabio Estevam Feb. 22, 2014, 3:05 p.m. UTC | #5
On Sat, Feb 22, 2014 at 12:02 PM, Alexander Shiyan <shc_work@mail.ru> wrote:

>> but then you would get a warning saying that "mxcmci_suspend/resume"
>> are defined by not used" when CONFIG_PM_SLEEP=n
>
> Please see the patch first,
> this warnings is avoided by "__maybe_unused" attributes.

Ok, I see it now ;-)

Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann Feb. 22, 2014, 3:42 p.m. UTC | #6
On Saturday 22 February 2014 12:05:43 Fabio Estevam wrote:
> On Sat, Feb 22, 2014 at 12:02 PM, Alexander Shiyan <shc_work@mail.ru> wrote:
> 
> >> but then you would get a warning saying that "mxcmci_suspend/resume"
> >> are defined by not used" when CONFIG_PM_SLEEP=n
> >
> > Please see the patch first,
> > this warnings is avoided by "__maybe_unused" attributes.
> 
> Ok, I see it now 
> 
> Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com>
> 

Unfortunately, everyone else uses the #ifdef here, and a lot of people
don't understand how to use __maybe_unused for this. IMHO all
drivers should do it the way that Alexander does it here, or
we should change the SIMPLE_DEV_PM_OPS() definition in a way that
doesn't need the #ifdef.

I have in the past tried to come up with a way to handle this more
naturally, but couldn't figure out how to migrate to it. If
SIMPLE_DEV_PM_OPS() defines an unused variable pointing to the
operations, we need neither the #ifdef nor the __maybe_unused
marker, but then it fails to build when there is an #ifdef.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/mxcmmc.c b/drivers/mmc/host/mxcmmc.c
index 84d630e..86401c0 100644
--- a/drivers/mmc/host/mxcmmc.c
+++ b/drivers/mmc/host/mxcmmc.c
@@ -1220,8 +1220,7 @@  static int mxcmci_remove(struct platform_device *pdev)
 	return 0;
 }
 
-#ifdef CONFIG_PM
-static int mxcmci_suspend(struct device *dev)
+static int __maybe_unused mxcmci_suspend(struct device *dev)
 {
 	struct mmc_host *mmc = dev_get_drvdata(dev);
 	struct mxcmci_host *host = mmc_priv(mmc);
@@ -1231,7 +1230,7 @@  static int mxcmci_suspend(struct device *dev)
 	return 0;
 }
 
-static int mxcmci_resume(struct device *dev)
+static int __maybe_unused mxcmci_resume(struct device *dev)
 {
 	struct mmc_host *mmc = dev_get_drvdata(dev);
 	struct mxcmci_host *host = mmc_priv(mmc);
@@ -1241,11 +1240,7 @@  static int mxcmci_resume(struct device *dev)
 	return 0;
 }
 
-static const struct dev_pm_ops mxcmci_pm_ops = {
-	.suspend	= mxcmci_suspend,
-	.resume		= mxcmci_resume,
-};
-#endif
+static SIMPLE_DEV_PM_OPS(mxcmci_pm_ops, mxcmci_suspend, mxcmci_resume);
 
 static struct platform_driver mxcmci_driver = {
 	.probe		= mxcmci_probe,
@@ -1254,9 +1249,7 @@  static struct platform_driver mxcmci_driver = {
 	.driver		= {
 		.name		= DRIVER_NAME,
 		.owner		= THIS_MODULE,
-#ifdef CONFIG_PM
 		.pm	= &mxcmci_pm_ops,
-#endif
 		.of_match_table	= mxcmci_of_match,
 	}
 };