public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 2.6.10-rc1-bk] shrink struct device a bit
@ 2004-11-05  3:37 David Brownell
  2004-11-07 10:54 ` Russell King
  0 siblings, 1 reply; 4+ messages in thread
From: David Brownell @ 2004-11-05  3:37 UTC (permalink / raw)
  To: Greg KH, Russell King; +Cc: Linux Kernel list

[-- Attachment #1: Type: text/plain, Size: 96 bytes --]

Two fields were duplicates of ones in the PM struct,
and weren't much used in any case.

- Dave

[-- Attachment #2: shrink-1104.patch --]
[-- Type: text/x-diff, Size: 4065 bytes --]

This patch removes two fields from "struct device" that are duplicated
in "struct dev_pm_info":  power_state (which should probably vanish)
and "saved_state".  There were only two "real" uses of saved_state;
both are now switched over to use dev_pm_info.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>

--- 1.131/include/linux/device.h	Mon Nov  1 12:46:20 2004
+++ edited/include/linux/device.h	Thu Nov  4 12:59:02 2004
@@ -268,12 +268,7 @@
 	void		*platform_data;	/* Platform specific data (e.g. ACPI,
 					   BIOS data relevant to device) */
 	struct dev_pm_info	power;
-	u32		power_state;	/* Current operating state. In
-					   ACPI-speak, this is D0-D3, D0
-					   being fully functional, and D3
-					   being off. */
 
-	unsigned char *saved_state;	/* saved device state */
 	u32		detach_state;	/* State to enter when device is
 					   detached from its driver. */
 
--- 1.1/arch/arm/common/locomo.c	Wed Jul  7 17:00:00 2004
+++ edited/arch/arm/common/locomo.c	Thu Nov  4 13:23:44 2004
@@ -629,9 +629,6 @@
 	if (lchip) {
 		__locomo_remove(lchip);
 		dev_set_drvdata(dev, NULL);
-
-		kfree(dev->saved_state);
-		dev->saved_state = NULL;
 	}
 
 	return 0;
--- 1.41/arch/arm/common/sa1111.c	Tue Sep 28 11:27:43 2004
+++ edited/arch/arm/common/sa1111.c	Thu Nov  4 13:30:27 2004
@@ -797,6 +797,8 @@
 	unsigned int	wakeen1;
 };
 
+#ifdef	CONFIG_PM
+
 static int sa1111_suspend(struct device *dev, u32 state, u32 level)
 {
 	struct sa1111 *sachip = dev_get_drvdata(dev);
@@ -808,11 +810,10 @@
 	if (level != SUSPEND_DISABLE)
 		return 0;
 
-	dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
-	if (!dev->saved_state)
+	save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
+	if (!save)
 		return -ENOMEM;
-
-	save = (struct sa1111_save_data *)dev->saved_state;
+	dev->power.saved_state = save;
 
 	spin_lock_irqsave(&sachip->lock, flags);
 
@@ -870,7 +871,7 @@
 	if (level != RESUME_ENABLE)
 		return 0;
 
-	save = (struct sa1111_save_data *)dev->saved_state;
+	save = (struct sa1111_save_data *)dev->power.saved_state;
 	if (!save)
 		return 0;
 
@@ -915,12 +916,18 @@
 
 	spin_unlock_irqrestore(&sachip->lock, flags);
 
-	dev->saved_state = NULL;
+	dev->power.saved_state = NULL;
 	kfree(save);
 
 	return 0;
 }
 
+#else	/* !CONFIG_PM */
+#define sa1111_resume	0
+#define sa1111_suspend	0
+#endif	/* !CONFIG_PM */
+
+
 static int sa1111_probe(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -943,8 +950,8 @@
 		__sa1111_remove(sachip);
 		dev_set_drvdata(dev, NULL);
 
-		kfree(dev->saved_state);
-		dev->saved_state = NULL;
+		kfree(dev->power.saved_state);
+		dev->power.saved_state = NULL;
 	}
 
 	return 0;
--- 1.22/arch/arm/mach-sa1100/neponset.c	Thu Mar 25 09:43:01 2004
+++ edited/arch/arm/mach-sa1100/neponset.c	Thu Nov  4 13:22:34 2004
@@ -173,6 +173,8 @@
 	return 0;
 }
 
+#ifdef CONFIG_PM
+
 /*
  * LDM power management.
  */
@@ -184,12 +186,12 @@
 	if (level == SUSPEND_SAVE_STATE ||
 	    level == SUSPEND_DISABLE ||
 	    level == SUSPEND_POWER_DOWN) {
-		if (!dev->saved_state)
-			dev->saved_state = kmalloc(sizeof(unsigned int), GFP_KERNEL);
-		if (!dev->saved_state)
+		if (!dev->power.saved_state)
+			dev->power.saved_state = kmalloc(sizeof(unsigned int), GFP_KERNEL);
+		if (!dev->power.saved_state)
 			return -ENOMEM;
 
-		*(unsigned int *)dev->saved_state = NCR_0;
+		*(unsigned int *)dev->power.saved_state = NCR_0;
 	}
 
 	return 0;
@@ -198,15 +200,20 @@
 static int neponset_resume(struct device *dev, u32 level)
 {
 	if (level == RESUME_RESTORE_STATE || level == RESUME_ENABLE) {
-		if (dev->saved_state) {
-			NCR_0 = *(unsigned int *)dev->saved_state;
-			kfree(dev->saved_state);
-			dev->saved_state = NULL;
+		if (dev->power.saved_state) {
+			NCR_0 = *(unsigned int *)dev->power.saved_state;
+			kfree(dev->power.saved_state);
+			dev->power.saved_state = NULL;
 		}
 	}
 
 	return 0;
 }
+
+#else
+#define	neponset_suspend	0
+#define	neponset_resume	0
+#endif
 
 static struct device_driver neponset_device_driver = {
 	.name		= "neponset",

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

* Re: [patch 2.6.10-rc1-bk] shrink struct device a bit
  2004-11-05  3:37 [patch 2.6.10-rc1-bk] shrink struct device a bit David Brownell
@ 2004-11-07 10:54 ` Russell King
  2004-11-08  1:52   ` David Brownell
  0 siblings, 1 reply; 4+ messages in thread
From: Russell King @ 2004-11-07 10:54 UTC (permalink / raw)
  To: David Brownell; +Cc: Greg KH, Linux Kernel list

On Thu, Nov 04, 2004 at 08:37:31PM -0700, David Brownell wrote:
> Two fields were duplicates of ones in the PM struct,
> and weren't much used in any case.

> +#else	/* !CONFIG_PM */
> +#define sa1111_resume	0
> +#define sa1111_suspend	0
...
> +#else
> +#define	neponset_suspend	0
> +#define	neponset_resume	0
> +#endif

I think sparse will complain at being given '0' instead of 'NULL' for
pointers.  Please use NULL instead.

-- 
Russell King
 Linux kernel    2.6 ARM Linux   - http://www.arm.linux.org.uk/
 maintainer of:  2.6 PCMCIA      - http://pcmcia.arm.linux.org.uk/
                 2.6 Serial core

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

* Re: [patch 2.6.10-rc1-bk] shrink struct device a bit
  2004-11-07 10:54 ` Russell King
