Commit 05997f16 authored by David Brownell's avatar David Brownell Committed by Greg Kroah-Hartman

[PATCH] driver core: shrink struct device a bit

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: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 5240bcbf
...@@ -627,9 +627,6 @@ static int locomo_remove(struct device *dev) ...@@ -627,9 +627,6 @@ static int locomo_remove(struct device *dev)
if (lchip) { if (lchip) {
__locomo_remove(lchip); __locomo_remove(lchip);
dev_set_drvdata(dev, NULL); dev_set_drvdata(dev, NULL);
kfree(dev->saved_state);
dev->saved_state = NULL;
} }
return 0; return 0;
......
...@@ -797,6 +797,8 @@ struct sa1111_save_data { ...@@ -797,6 +797,8 @@ struct sa1111_save_data {
unsigned int wakeen1; unsigned int wakeen1;
}; };
#ifdef CONFIG_PM
static int sa1111_suspend(struct device *dev, u32 state, u32 level) static int sa1111_suspend(struct device *dev, u32 state, u32 level)
{ {
struct sa1111 *sachip = dev_get_drvdata(dev); struct sa1111 *sachip = dev_get_drvdata(dev);
...@@ -808,11 +810,10 @@ static int sa1111_suspend(struct device *dev, u32 state, u32 level) ...@@ -808,11 +810,10 @@ static int sa1111_suspend(struct device *dev, u32 state, u32 level)
if (level != SUSPEND_DISABLE) if (level != SUSPEND_DISABLE)
return 0; return 0;
dev->saved_state = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL); save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
if (!dev->saved_state) if (!save)
return -ENOMEM; return -ENOMEM;
dev->power.saved_state = save;
save = (struct sa1111_save_data *)dev->saved_state;
spin_lock_irqsave(&sachip->lock, flags); spin_lock_irqsave(&sachip->lock, flags);
...@@ -870,7 +871,7 @@ static int sa1111_resume(struct device *dev, u32 level) ...@@ -870,7 +871,7 @@ static int sa1111_resume(struct device *dev, u32 level)
if (level != RESUME_ENABLE) if (level != RESUME_ENABLE)
return 0; return 0;
save = (struct sa1111_save_data *)dev->saved_state; save = (struct sa1111_save_data *)dev->power.saved_state;
if (!save) if (!save)
return 0; return 0;
...@@ -915,12 +916,18 @@ static int sa1111_resume(struct device *dev, u32 level) ...@@ -915,12 +916,18 @@ static int sa1111_resume(struct device *dev, u32 level)
spin_unlock_irqrestore(&sachip->lock, flags); spin_unlock_irqrestore(&sachip->lock, flags);
dev->saved_state = NULL; dev->power.saved_state = NULL;
kfree(save); kfree(save);
return 0; return 0;
} }
#else /* !CONFIG_PM */
#define sa1111_resume NULL
#define sa1111_suspend NULL
#endif /* !CONFIG_PM */
static int sa1111_probe(struct device *dev) static int sa1111_probe(struct device *dev)
{ {
struct platform_device *pdev = to_platform_device(dev); struct platform_device *pdev = to_platform_device(dev);
...@@ -943,8 +950,8 @@ static int sa1111_remove(struct device *dev) ...@@ -943,8 +950,8 @@ static int sa1111_remove(struct device *dev)
__sa1111_remove(sachip); __sa1111_remove(sachip);
dev_set_drvdata(dev, NULL); dev_set_drvdata(dev, NULL);
kfree(dev->saved_state); kfree(dev->power.saved_state);
dev->saved_state = NULL; dev->power.saved_state = NULL;
} }
return 0; return 0;
......
...@@ -173,6 +173,8 @@ static int neponset_probe(struct device *dev) ...@@ -173,6 +173,8 @@ static int neponset_probe(struct device *dev)
return 0; return 0;
} }
#ifdef CONFIG_PM
/* /*
* LDM power management. * LDM power management.
*/ */
...@@ -184,12 +186,12 @@ static int neponset_suspend(struct device *dev, u32 state, u32 level) ...@@ -184,12 +186,12 @@ static int neponset_suspend(struct device *dev, u32 state, u32 level)
if (level == SUSPEND_SAVE_STATE || if (level == SUSPEND_SAVE_STATE ||
level == SUSPEND_DISABLE || level == SUSPEND_DISABLE ||
level == SUSPEND_POWER_DOWN) { level == SUSPEND_POWER_DOWN) {
if (!dev->saved_state) if (!dev->power.saved_state)
dev->saved_state = kmalloc(sizeof(unsigned int), GFP_KERNEL); dev->power.saved_state = kmalloc(sizeof(unsigned int), GFP_KERNEL);
if (!dev->saved_state) if (!dev->power.saved_state)
return -ENOMEM; return -ENOMEM;
*(unsigned int *)dev->saved_state = NCR_0; *(unsigned int *)dev->power.saved_state = NCR_0;
} }
return 0; return 0;
...@@ -198,16 +200,21 @@ static int neponset_suspend(struct device *dev, u32 state, u32 level) ...@@ -198,16 +200,21 @@ static int neponset_suspend(struct device *dev, u32 state, u32 level)
static int neponset_resume(struct device *dev, u32 level) static int neponset_resume(struct device *dev, u32 level)
{ {
if (level == RESUME_RESTORE_STATE || level == RESUME_ENABLE) { if (level == RESUME_RESTORE_STATE || level == RESUME_ENABLE) {
if (dev->saved_state) { if (dev->power.saved_state) {
NCR_0 = *(unsigned int *)dev->saved_state; NCR_0 = *(unsigned int *)dev->power.saved_state;
kfree(dev->saved_state); kfree(dev->power.saved_state);
dev->saved_state = NULL; dev->power.saved_state = NULL;
} }
} }
return 0; return 0;
} }
#else
#define neponset_suspend NULL
#define neponset_resume NULL
#endif
static struct device_driver neponset_device_driver = { static struct device_driver neponset_device_driver = {
.name = "neponset", .name = "neponset",
.bus = &platform_bus_type, .bus = &platform_bus_type,
......
...@@ -268,12 +268,7 @@ struct device { ...@@ -268,12 +268,7 @@ struct device {
void *platform_data; /* Platform specific data (e.g. ACPI, void *platform_data; /* Platform specific data (e.g. ACPI,
BIOS data relevant to device) */ BIOS data relevant to device) */
struct dev_pm_info power; 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 u32 detach_state; /* State to enter when device is
detached from its driver. */ detached from its driver. */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment