Skip to contentSkip to conversation

swsusp: Do not use pm_ops

PATCH In review Rafael J. Wysocki 4 participants 23 messages May 2, 2007 – May 3, 2007

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 swsusp: Do not use pm_ops

From: Rafael J. Wysocki <[email protected]>, Johannes Berg <[email protected]>

Separate the hibernation (aka suspend to disk code) from the other suspend code. In particular:
* remove the definition related to hibernation (aka suspend to disk) from include/linux/pm.h
* introduce struct hibernation_ops and a new hibernate() function to hibernate the system, defined in include/linux/suspend.h
* separate suspend code in kernel/power/main.c from hibernation-related code in kernel/power/disk.c and kernel/power/user.c (with the help of hibernation_ops)
* switch ACPI (the only user of pm_ops.pm_disk_mode) to hibernation_ops

---

 Documentation/power/userland-swsusp.txt |   26 ++--
 drivers/acpi/sleep/main.c               |   67 +++++++++--
 drivers/acpi/sleep/proc.c               |    2 
 drivers/i2c/chips/tps65010.c            |    2 
 include/linux/pm.h                      |   31 -----
 include/linux/suspend.h                 |   32 +++++
 kernel/power/disk.c                     |  186 +++++++++++++++++---------------
 kernel/power/main.c                     |   42 ++-----
 kernel/power/power.h                    |    7 -
 kernel/power/user.c                     |   13 +-
 kernel/sys.c                            |    2 
 11 files changed, 225 insertions(+), 185 deletions(-)
include/linux/pm.h +1 -30
Index: linux-2.6.21/include/linux/pm.h
===================================================================
@@ -107,26 +107,11 @@ typedef int __bitwise suspend_state_t;
 #define PM_SUSPEND_ON		((__force suspend_state_t) 0)
 #define PM_SUSPEND_STANDBY	((__force suspend_state_t) 1)
 #define PM_SUSPEND_MEM		((__force suspend_state_t) 3)
-#define PM_SUSPEND_DISK		((__force suspend_state_t) 4)
-#define PM_SUSPEND_MAX		((__force suspend_state_t) 5)
-
-typedef int __bitwise suspend_disk_method_t;
-
-/* invalid must be 0 so struct pm_ops initialisers can leave it out */
-#define PM_DISK_INVALID		((__force suspend_disk_method_t) 0)
-#define	PM_DISK_PLATFORM	((__force suspend_disk_method_t) 1)
-#define	PM_DISK_SHUTDOWN	((__force suspend_disk_method_t) 2)
-#define	PM_DISK_REBOOT		((__force suspend_disk_method_t) 3)
-#define	PM_DISK_TEST		((__force suspend_disk_method_t) 4)
-#define	PM_DISK_TESTPROC	((__force suspend_disk_method_t) 5)
-#define	PM_DISK_MAX		((__force suspend_disk_method_t) 6)
+#define PM_SUSPEND_MAX		((__force suspend_state_t) 4)
 
 /**
  * struct pm_ops - Callbacks for managing platform dependent suspend states.
  * @valid: Callback to determine whether the given state can be entered.
- * 	If %CONFIG_SOFTWARE_SUSPEND is set then %PM_SUSPEND_DISK is
- *	always valid and never passed to this call. If not assigned,
- *	no suspend states are valid.
  *	Valid states are advertised in /sys/power/state but can still
  *	be rejected by prepare or enter if the conditions aren't right.
  *	There is a %pm_valid_only_mem function available that can be assigned
@@ -140,24 +125,12 @@ typedef int __bitwise suspend_disk_metho
  *
  * @finish: Called when the system has left the given state and all devices
  *	are resumed. The return value is ignored.
- *
- * @pm_disk_mode: The generic code always allows one of the shutdown methods
- *	%PM_DISK_SHUTDOWN, %PM_DISK_REBOOT, %PM_DISK_TEST and
- *	%PM_DISK_TESTPROC. If this variable is set, the mode it is set
- *	to is allowed in addition to those modes and is also made default.
- *	When this mode is sent selected, the @prepare call will be called
- *	before suspending to disk (if present), the @enter call should be
- *	present and will be called after all state has been saved and the
- *	machine is ready to be powered off; the @finish callback is called
- *	after state has been restored. All these calls are called with
- *	%PM_SUSPEND_DISK as the state.
  */
 struct pm_ops {
 	int (*valid)(suspend_state_t state);
 	int (*prepare)(suspend_state_t state);
 	int (*enter)(suspend_state_t state);
 	int (*finish)(suspend_state_t state);
-	suspend_disk_method_t pm_disk_mode;
 };
 
 /**
@@ -276,8 +249,6 @@ extern void device_power_up(void);
 extern void device_resume(void);
 
 #ifdef CONFIG_PM
-extern suspend_disk_method_t pm_disk_mode;
-
 extern int device_suspend(pm_message_t state);
 extern int device_prepare_suspend(pm_message_t state);
 
kernel/power/main.c +16 -26

88 lines not on this page · raw message

kernel/power/disk.c +99 -87

308 lines not on this page · raw message

Documentation/power/userland-swsusp.txt +14 -12
Index: linux-2.6.21/Documentation/power/userland-swsusp.txt
===================================================================
@@ -93,21 +93,23 @@ SNAPSHOT_S2RAM - suspend to RAM; using t
 	to resume the system from RAM if there's enough battery power or restore
 	its state on the basis of the saved suspend image otherwise)
 
-SNAPSHOT_PMOPS - enable the usage of the pmops->prepare, pmops->enter and
-	pmops->finish methods (the in-kernel swsusp knows these as the "platform
-	method") which are needed on many machines to (among others) speed up
-	the resume by letting the BIOS skip some steps or to let the system
-	recognise the correct state of the hardware after the resume (in
-	particular on many machines this ensures that unplugged AC
-	adapters get correctly detected and that kacpid does not run wild after
-	the resume).  The last ioctl() argument can take one of the three
-	values, defined in kernel/power/power.h:
+SNAPSHOT_PMOPS - enable the usage of the hibernation_ops->prepare,
+	hibernate_ops->enter and hibernation_ops->finish methods (the in-kernel
+	swsusp knows these as the "platform method") which are needed on many
+	machines to (among others) speed up the resume by letting the BIOS skip
+	some steps or to let the system recognise the correct state of the
+	hardware after the resume (in particular on many machines this ensures
+	that unplugged AC adapters get correctly detected and that kacpid does
+	not run wild after the resume).  The last ioctl() argument can take one
+	of the three values, defined in kernel/power/power.h:
 	PMOPS_PREPARE - make the kernel carry out the
-		pm_ops->prepare(PM_SUSPEND_DISK) operation
+		hibernation_ops->prepare() operation
 	PMOPS_ENTER - make the kernel power off the system by calling
-		pm_ops->enter(PM_SUSPEND_DISK)
+		hibernation_ops->enter()
 	PMOPS_FINISH - make the kernel carry out the
-		pm_ops->finish(PM_SUSPEND_DISK) operation
+		hibernation_ops->finish() operation
+	Note that the actual constants are misnamed because they surface
+	internal kernel implementation details that have changed.
 
 The device's read() operation can be used to transfer the snapshot image from
 the kernel.  It has the following limitations:
drivers/i2c/chips/tps65010.c +1 -1
Index: linux-2.6.21/drivers/i2c/chips/tps65010.c
===================================================================
@@ -354,7 +354,7 @@ static void tps65010_interrupt(struct tp
 			 * also needs to get error handling and probably
 			 * an #ifdef CONFIG_SOFTWARE_SUSPEND
 			 */
-			pm_suspend(PM_SUSPEND_DISK);
+			hibernate();
 #endif
 			poll = 1;
 		}
kernel/sys.c +1 -1
Index: linux-2.6.21/kernel/sys.c
===================================================================
@@ -881,7 +881,7 @@ asmlinkage long sys_reboot(int magic1, i
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	case LINUX_REBOOT_CMD_SW_SUSPEND:
 		{
-			int ret = pm_suspend(PM_SUSPEND_DISK);
+			int ret = hibernate();
 			unlock_kernel();
 			return ret;
 		}
drivers/acpi/sleep/main.c +53 -14

106 lines not on this page · raw message

kernel/power/power.h +1 -6
Index: linux-2.6.21/kernel/power/power.h
===================================================================
@@ -25,12 +25,7 @@ struct swsusp_info {
  */
 #define SPARE_PAGES	((1024 * 1024) >> PAGE_SHIFT)
 
-extern int pm_suspend_disk(void);
-#else
-static inline int pm_suspend_disk(void)
-{
-	return -EPERM;
-}
+extern struct hibernation_ops *hibernation_ops;
 #endif
 
 extern struct mutex pm_mutex;
drivers/acpi/sleep/proc.c +1 -1
Index: linux-2.6.21/drivers/acpi/sleep/proc.c
===================================================================
@@ -60,7 +60,7 @@ acpi_system_write_sleep(struct file *fil
 	state = simple_strtoul(str, NULL, 0);
 #ifdef CONFIG_SOFTWARE_SUSPEND
 	if (state == 4) {
-		error = pm_suspend(PM_SUSPEND_DISK);
+		error = hibernate();
 		goto Done;
 	}
 #endif
kernel/power/user.c +6 -7
Index: linux-2.6.21/kernel/power/user.c
===================================================================
@@ -130,16 +130,16 @@ static inline int platform_prepare(void)
 {
 	int error = 0;
 
-	if (pm_ops && pm_ops->prepare)
-		error = pm_ops->prepare(PM_SUSPEND_DISK);
+	if (hibernation_ops)
+		error = hibernation_ops->prepare();
 
 	return error;
 }
 
 static inline void platform_finish(void)
 {
-	if (pm_ops && pm_ops->finish)
-		pm_ops->finish(PM_SUSPEND_DISK);
+	if (hibernation_ops)
+		hibernation_ops->finish();
 }
 
 static inline int snapshot_suspend(int platform_suspend)
@@ -384,7 +384,7 @@ static int snapshot_ioctl(struct inode *
 		switch (arg) {
 
 		case PMOPS_PREPARE:
-			if (pm_ops && pm_ops->enter) {
+			if (hibernation_ops) {
 				data->platform_suspend = 1;
 				error = 0;
 			} else {
@@ -395,8 +395,7 @@ static int snapshot_ioctl(struct inode *
 		case PMOPS_ENTER:
 			if (data->platform_suspend) {
 				kernel_shutdown_prepare(SYSTEM_SUSPEND_DISK);
-				error = pm_ops->enter(PM_SUSPEND_DISK);
-				error = 0;
+				error = hibernation_ops->enter();
 			}
 			break;
 
include/linux/suspend.h +32 -0
Index: linux-2.6.21/include/linux/suspend.h
===================================================================
@@ -32,6 +32,24 @@ static inline int pm_prepare_console(voi
 static inline void pm_restore_console(void) {}
 #endif
 
+/**
+ * struct hibernation_ops - hibernation platform support
+ *
+ * The methods in this structure allow a platform to override the default
+ * mechanism of shutting down the machine during a hibernation transition.
+ *
+ * All three methods must be assigned.
+ *
+ * @prepare: prepare system for hibernation
+ * @enter: shut down system after state has been saved to disk
+ * @finish: finish/clean up after state has been reloaded
+ */
+struct hibernation_ops {
+	int (*prepare)(void);
+	int (*enter)(void);
+	void (*finish)(void);
+};
+
 #if defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND)
 /* kernel/power/snapshot.c */
 extern void __init register_nosave_region(unsigned long, unsigned long);
@@ -39,11 +57,25 @@ extern int swsusp_page_is_forbidden(stru
 extern void swsusp_set_page_free(struct page *);
 extern void swsusp_unset_page_free(struct page *);
 extern unsigned long get_safe_page(gfp_t gfp_mask);
+
+/**
+ * hibernation_set_ops - set the global hibernate operations
+ * @ops: the hibernation operations to use in subsequent hibernation transitions
+ */
+void hibernation_set_ops(struct hibernation_ops *ops);
+
+/**
+ * hibernate - hibernate the system
+ */
+extern int hibernate(void);
 #else
 static inline void register_nosave_region(unsigned long b, unsigned long e) {}
 static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
 static inline void swsusp_set_page_free(struct page *p) {}
 static inline void swsusp_unset_page_free(struct page *p) {}
+
+static inline void hibernation_set_ops(struct hibernation_ops *ops) {}
+extern inline int hibernate(void) { return -ENOSYS; }
 #endif /* defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND) */
 
 void save_processor_state(void);
#1 lore raw

kernel/power/disk.c char resume_file[256] = CONFIG_PM_STD_PA · line 56

Quoted 7 lines · Rafael J. Wysocki
kernel/power/disk.c +7 -0
+void hibernation_set_ops(struct hibernation_ops *ops)
+{
+	if (ops && !(ops->prepare && ops->enter && ops->finish)) {
+		printk(KERN_ERR "Wrong definition of hibernation operations! "
+			"Using defaults\n");
+		return;
+	}

Why not BUG_ON here as I had before? I don't see much point in giving a runtime warning, and the docs clearly state that you must assign all three items. Oh, I see I had a bug before when ops was NULL, but you can still do
BUG_ON(ops && !(ops->prepare && ops->enter && ops->finish));

kernel/power/disk.c static ssize_t disk_store(struct subsyst · line 434

Quoted 5 lines
kernel/power/disk.c +3 -2
-	pr_debug("PM: suspend-to-disk mode set to '%s'\n",
-		 pm_disk_modes[mode]);
+	if (!error)
+		pr_debug("PM: suspend-to-disk mode set to '%s'\n",
+			 hibernation_modes[mode]);

Isn't that an unrelated bugfix ;) just kidding

Looks good to me but I haven't checked the acpi in detail. If I remember, I'll try to give it all a go on my G5 later today.

johannes

#12 lore raw
In reply to Rafael J. Wysocki

kernel/power/disk.c char resume_file[256] = CONFIG_PM_STD_PA · line 56

Quoted 7 lines · Rafael J. Wysocki
kernel/power/disk.c +7 -0
+void hibernation_set_ops(struct hibernation_ops *ops)
+{
+	if (ops && !(ops->prepare && ops->enter && ops->finish)) {
+		printk(KERN_ERR "Wrong definition of hibernation operations! "
+			"Using defaults\n");
+		return;
+	}

Why not BUG_ON here as I had before? I don't see much point in giving a runtime warning, and the docs clearly state that you must assign all three items. Oh, I see I had a bug before when ops was NULL, but you can still do
BUG_ON(ops && !(ops->prepare && ops->enter && ops->finish));

kernel/power/disk.c static ssize_t disk_store(struct subsyst · line 434

Quoted 5 lines
kernel/power/disk.c +3 -2
-	pr_debug("PM: suspend-to-disk mode set to '%s'\n",
-		 pm_disk_modes[mode]);
+	if (!error)
+		pr_debug("PM: suspend-to-disk mode set to '%s'\n",
+			 hibernation_modes[mode]);

Isn't that an unrelated bugfix ;) just kidding

Looks good to me but I haven't checked the acpi in detail. If I remember, I'll try to give it all a go on my G5 later today.

johannes

#2 lore raw
In reply to Johannes Berg
Quoted 15 lines · Johannes Berg

kernel/power/disk.c char resume_file[256] = CONFIG_PM_STD_PA · line 56

Quoted 7 lines · Rafael J. Wysocki
kernel/power/disk.c +7 -0
+void hibernation_set_ops(struct hibernation_ops *ops)
+{
+	if (ops && !(ops->prepare && ops->enter && ops->finish)) {
+		printk(KERN_ERR "Wrong definition of hibernation operations! "
+			"Using defaults\n");
+		return;
+	}

Why not BUG_ON here as I had before? I don't see much point in giving a runtime warning, and the docs clearly state that you must assign all three items. Oh, I see I had a bug before when ops was NULL, but you can still do
BUG_ON(ops && !(ops->prepare && ops->enter && ops->finish));

Well, BUG_ON() is extremely user-unfriendly, and it'd trigger even if the user actually didn't intend to suspend at all.

IMO this is not a "we can't continue if that condition is not satisfied" situation.

Quoted 7 lines

kernel/power/disk.c static ssize_t disk_store(struct subsyst · line 434

Quoted 5 lines
kernel/power/disk.c +3 -2
-	pr_debug("PM: suspend-to-disk mode set to '%s'\n",
-		 pm_disk_modes[mode]);
+	if (!error)
+		pr_debug("PM: suspend-to-disk mode set to '%s'\n",
+			 hibernation_modes[mode]);

Isn't that an unrelated bugfix ;) just kidding

You mean the 'if (!error)'? Well ... ;-)

Quoted 2 lines

Looks good to me but I haven't checked the acpi in detail. If I remember, I'll try to give it all a go on my G5 later today.

OK

Greetings,
Rafael

#3 lore raw
Quoted 2 lines · Rafael J. Wysocki

Well, BUG_ON() is extremely user-unfriendly, and it'd trigger even if the user actually didn't intend to suspend at all.

Well, hibernation_set_ops is invoked whenever the user loads his ACPI module with S4 possible, and typically having a BUG_ON here will make the developers who wrote the code that calls hibernation_set_ops see it right away while they might miss the message.

I don't care much though, it just seems wasteful to have this string in there when it'll never be seen by anyone but the developers who create new hibernation_ops.

johannes

#6 lore raw
In reply to Rafael J. Wysocki
Quoted 2 lines · Rafael J. Wysocki

Well, BUG_ON() is extremely user-unfriendly, and it'd trigger even if the user actually didn't intend to suspend at all.

Well, hibernation_set_ops is invoked whenever the user loads his ACPI module with S4 possible, and typically having a BUG_ON here will make the developers who wrote the code that calls hibernation_set_ops see it right away while they might miss the message.

I don't care much though, it just seems wasteful to have this string in there when it'll never be seen by anyone but the developers who create new hibernation_ops.

johannes

#11 lore raw
In reply to Johannes Berg
Quoted 15 lines · Johannes Berg

kernel/power/disk.c char resume_file[256] = CONFIG_PM_STD_PA · line 56

Quoted 7 lines · Rafael J. Wysocki
kernel/power/disk.c +7 -0
+void hibernation_set_ops(struct hibernation_ops *ops)
+{
+	if (ops && !(ops->prepare && ops->enter && ops->finish)) {
+		printk(KERN_ERR "Wrong definition of hibernation operations! "
+			"Using defaults\n");
+		return;
+	}

Why not BUG_ON here as I had before? I don't see much point in giving a runtime warning, and the docs clearly state that you must assign all three items. Oh, I see I had a bug before when ops was NULL, but you can still do
BUG_ON(ops && !(ops->prepare && ops->enter && ops->finish));

Well, BUG_ON() is extremely user-unfriendly, and it'd trigger even if the user actually didn't intend to suspend at all.

IMO this is not a "we can't continue if that condition is not satisfied" situation.

Quoted 7 lines

kernel/power/disk.c static ssize_t disk_store(struct subsyst · line 434

Quoted 5 lines
kernel/power/disk.c +3 -2
-	pr_debug("PM: suspend-to-disk mode set to '%s'\n",
-		 pm_disk_modes[mode]);
+	if (!error)
+		pr_debug("PM: suspend-to-disk mode set to '%s'\n",
+			 hibernation_modes[mode]);

Isn't that an unrelated bugfix ;) just kidding

You mean the 'if (!error)'? Well ... ;-)

Quoted 2 lines

Looks good to me but I haven't checked the acpi in detail. If I remember, I'll try to give it all a go on my G5 later today.

OK

Greetings,
Rafael

#4 lore raw
In reply to Johannes Berg
Quoted 5 lines · Johannes Berg
Quoted 2 lines · Rafael J. Wysocki

Well, BUG_ON() is extremely user-unfriendly, and it'd trigger even if the user actually didn't intend to suspend at all.

Quoted 8 lines

Well, hibernation_set_ops is invoked whenever the user loads his ACPI module with S4 possible, and typically having a BUG_ON here will make the developers who wrote the code that calls hibernation_set_ops see it right away while they might miss the message.

I don't care much though, it just seems wasteful to have this string in there when it'll never be seen by anyone but the developers who create new hibernation_ops.

You're making the dangerous assumption that all patches get tested before hitting users. ;-)

Greetings,
Rafael

#5 lore raw
In reply to Johannes Berg
Quoted 5 lines · Johannes Berg
Quoted 2 lines · Rafael J. Wysocki

Well, BUG_ON() is extremely user-unfriendly, and it'd trigger even if the user actually didn't intend to suspend at all.

Quoted 8 lines

Well, hibernation_set_ops is invoked whenever the user loads his ACPI module with S4 possible, and typically having a BUG_ON here will make the developers who wrote the code that calls hibernation_set_ops see it right away while they might miss the message.

I don't care much though, it just seems wasteful to have this string in there when it'll never be seen by anyone but the developers who create new hibernation_ops.

You're making the dangerous assumption that all patches get tested before hitting users. ;-)

Greetings,
Rafael

#7 lore raw
In reply to Rafael J. Wysocki
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Johannes Berg

kernel/power/disk.c char resume_file[256] = CONFIG_PM_STD_PA · line 56

Quoted 7 lines · Rafael J. Wysocki
kernel/power/disk.c +7 -0
+void hibernation_set_ops(struct hibernation_ops *ops)
+{
+	if (ops && !(ops->prepare && ops->enter && ops->finish)) {
+		printk(KERN_ERR "Wrong definition of hibernation operations! "
+			"Using defaults\n");
+		return;
+	}

Why not BUG_ON here as I had before? I don't see much point in giving a runtime warning, and the docs clearly state that you must assign all three items. Oh, I see I had a bug before when ops was NULL, but you can still do
BUG_ON(ops && !(ops->prepare && ops->enter && ops->finish));

Quoted 2 lines

Well, BUG_ON() is extremely user-unfriendly, and it'd trigger even if the user actually didn't intend to suspend at all.

WARN_ON()?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#8 lore raw
In reply to Rafael J. Wysocki
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Johannes Berg

kernel/power/disk.c char resume_file[256] = CONFIG_PM_STD_PA · line 56

Quoted 7 lines · Rafael J. Wysocki
kernel/power/disk.c +7 -0
+void hibernation_set_ops(struct hibernation_ops *ops)
+{
+	if (ops && !(ops->prepare && ops->enter && ops->finish)) {
+		printk(KERN_ERR "Wrong definition of hibernation operations! "
+			"Using defaults\n");
+		return;
+	}

Why not BUG_ON here as I had before? I don't see much point in giving a runtime warning, and the docs clearly state that you must assign all three items. Oh, I see I had a bug before when ops was NULL, but you can still do
BUG_ON(ops && !(ops->prepare && ops->enter && ops->finish));

Quoted 2 lines

Well, BUG_ON() is extremely user-unfriendly, and it'd trigger even if the user actually didn't intend to suspend at all.

WARN_ON()?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#9 lore raw
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Johannes Berg

kernel/power/disk.c char resume_file[256] = CONFIG_PM_STD_PA · line 56

Quoted 7 lines · Rafael J. Wysocki
kernel/power/disk.c +7 -0
+void hibernation_set_ops(struct hibernation_ops *ops)
+{
+	if (ops && !(ops->prepare && ops->enter && ops->finish)) {
+		printk(KERN_ERR "Wrong definition of hibernation operations! "
+			"Using defaults\n");
+		return;
+	}

Why not BUG_ON here as I had before? I don't see much point in giving a runtime warning, and the docs clearly state that you must assign all three items. Oh, I see I had a bug before when ops was NULL, but you can still do
BUG_ON(ops && !(ops->prepare && ops->enter && ops->finish));

Quoted 4 lines
Quoted 2 lines

Well, BUG_ON() is extremely user-unfriendly, and it'd trigger even if the user actually didn't intend to suspend at all.

WARN_ON()?

Sure, why not.

Greetings,
Rafael

#10 lore raw
In reply to Pavel Machek
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Rafael J. Wysocki
Quoted 15 lines · Johannes Berg

kernel/power/disk.c char resume_file[256] = CONFIG_PM_STD_PA · line 56

Quoted 7 lines · Rafael J. Wysocki
kernel/power/disk.c +7 -0
+void hibernation_set_ops(struct hibernation_ops *ops)
+{
+	if (ops && !(ops->prepare && ops->enter && ops->finish)) {
+		printk(KERN_ERR "Wrong definition of hibernation operations! "
+			"Using defaults\n");
+		return;
+	}

Why not BUG_ON here as I had before? I don't see much point in giving a runtime warning, and the docs clearly state that you must assign all three items. Oh, I see I had a bug before when ops was NULL, but you can still do
BUG_ON(ops && !(ops->prepare && ops->enter && ops->finish));

Quoted 4 lines
Quoted 2 lines

Well, BUG_ON() is extremely user-unfriendly, and it'd trigger even if the user actually didn't intend to suspend at all.

WARN_ON()?

Sure, why not.

Greetings,
Rafael

#15 lore raw
In reply to Rafael J. Wysocki

include/linux/suspend.h extern int swsusp_page_is_forbidden(stru

Quoted 6 lines · Rafael J. Wysocki

extern void swsusp_unset_page_free(struct page *); extern unsigned long get_safe_page(gfp_t gfp_mask);

include/linux/suspend.h +2 -0
+void hibernation_set_ops(struct hibernation_ops *ops);
 
+extern int hibernate(void);

You could add an extern to hibernation_set_ops for consistency :) Not that I really care.

johannes

#18 lore raw
In reply to Rafael J. Wysocki

include/linux/suspend.h extern int swsusp_page_is_forbidden(stru

Quoted 6 lines · Rafael J. Wysocki

extern void swsusp_unset_page_free(struct page *); extern unsigned long get_safe_page(gfp_t gfp_mask);

include/linux/suspend.h +2 -0
+void hibernation_set_ops(struct hibernation_ops *ops);
 
+extern int hibernate(void);

You could add an extern to hibernation_set_ops for consistency :) Not that I really care.

johannes

#19 lore raw
In reply to Rafael J. Wysocki
Quoted 1 line · Rafael J. Wysocki

+extern inline int hibernate(void) { return -ENOSYS; }

and I don't think that will compile :)

(the extern doesn't seem to be consistent right now anyway. maybe just kill them all?)

johannes

#22 lore raw
In reply to Rafael J. Wysocki
Quoted 1 line · Rafael J. Wysocki

+extern inline int hibernate(void) { return -ENOSYS; }

and I don't think that will compile :)

(the extern doesn't seem to be consistent right now anyway. maybe just kill them all?)

johannes

#16 lore raw
In reply to Johannes Berg
Quoted 11 lines · Johannes Berg

include/linux/suspend.h extern int swsusp_page_is_forbidden(stru

Quoted 6 lines · Rafael J. Wysocki

extern void swsusp_unset_page_free(struct page *); extern unsigned long get_safe_page(gfp_t gfp_mask);

include/linux/suspend.h +2 -0
+void hibernation_set_ops(struct hibernation_ops *ops);
 
+extern int hibernate(void);

You could add an extern to hibernation_set_ops for consistency :) Not that I really care.

Will add, thanks.

Rafael

#20 lore raw
In reply to Johannes Berg
Quoted 5 lines · Johannes Berg
Quoted 1 line · Rafael J. Wysocki

+extern inline int hibernate(void) { return -ENOSYS; }

and I don't think that will compile :)

It will, but this is a mistake. It should be 'static', not 'extern'. Will fix, thanks.

Rafael

#17 lore raw
In reply to Johannes Berg
Quoted 11 lines · Johannes Berg

include/linux/suspend.h extern int swsusp_page_is_forbidden(stru

Quoted 6 lines · Rafael J. Wysocki

extern void swsusp_unset_page_free(struct page *); extern unsigned long get_safe_page(gfp_t gfp_mask);

include/linux/suspend.h +2 -0
+void hibernation_set_ops(struct hibernation_ops *ops);
 
+extern int hibernate(void);

You could add an extern to hibernation_set_ops for consistency :) Not that I really care.

Will add, thanks.

Rafael

#21 lore raw
In reply to Johannes Berg
Quoted 5 lines · Johannes Berg
Quoted 1 line · Rafael J. Wysocki

+extern inline int hibernate(void) { return -ENOSYS; }

and I don't think that will compile :)

It will, but this is a mistake. It should be 'static', not 'extern'. Will fix, thanks.

Rafael