I can't speak for the second example, but there's a good reason the
first example works this way. It's not a matter of races; the problem
is that the kernel thread's job is to selectively suspend and resume
devices. We don't want it doing this while a system sleep is in
progress; it would (and in fact has, before the thread was made
freezable) cause the sleep transition to abort.
Handling it entirely from within the drivers is possible in theory.
Unfortunately the design of the PM core has not leant itself to such an
approach. Using separate callbacks for hibernation vs. STR will help,
as will Raphael's notifiers.