@ 2004-11-08  1:52   ` David Brownell
  2004-11-12 20:49     ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: David Brownell @ 2004-11-08  1:52 UTC (permalink / raw)
  To: Russell King; +Cc: Greg KH, Linux Kernel list

[-- Attachment #1: Type: text/plain, Size: 316 bytes --]

On Sunday 07 November 2004 02:54, Russell King wrote:
> I think sparse will complain at being given '0' instead of 'NULL' for
> pointers.  Please use NULL instead.

Attached.

- Dave

p.s. The SA-1111 + PXA build combo was broken (as on "Lubbock"),
     as you likely know if you're removing broken machine configs!

[-- Attachment #2: shrink-1104a.patch --]
[-- Type: text/x-diff, Size: 4077 bytes --]

This patch removes two fields from "struct device" that are duplicated
in "struct dev_pm_info":  power_state (which should probably vanish)
and "saved_state".  There were only two "real" uses of saved_state;
both are now switched over to use dev_pm_info.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>

--- 1.131/include/linux/device.h	Mon Nov  1 12:46:20 2004
+++ edited/include/linux/device.h	Thu Nov  4 12:59:02 2004
@@ -268,12 +268,7 @@
 	void		*platform_data;	/* Platform specific data (e.g. ACPI,
 					   BIOS data relevant to device) */
 	struct dev_pm_info	power;
-	u32		power_state;	/* Current operating state. In
-					   ACPI-speak, this is D0-D3, D0
-					   being fully functional, and D3
-					   being off. */
 
-	unsigned char *saved_state;	/* saved device state */
 	u32		detach_state;	/* State to enter when device is
 					   detached from its driver. */
 
--- 1.1/arch/arm/common/locomo.c	Wed Jul  7 17:00:00 2004
+++ edited/arch/arm/common/locomo.c	Thu Nov  4 13:23:44 2004
@@ -629,9 +629,6 @@
 	if (lchip) {
 		__locomo_remove(lchip);
 		dev_set_drvdata(dev, NULL);
-
-		kfree(dev->saved_state);
-		dev->saved_state = NULL;
 	}
 
 	return 0;
--- 1.41/arch/arm/common/sa1111.c	Tue Sep 28 11:27:43 2004
+++ edited/arch/arm/common/sa1111.c	Thu Nov  4 13:30:27 2004
@@ -797,6 +797,8 @@
 	unsigned int	wakeen1;
 };
 
+#ifdef	CONFIG_PM
+
 static int sa1111_suspend(struct device *dev, u32 state, u32 level)
 {
 	struct sa1111 *sachip = dev_get_drvdata(dev);
@@ -808,11 +810,10 @@
 	if (level != SUSPEND_DISABLE)
 		return 0;
 
-	dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
-	if (!dev->saved_state)
+	save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
+	if (!save)
 		return -ENOMEM;
-
-	save = (struct sa1111_save_data *)dev->saved_state;
+	dev->power.saved_state = save;
 
 	spin_lock_irqsave(&sachip->lock, flags);
 
@@ -870,7 +871,7 @@
 	if (level != RESUME_ENABLE)
 		return 0;
 
-	save = (struct sa1111_save_data *)dev->saved_state;
+	save = (struct sa1111_save_data *)dev->power.saved_state;
 	if (!save)
 		return 0;
 
@@ -915,12 +916,18 @@
 
 	spin_unlock_irqrestore(&sachip->lock, flags);
 
-	dev->saved_state = NULL;
+	dev->power.saved_state = NULL;
 	kfree(save);
 
 	return 0;
 }
 
+#else	/* !CONFIG_PM */
+#define sa1111_resume	NULL
+#define sa1111_suspend	NULL
+#endif	/* !CONFIG_PM */
+
+
 static int sa1111_probe(struct device *dev)
 {
 	struct platform_device *pdev = to_platform_device(dev);
@@ -943,8 +950,8 @@
 		__sa1111_remove(sachip);
 		dev_set_drvdata(dev, NULL);
 
-		kfree(dev->saved_state);
-		dev->saved_state = NULL;
+		kfree(dev->power.saved_state);
+		dev->power.saved_state = NULL;
 	}
 
 	return 0;
--- 1.22/arch/arm/mach-sa1100/neponset.c	Thu Mar 25 09:43:01 2004
+++ edited/arch/arm/mach-sa1100/neponset.c	Thu Nov  4 13:22:34 2004
@@ -173,6 +173,8 @@
 	return 0;
 }
 
+#ifdef CONFIG_PM
+
 /*
  * LDM power management.
  */
@@ -184,12 +186,12 @@
 	if (level == SUSPEND_SAVE_STATE ||
 	    level == SUSPEND_DISABLE ||
 	    level == SUSPEND_POWER_DOWN) {
-		if (!dev->saved_state)
-			dev->saved_state = kmalloc(sizeof(unsigned int), GFP_KERNEL);
-		if (!dev->saved_state)
+		if (!dev->power.saved_state)
+			dev->power.saved_state = kmalloc(sizeof(unsigned int), GFP_KERNEL);
+		if (!dev->power.saved_state)
 			return -ENOMEM;
 
-		*(unsigned int *)dev->saved_state = NCR_0;
+		*(unsigned int *)dev->power.saved_state = NCR_0;
 	}
 
 	return 0;
@@ -198,15 +200,20 @@
 static int neponset_resume(struct device *dev, u32 level)
 {
 	if (level == RESUME_RESTORE_STATE || level == RESUME_ENABLE) {
-		if (dev->saved_state) {
-			NCR_0 = *(unsigned int *)dev->saved_state;
-			kfree(dev->saved_state);
-			dev->saved_state = NULL;
+		if (dev->power.saved_state) {
+			NCR_0 = *(unsigned int *)dev->power.saved_state;
+			kfree(dev->power.saved_state);
+			dev->power.saved_state = NULL;
 		}
 	}
 
 	return 0;
 }
+
+#else
+#define	neponset_suspend	NULL
+#define	neponset_resume	NULL
+#endif
 
 static struct device_driver neponset_device_driver = {
 	.name		= "neponset",

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

* Re: [patch 2.6.10-rc1-bk] shrink struct device a bit
  2004-11-08  1:52   ` David Brownell
@ 2004-11-12 20:49     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2004-11-12 20:49 UTC (permalink / raw)
  To: David Brownell; +Cc: Russell King, Linux Kernel list

On Sun, Nov 07, 2004 at 06:52:05PM -0700, David Brownell wrote:
> On Sunday 07 November 2004 02:54, Russell King wrote:
> > I think sparse will complain at being given '0' instead of 'NULL' for
> > pointers.  Please use NULL instead.
> 
> Attached.
> 
> - Dave
> 
> p.s. The SA-1111 + PXA build combo was broken (as on "Lubbock"),
>      as you likely know if you're removing broken machine configs!

> This patch removes two fields from "struct device" that are duplicated
> in "struct dev_pm_info":  power_state (which should probably vanish)
> and "saved_state".  There were only two "real" uses of saved_state;
> both are now switched over to use dev_pm_info.

Applied, thanks.

Oh, I also fixed up the video drivers that were also using this field.

greg k-h

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

end of thread, other threads:[~2004-11-12 21:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-05  3:37 [patch 2.6.10-rc1-bk] shrink struct device a bit David Brownell
2004-11-07 10:54 ` Russell King
2004-11-08  1:52   ` David Brownell
2004-11-12 20:49     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox