serial8250: update to dev_pm_ops
RFC PATCH 1/1 serial8250: update to dev_pm_ops
serial8250: update to dev_pm_ops
Quoted 1 line
From dmesg:
Platform driver 'serial8250' needs updating - please use dev_pm_ops
Is this how it should be done? I have not tested it, but it compiles fine. Should I send in similar patches for other drivers that also give this message?
---
drivers/serial/8250.c +10 -6
@@ -2982,42 +2982,46 @@ static int __devexit serial8250_remove(struct platform_device *dev)return 0 ; } -static int serial8250_suspend (struct platform_device *dev,pm_message_t state) +static int serial8250_suspend (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev->dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)uart_suspend_port (&serial8250_reg, &up->port); }return 0 ; } -static int serial8250_resume (struct platform_device *dev) +static int serial8250_resume (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev->dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)serial8250_resume_port (i); }return 0 ; } +static struct dev_pm_ops serial8250_pm_ops = { + .suspend = serial8250_suspend, + .resume = serial8250_resume, +}; +static struct platform_driver serial8250_isa_driver = { .probe = serial8250_probe, .remove =__devexit_p (serial8250_remove), - .suspend = serial8250_suspend, - .resume = serial8250_resume, .driver = { .name ="serial8250" , .owner =THIS_MODULE , + .pm = &serial8250_pm_ops, }, };
Adding some CCs as there's no reply yet.
Quoted 1 line
From dmesg:> Platform driver 'serial8250' needs updating - please use
dev_pm_ops>> Is this how it should be done?
Alan or Rafael can probably tell.
One comment from me at the bottom.
Quoted 1 line
I have not tested it, but it compiles fine. Should I send in similar> patches for other drivers that also give this message?
Note that comments and questions that should not go in the commit logshould go between the separator after the Signed-off-by line and thepatch.
Quoted 1 line
Signed-off-by Erik Ekman <[email protected]>> ---
[Comments and questions go here]
drivers/serial/8250.c>index fb867a9..dcbc6da 100644>--- a/drivers/serial/8250.c>+++ b/drivers/serial/8250.c>@@ -2982,42 +2982,46 @@ static int __devexit serial8250_remove(struct platform_device *dev)> return 0;> }> >-static int serial8250_suspend(struct platform_device *dev, pm_message_t state)>+static int serial8250_suspend(struct device *dev)> {> int i;> > for (i = 0; i < UART_NR; i++) {> struct uart_8250_port *up = &serial8250_ports[i];> >- if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)>+ if (up->port.type != PORT_UNKNOWN && up->port.dev == dev)> uart_suspend_port(&serial8250_reg, &up->port);> }> > return 0;> }> >-static int serial8250_resume(struct platform_device *dev)>+static int serial8250_resume(struct device *dev)> {> int i;> > for (i = 0; i < UART_NR; i++) {> struct uart_8250_port *up = &serial8250_ports[i];> >- if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)>+ if (up->port.type != PORT_UNKNOWN && up->port.dev == dev)> serial8250_resume_port(i);> }> > return 0;> }> >+static struct dev_pm_ops serial8250_pm_ops = {>+ .suspend = serial8250_suspend,>+ .resume = serial8250_resume,>+};>+> static struct platform_driver serial8250_isa_driver = {> .probe = serial8250_probe,> .remove = __devexit_p(serial8250_remove),>- .suspend = serial8250_suspend,>- .resume = serial8250_resume,> .driver = {> .name = "serial8250",> .owner = THIS_MODULE,>+ .pm = &serial8250_pm_ops,
Quoted 1 line
drivers/serial/8250.c>index fb867a9..dcbc6da 100644>--- a/drivers/serial/8250.c>+++ b/drivers/serial/8250.c>@@ -2982,42 +2982,46 @@ static int __devexit serial8250_remove(struct platform_device *dev)> return 0;> }> >-static int serial8250_suspend(struct platform_device *dev, pm_message_t state)>+static int serial8250_suspend(struct device *dev)> {> int i;> > for (i = 0; i < UART_NR; i++) {> struct uart_8250_port *up = &serial8250_ports[i];> >- if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)>+ if (up->port.type != PORT_UNKNOWN && up->port.dev == dev)> uart_suspend_port(&serial8250_reg, &up->port);> }> > return 0;> }> >-static int serial8250_resume(struct platform_device *dev)>+static int serial8250_resume(struct device *dev)> {> int i;> > for (i = 0; i < UART_NR; i++) {> struct uart_8250_port *up = &serial8250_ports[i];> >- if (up->port.type != PORT_UNKNOWN && up->port.dev == &dev->dev)>+ if (up->port.type != PORT_UNKNOWN && up->port.dev == dev)> serial8250_resume_port(i);> }> > return 0;> }> >+static struct dev_pm_ops serial8250_pm_ops = {>+ .suspend = serial8250_suspend,>+ .resume = serial8250_resume,>+};>+> static struct platform_driver serial8250_isa_driver = {> .probe = serial8250_probe,> .remove = __devexit_p(serial8250_remove),>- .suspend = serial8250_suspend,>- .resume = serial8250_resume,> .driver = {> .name = "serial8250",> .owner = THIS_MODULE,>+ .pm = &serial8250_pm_ops, renamed from drivers/serial/8250.c +0
-0
Git warns that there is whitespace at the end of this line...
Quoted 1 line
},> };
Cheers,FJPÿôèº{.nÇ+‰·Ÿ®‰†+%ŠËÿ±éݶ¥Šwÿº{.nÇ+‰·¥Š{±þG«�éÿŠ{ayºÊ‡Ú™ë,j¢f£¢·hš�ï�êÿ‘êçz_è®(階ŠÝ¢j"�ú¶m§ÿÿ¾«þG«�éÿ¢¸?™¨èÚ&£ø§~�á¶iO•æ¬z·švØ^¶m§ÿÿÃÿ¶ìÿ¢¸?–I¥
Quoted 8 lines · On Wed, 8 Jul 2009 13:10:51 +0200 Frans Pop <[email protected]> wrote:
Adding some CCs as there's no reply yet.
Quoted 4 lines
From dmesg:
Platform driver 'serial8250' needs updating - please usedev_pm_opsIs this how it should be done?
Alan or Rafael can probably tell.
No idea. I've not looked at this so your guess is as good as mine (but looks quite believable. I don't plan to do anything until someone who needs platform 8250 support sends a tested version of the change however.
Alan
h
Frans Pop
Reviewed-byQuoted 4 lines · Alan Cox
Quoted 3 lines · On Wed, 8 Jul 2009 Frans Pop <[email protected]> wrote:
Quoted 3 lines
From dmesg:
Platform driver 'serial8250' needs updating - please usedev_pm_ops
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Is this how it should be done?
Alan or Rafael can probably tell.
No idea. I've not looked at this so your guess is as good as mine (but looks quite believable. I don't plan to do anything until someone who needs platform 8250 support sends a tested version of the change however.
I have done a few of these myself now and followed all other similar updates for other drivers. From that experience I can say that this update is both trivial and correct. Hope you will reconsider your reluctance on that basis.
Below Erik's patch with the commit log cleaned up, one whitespace problem fixed and my Reviewed-by added.
Cheers,
FJP
---
From: Erik Ekman <[email protected]>
Subject: serial8250: update to dev_pm_ops
Quoted 1 line
From dmesg:
Platform driver 'serial8250' needs updating - please use dev_pm_ops
drivers/serial/8250.c +10 -6
@@ -2982,42 +2982,46 @@ static int __devexit serial8250_remove(struct platform_device *dev)return 0 ; } -static int serial8250_suspend (struct platform_device *dev,pm_message_t state) +static int serial8250_suspend (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev->dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)uart_suspend_port (&serial8250_reg, &up->port); }return 0 ; } -static int serial8250_resume (struct platform_device *dev) +static int serial8250_resume (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev->dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)serial8250_resume_port (i); }return 0 ; } +static struct dev_pm_ops serial8250_pm_ops = { + .suspend = serial8250_suspend, + .resume = serial8250_resume, +}; +static struct platform_driver serial8250_isa_driver = { .probe = serial8250_probe, .remove =__devexit_p (serial8250_remove), - .suspend = serial8250_suspend, - .resume = serial8250_resume, .driver = { .name ="serial8250" , .owner =THIS_MODULE , + .pm = &serial8250_pm_ops, }, };
Quoted 68 lines · Frans Pop
Quoted 4 lines · Alan Cox
Quoted 3 lines · On Wed, 8 Jul 2009 Frans Pop <[email protected]> wrote:
Quoted 3 lines
From dmesg:
Platform driver 'serial8250' needs updating - please usedev_pm_opsQuoted 8 lines
Quoted 3 lines
Quoted 1 line
Is this how it should be done?
Alan or Rafael can probably tell.
No idea. I've not looked at this so your guess is as good as mine (but looks quite believable. I don't plan to do anything until someone who needs platform 8250 support sends a tested version of the change however.
I have done a few of these myself now and followed all other similar updates for other drivers. From that experience I can say that this update is both trivial and correct. Hope you will reconsider your reluctance on that basis.
Below Erik's patch with the commit log cleaned up, one whitespace problem fixed and my Reviewed-by added.
Cheers,
FJP---
From: Erik Ekman <[email protected]>
Subject: serial8250: update todev_pm_opsFrom dmesg:
Platform driver 'serial8250' needs updating - please usedev_pm_opsSigned-off-by Erik Ekman <[email protected]>Reviewed-by Frans Pop <[email protected]>drivers/serial/8250.c +3
-4@@ -2982,42 +2982,46 @@ static int __devexit serial8250_remove(struct platform_device *dev)return 0 ; } -static int serial8250_suspend (struct platform_device *dev,pm_message_t state) +static int serial8250_suspend (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev->dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)uart_suspend_port (&serial8250_reg, &up->port); }return 0 ; } -static int serial8250_resume (struct platform_device *dev) +static int serial8250_resume (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev->dev)
drivers/serial/8250.c static int __devexit serial8250_remove(struct platform_device *dev) · line 3015
Quoted 10 lines
drivers/serial/8250.c +4
-0+if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)serial8250_resume_port (i); }return 0 ; } +static struct dev_pm_ops serial8250_pm_ops = { + .suspend = serial8250_suspend, + .resume = serial8250_resume,
Please don't forget about hibernation!
drivers/serial/8250.c static int __devexit serial8250_remove(struct platform_device *dev) · line 3026
Quoted 13 lines
drivers/serial/8250.c +3
-2+}; +static struct platform_driver serial8250_isa_driver = { .probe = serial8250_probe, .remove =__devexit_p (serial8250_remove), - .suspend = serial8250_suspend, - .resume = serial8250_resume, .driver = { .name ="serial8250" , .owner =THIS_MODULE , + .pm = &serial8250_pm_ops, }, };
Best,
Rafael
RFC PATCH v2 1/1 serial8250: update to dev_pm_ops
serial8250: update to dev_pm_ops
Quoted 1 line
From dmesg:
Platform driver 'serial8250' needs updating - please use dev_pm_ops
--
Updated to handle hibernation as understood based on info from Rafael J. Wysocki. Please let me know if any special handling is needed.
drivers/serial/8250.c +14 -6
@@ -2982,42 +2982,50 @@ static int __devexit serial8250_remove(struct platform_device *dev)return 0 ; } -static int serial8250_suspend (struct platform_device *dev,pm_message_t state) +static int serial8250_suspend (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev->dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)uart_suspend_port (&serial8250_reg, &up->port); }return 0 ; } -static int serial8250_resume (struct platform_device *dev) +static int serial8250_resume (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev->dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)serial8250_resume_port (i); }return 0 ; } +static struct dev_pm_ops serial8250_pm_ops = { + .resume = serial8250_resume, + .suspend = serial8250_suspend, + .freeze = serial8250_resume, + .thaw = serial8250_suspend, + .restore = serial8250_resume, + .poweroff = serial8250_suspend, +}; +static struct platform_driver serial8250_isa_driver = { .probe = serial8250_probe, .remove =__devexit_p (serial8250_remove), - .suspend = serial8250_suspend, - .resume = serial8250_resume, .driver = { .name ="serial8250" , .owner =THIS_MODULE , + .pm = &serial8250_pm_ops, }, };
Quoted 52 lines · Erik Ekman
serial8250: update to
dev_pm_opsFrom dmesg:
Platform driver 'serial8250' needs updating - please usedev_pm_opsSigned-off-by Erik Ekman <[email protected]>--
Updated to handle hibernation as understood based on info from Rafael J. Wysocki. Please let me know if any special handling is needed.drivers/serial/8250.c +4
-4@@ -2982,42 +2982,50 @@ static int __devexit serial8250_remove (struct platform_device *dev) return 0; } -static int serial8250_suspend (struct platform_device *dev, pm_message_t state) +static int serial8250_suspend (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev- >dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)uart_suspend_port (&serial8250_reg, &up->port); }return 0 ; } -static int serial8250_resume (struct platform_device *dev) +static int serial8250_resume (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev- >dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)serial8250_resume_port (i); }return 0 ;
drivers/serial/8250.c static int __devexit serial8250_remove · line 3024
Quoted 10 lines
drivers/serial/8250.c +8
-0} +static struct dev_pm_ops serial8250_pm_ops = { + .resume = serial8250_resume, + .suspend = serial8250_suspend, + .freeze = serial8250_resume, + .thaw = serial8250_suspend, + .restore = serial8250_resume, + .poweroff = serial8250_suspend, +};
Do we really both freeze and poweroff for serial port? I am getting wary of these mechanical conversions...
Signature · 1 line
Dmitry
Quoted 57 lines · Dmitry Torokhov
Quoted 55 lines · Erik Ekman
serial8250: update to
dev_pm_opsFrom dmesg:
Platform driver 'serial8250' needs updating - please usedev_pm_opsSigned-off-by Erik Ekman <[email protected]>--
Updated to handle hibernation as understood based on info from Rafael J. Wysocki.
Please let me know if any special handling is needed.drivers/serial/8250.c +4
-4@@ -2982,42 +2982,50 @@ static int __devexit serial8250_remove (struct platform_device *dev) return 0; } -static int serial8250_suspend (struct platform_device *dev, pm_message_t state) +static int serial8250_suspend (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev- >dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)uart_suspend_port (&serial8250_reg, &up->port); }return 0 ; } -static int serial8250_resume (struct platform_device *dev) +static int serial8250_resume (struct device *dev) {int i;for (i =0 ; i <UART_NR ; i++) {struct uart_8250_port *up = &serial8250_ports[i]; -if (up->port.type !=PORT_UNKNOWN && up->port.dev == &dev- >dev) +if (up->port.type !=PORT_UNKNOWN && up->port.dev == dev)serial8250_resume_port (i); }return 0 ; }
Quoted 12 lines
drivers/serial/8250.c static int __devexit serial8250_remove(struct platform_device *dev) · line 3020
Quoted 8 lines
drivers/serial/8250.c +8
-0+static struct dev_pm_ops serial8250_pm_ops = { + .resume = serial8250_resume, + .suspend = serial8250_suspend, + .freeze = serial8250_resume, + .thaw = serial8250_suspend, + .restore = serial8250_resume, + .poweroff = serial8250_suspend, +};Do we really both freeze and poweroff for serial port? I am getting wary of these mechanical conversions...
And this one is incorrect, because I made a mistake in one of my previous messages. Obviously _suspend() should not be used for .thaw(), but for .freeze(), and analogously with _resume().
Also, .poweroff() in probably unnecessary and .freeze() is only necessary if there's anything to be saved before hibernation and restored during the subsequent resume.
In fact, I wouldn't advise anyone to do these conversions mechanically.
Best,
Rafael
Quoted 1 line · Rafael J. Wysocki
In fact, I wouldn't advise anyone to do these conversions mechanically.
With hindsight I'd say you are correct.
In that case would it maybe have been better to have a build time warning about the need to convert drivers rather than a run time one? Run time warnings have a much higher annoyance factor and will thus "invite" more people into having a shot at getting rid of them.
But I guess partly it's also just the nature of this change: it looks trivial due to the corresponding terms.
Quoted 5 lines · Frans Pop
Quoted 1 line · Rafael J. Wysocki
In fact, I wouldn't advise anyone to do these conversions mechanically.
With hindsight I'd say you are correct.
Quoted 7 lines
In that case would it maybe have been better to have a build time warning about the need to convert drivers rather than a run time one? Run time warnings have a much higher annoyance factor and will thus "invite" more people into having a shot at getting rid of them.
But I guess partly it's also just the nature of this change: it looks trivial due to the corresponding terms.
Well, in fact the patch that added the warning wasn't mine. :-)
Anyway, the purpose was to get the attention of the people who maintain those drivers mostly, AFAICS.
Best,
Rafael
Quoted 9 lines · Frans Pop
Quoted 1 line · Rafael J. Wysocki
In fact, I wouldn't advise anyone to do these conversions mechanically.
With hindsight I'd say you are correct.
In that case would it maybe have been better to have a build time warning about the need to convert drivers rather than a run time one? Run time warnings have a much higher annoyance factor and will thus "invite" more people into having a shot at getting rid of them.
I'm the one who added the runtime warning and I agree that a build time warning would have been more suitable. Exacly how to implement that in this specific case is another question. I'm open to suggestions. =)
The purpose was simply to move over to the new interface sooner than later.
Quoted 2 lines
But I guess partly it's also just the nature of this change: it looks trivial due to the corresponding terms.
It should be pretty trivial. The tricky part is what gets used when in the cases of CONFIG_HIBERNATION and CONFIG_SUSPEND. The dev_pm_ops comment in include/linux/pm.h should guide people in the right direction.
Thanks for your help!
/ magnus
Quoted 11 lines · Magnus Damm
Quoted 9 lines · Frans Pop
Quoted 1 line · Rafael J. Wysocki
In fact, I wouldn't advise anyone to do these conversions mechanically.
With hindsight I'd say you are correct.
In that case would it maybe have been better to have a build time warning about the need to convert drivers rather than a run time one? Run time warnings have a much higher annoyance factor and will thus "invite" more people into having a shot at getting rid of them.
Quoted 9 lines
I'm the one who added the runtime warning and I agree that a build time warning would have been more suitable. Exacly how to implement that in this specific case is another question. I'm open to suggestions. =)
The purpose was simply to move over to the new interface sooner than later.
Quoted 2 lines
But I guess partly it's also just the nature of this change: it looks trivial due to the corresponding terms.
Yes, that is why I gave it a try. I am trying to learn and looking for stuff to fix this looked like a simple task. I dont have hibernation configured and I am not sure if I have a serial port either so I will leave this to the professionals.
Quoted 10 lines
It should be pretty trivial. The tricky part is what gets used when in the cases of
CONFIG_HIBERNATIONandCONFIG_SUSPEND. Thedev_pm_opscomment ininclude/linux/pm.hshould guide people in the right direction.Thanks for your help!
/ magnus
/Erik
Quoted 15 lines · Frans Pop
Quoted 5 lines · Alan Cox
Quoted 4 lines · On Wed, 8 Jul 2009 Frans Pop <[email protected]> wrote:
Quoted 4 lines
From dmesg:
Platform driver 'serial8250' needs updating - please usedev_pm_opsQuoted 8 lines
Quoted 3 lines
Quoted 1 line
Is this how it should be done?
Alan or Rafael can probably tell.
No idea. I've not looked at this so your guess is as good as mine (but looks quite believable. I don't plan to do anything until someone who needs platform 8250 support sends a tested version of the change however.
Quoted 4 lines
I have done a few of these myself now and followed all other similar updates for other drivers. From that experience I can say that this update is both trivial and correct. Hope you will reconsider your reluctance on that basis.
Please cancel that. It turns out that the old system also supported suspend to disk, which most driver conversions so far did not allow for.
Kudo's to Dmitry Torokhov for bringing this up.
Sorry.