PM: Do not use saved_state from struct dev_pm_info on ARM (was: Re: patch pm-remove-saved_state-from-struct-dev_pm_info.patch added to gregkh-2.6 tree)
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
RFC PATCH 1/1 PM: Do not use saved_state from struct dev_pm_info on ARM (was: Re: patch pm-remove-saved_state-from-struct-dev_pm_info.patch added to gregkh-2.6 tree)
Quoted 26 lines · Greg KH
Quoted 25 lines · Rafael J. Wysocki
Quoted 24 lines · On Friday, 15 June 2007 00:57, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
Subject: PM: Remove
saved_statefrom structdev_pm_infoto my gregkh-2.6 tree. Its filename is
pm-remove-saved_state-from-struct-dev_pm_info.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/From [email protected] Thu Jun 14 15:47:15 2007
From: "Rafael J. Wysocki" <[email protected]>
To: Andrew Morton <[email protected]>
Subject: PM: Removesaved_statefrom structdev_pm_info
Date: Wed, 13 Jun 2007 15:55:34 +0200
Cc: Alan Stern <[email protected]>, David Brownell <[email protected]>, Greg KH <[email protected]>, Pavel Machek <[email protected]>
Content-Disposition: inline
Message-Id: <[email protected]>From: Rafael J. Wysocki <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
The
saved_statemember of structdev_pm_info, defined ininclude/linux/pm.h, is not used anywhere, so it can be removed.Unfortunately this is wrong, as I've just found three drivers in the ARM tree that use it. I don't know why I didn't see them when I was creating the patch, though. :-(
Why not just fix up the ARM drivers instead?
OK, let's try. :-)
The following patch has only been compilation tested.
---
From: Rafael J. Wysocki <[email protected]>
The saved_state member of 'struct dev_pm_info' that's going to be removed is used in arch/arm/common/locomo.c, arch/arm/common/sa1111.c and arch/arm/mach-sa1100/neponset.c. Change the code in there to use local variables for saving the state of devices during suspend.
--- arch/arm/common/locomo.c | 17 +++-------------- arch/arm/common/sa1111.c | 12 +++++++----- arch/arm/mach-sa1100/neponset.c | 15 ++++----------- 3 files changed, 14 insertions(+), 30 deletions(-)
arch/arm/common/locomo.c +3 -14
@@ -553,20 +553,14 @@ struct locomo_save_data {u16 LCM_GPE ;u16 LCM_ASD ;u16 LCM_SPIMD ; -}; +} locomo_saved_state;static int locomo_suspend (struct platform_device *dev,pm_message_t state) {struct locomo *lchip =platform_get_drvdata (dev); -struct locomo_save_data *save; +struct locomo_save_data *save = &locomo_saved_state;unsigned long flags; - save =kmalloc (sizeof (struct locomo_save_data ),GFP_KERNEL ); -if (!save) -return -ENOMEM ; - - dev->dev.power.saved_state = (void *) save; -spin_lock_irqsave (&lchip->lock, flags); save->LCM_GPO =locomo_readl (lchip->base +LOCOMO_GPO );/* GPIO */
@@ -602,13 +596,9 @@ static int locomo_suspend(struct platforstatic int locomo_resume (struct platform_device *dev) {struct locomo *lchip =platform_get_drvdata (dev); -struct locomo_save_data *save; +struct locomo_save_data *save = &locomo_saved_state;unsigned long r;unsigned long flags; - - save = (struct locomo_save_data *) dev->dev.power.saved_state; -if (!save) -return 0 ;spin_lock_irqsave (&lchip->lock, flags);
@@ -628,7 +618,6 @@ static int locomo_resume(struct platformlocomo_writel (0x1 , lchip->base +LOCOMO_KEYBOARD +LOCOMO_KCMD );spin_unlock_irqrestore (&lchip->lock, flags); -kfree (save);return 0 ; }
arch/arm/common/sa1111.c +7 -5
@@ -811,6 +811,8 @@ struct sa1111_save_data {#ifdef CONFIG_PM +static struct sa1111_save_data *sa1111_saved_state; +static int sa1111_suspend (struct platform_device *dev,pm_message_t state) {struct sa1111 *sachip =platform_get_drvdata (dev);
@@ -822,7 +824,7 @@ static int sa1111_suspend(struct platfor save =kmalloc (sizeof (struct sa1111_save_data ),GFP_KERNEL );if (!save)return -ENOMEM ; - dev->dev.power.saved_state = save; + sa1111_saved_state = save;spin_lock_irqsave (&sachip->lock, flags);
@@ -878,7 +880,7 @@ static int sa1111_resume(struct platformunsigned long flags, id;void __iomem *base; - save = (struct sa1111_save_data *)dev->dev.power.saved_state; + save = sa1111_saved_state;if (!save)return 0 ;
@@ -923,7 +925,7 @@ static int sa1111_resume(struct platformspin_unlock_irqrestore (&sachip->lock, flags); - dev->dev.power.saved_state =NULL ; + sa1111_saved_state =NULL ;kfree (save);return 0 ;
@@ -958,8 +960,8 @@ static int sa1111_remove(struct platformplatform_set_drvdata (pdev,NULL );#ifdef CONFIG_PM -kfree (pdev->dev.power.saved_state); - pdev->dev.power.saved_state =NULL ; +kfree (sa1111_saved_state); + sa1111_saved_state =NULL ;#endif }
arch/arm/mach-sa1100/neponset.c +4 -11
@@ -185,28 +185,21 @@ static int __devinit neponset_probe(stru/* * LDM power management. */ +static unsigned int neponset_saved_state; +static int neponset_suspend (struct platform_device *dev,pm_message_t state) {/* * Save state. */ -if (!dev->dev.power.saved_state) - dev->dev.power.saved_state =kmalloc (sizeof (unsigned int ),GFP_KERNEL ); -if (!dev->dev.power.saved_state) -return -ENOMEM ; - - *(unsigned int *)dev->dev.power.saved_state =NCR_0 ; + neponset_saved_state =NCR_0 ;return 0 ; }static int neponset_resume (struct platform_device *dev) { -if (dev->dev.power.saved_state) { -NCR_0 = *(unsigned int *)dev->dev.power.saved_state; -kfree (dev->dev.power.saved_state); - dev->dev.power.saved_state =NULL ; - } +NCR_0 = neponset_saved_state;return 0 ; }
Quoted 43 lines · Rafael J. Wysocki
Quoted 26 lines · Greg KH
Quoted 25 lines · Rafael J. Wysocki
Quoted 24 lines · On Friday, 15 June 2007 00:57, [email protected] wrote:
This is a note to let you know that I've just added the patch titled
Subject: PM: Remove
saved_statefrom structdev_pm_infoto my gregkh-2.6 tree. Its filename is
pm-remove-saved_state-from-struct-dev_pm_info.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/From [email protected] Thu Jun 14 15:47:15 2007
From: "Rafael J. Wysocki" <[email protected]>
To: Andrew Morton <[email protected]>
Subject: PM: Removesaved_statefrom structdev_pm_info
Date: Wed, 13 Jun 2007 15:55:34 +0200
Cc: Alan Stern <[email protected]>, David Brownell <[email protected]>, Greg KH <[email protected]>, Pavel Machek <[email protected]>
Content-Disposition: inline
Message-Id: <[email protected]>From: Rafael J. Wysocki <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
The
saved_statemember of structdev_pm_info, defined ininclude/linux/pm.h, is not used anywhere, so it can be removed.Unfortunately this is wrong, as I've just found three drivers in the ARM tree that use it. I don't know why I didn't see them when I was creating the patch, though. :-(
Why not just fix up the ARM drivers instead?
OK, let's try. :-)
The following patch has only been compilation tested.
---
From: Rafael J. Wysocki <[email protected]>
Quoted 6 lines
The
saved_statemember of 'structdev_pm_info' that's going to be removed is used inarch/arm/common/locomo.c,arch/arm/common/sa1111.candarch/arm/mach-sa1100/neponset.c. Change the code in there to use local variables for saving the state of devices during suspend.Signed-off-by Rafael J. Wysocki <[email protected]>
Russell says that the affected drivers were coded to support multiple instances of the same device which the $subject patch doesn't take into account (still, as far as the neponset is concerned, I think that there can be only one instance of NCR_0 in the system).
Updated (compilation tested) patch follows.
Greetings,
Rafael
---
From: Rafael J. Wysocki <[email protected]>
The saved_state member of 'struct dev_pm_info' that's going to be removed is used in arch/arm/common/locomo.c, arch/arm/common/sa1111.c and arch/arm/mach-sa1100/neponset.c. Change the code in there to use the drivers' own per-device data structures or static variables for saving the state of devices during suspend.
--- arch/arm/common/locomo.c | 9 +++++++-- arch/arm/common/sa1111.c | 13 ++++++++----- arch/arm/mach-sa1100/neponset.c | 15 ++++----------- 3 files changed, 19 insertions(+), 18 deletions(-)
arch/arm/common/locomo.c +7 -2
@@ -60,6 +60,9 @@ struct locomo {unsigned int irq;spinlock_t lock;void __iomem *base; +#ifdef CONFIG_PM +void *saved_state; +#endif };struct locomo_dev_info {
@@ -565,7 +568,7 @@ static int locomo_suspend(struct platforif (!save)return -ENOMEM ; - dev->dev.power.saved_state = (void *) save; + lchip->saved_state = save;spin_lock_irqsave (&lchip->lock, flags);
@@ -606,7 +609,7 @@ static int locomo_resume(struct platformunsigned long r;unsigned long flags; - save = (struct locomo_save_data *) dev->dev.power.saved_state; + save = lchip->saved_state;if (!save)return 0 ;
@@ -628,6 +631,8 @@ static int locomo_resume(struct platformlocomo_writel (0x1 , lchip->base +LOCOMO_KEYBOARD +LOCOMO_KCMD );spin_unlock_irqrestore (&lchip->lock, flags); + + lchip->saved_state =NULL ;kfree (save);return 0 ;
arch/arm/common/sa1111.c +8 -5
@@ -51,6 +51,9 @@ struct sa1111 {int irq;spinlock_t lock;void __iomem *base; +#ifdef CONFIG_PM +void *saved_state; +#endif };/*
@@ -822,7 +825,7 @@ static int sa1111_suspend(struct platfor save =kmalloc (sizeof (struct sa1111_save_data ),GFP_KERNEL );if (!save)return -ENOMEM ; - dev->dev.power.saved_state = save; + sachip->saved_state = save;spin_lock_irqsave (&sachip->lock, flags);
@@ -878,7 +881,7 @@ static int sa1111_resume(struct platformunsigned long flags, id;void __iomem *base; - save = (struct sa1111_save_data *)dev->dev.power.saved_state; + save = sachip->saved_state;if (!save)return 0 ;
@@ -923,7 +926,7 @@ static int sa1111_resume(struct platformspin_unlock_irqrestore (&sachip->lock, flags); - dev->dev.power.saved_state =NULL ; + sachip->saved_state =NULL ;kfree (save);return 0 ;
@@ -958,8 +961,8 @@ static int sa1111_remove(struct platformplatform_set_drvdata (pdev,NULL );#ifdef CONFIG_PM -kfree (pdev->dev.power.saved_state); - pdev->dev.power.saved_state =NULL ; +kfree (sachip->saved_state); + sachip->saved_state =NULL ;#endif }
arch/arm/mach-sa1100/neponset.c +4 -11
@@ -185,28 +185,21 @@ static int __devinit neponset_probe(stru/* * LDM power management. */ +static unsigned int neponset_saved_state; +static int neponset_suspend (struct platform_device *dev,pm_message_t state) {/* * Save state. */ -if (!dev->dev.power.saved_state) - dev->dev.power.saved_state =kmalloc (sizeof (unsigned int ),GFP_KERNEL ); -if (!dev->dev.power.saved_state) -return -ENOMEM ; - - *(unsigned int *)dev->dev.power.saved_state =NCR_0 ; + neponset_saved_state =NCR_0 ;return 0 ; }static int neponset_resume (struct platform_device *dev) { -if (dev->dev.power.saved_state) { -NCR_0 = *(unsigned int *)dev->dev.power.saved_state; -kfree (dev->dev.power.saved_state); - dev->dev.power.saved_state =NULL ; - } +NCR_0 = neponset_saved_state;return 0 ; }