Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9684e51c authored by Johannes Berg's avatar Johannes Berg Committed by Linus Torvalds
Browse files

power management: force pm_ops.valid callback to be assigned



This patch changes the docs and behaviour from "all states valid" to "no
states valid" if no .valid callback is assigned.  Users of pm_ops that only
need mem sleep can assign pm_valid_only_mem without any overhead, others
will require more elaborate callbacks.

Now that all users of pm_ops have a .valid callback this is a safe thing to
do and prevents things from getting messy again as they were before.

Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Acked-by: default avatarPavel Machek <pavel@ucw.cz>
Looks-okay-to: Rafael J. Wysocki <rjw@sisk.pl>
Cc: <linux-pm@lists.linux-foundation.org>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e8c9c502
Loading
Loading
Loading
Loading
+6 −6
Original line number Original line Diff line number Diff line
@@ -125,12 +125,12 @@ typedef int __bitwise suspend_disk_method_t;
 * struct pm_ops - Callbacks for managing platform dependent suspend states.
 * struct pm_ops - Callbacks for managing platform dependent suspend states.
 * @valid: Callback to determine whether the given state can be entered.
 * @valid: Callback to determine whether the given state can be entered.
 * 	If %CONFIG_SOFTWARE_SUSPEND is set then %PM_SUSPEND_DISK is
 * 	If %CONFIG_SOFTWARE_SUSPEND is set then %PM_SUSPEND_DISK is
 *	always valid and never passed to this call.
 *	always valid and never passed to this call. If not assigned,
 *	If not assigned, all suspend states are advertised as valid
 *	no suspend states are valid.
 *	in /sys/power/state (but can still be rejected by prepare or enter.)
 *	Valid states are advertised in /sys/power/state but can still
 *	Since new states can be added for other platforms, you should
 *	be rejected by prepare or enter if the conditions aren't right.
 *	assign this callback. There is a %pm_valid_only_mem function
 *	There is a %pm_valid_only_mem function available that can be assigned
 *	available if you only implemented mem sleep.
 *	to this if you only implement mem sleep.
 *
 *
 * @prepare: Prepare the platform for the given suspend state. Can return a
 * @prepare: Prepare the platform for the given suspend state. Can return a
 *	negative error code if necessary.
 *	negative error code if necessary.
+2 −2
Original line number Original line Diff line number Diff line
@@ -198,8 +198,8 @@ static inline int valid_state(suspend_state_t state)


	/* all other states need lowlevel support and need to be
	/* all other states need lowlevel support and need to be
	 * valid to the lowlevel implementation, no valid callback
	 * valid to the lowlevel implementation, no valid callback
	 * implies that all are valid. */
	 * implies that none are valid. */
	if (!pm_ops || (pm_ops->valid && !pm_ops->valid(state)))
	if (!pm_ops || !pm_ops->valid || !pm_ops->valid(state))
		return 0;
		return 0;
	return 1;
	return 1;
}
}