Cc: pm list <linux-pm@...>, ACPI Devel Maling List <linux-acpi@...>, Greg KH <greg@...>, Len Brown <lenb@...>, LKML <linux-kernel@...>, Alexey Starikovskiy <astarikovskiy@...>, David Brownell <david-b@...>, Pavel Machek <pavel@...>, Benjamin Herrenschmidt <benh@...>
...
It would be okay to wait until after the last prepare() method is
called. I don't know if it makes any difference in the end, however.
Can we also have a DPM_PREPARING state, set when ->prepare() is about
to be called? The PM core wouldn't make use of it but some drivers
would. (I can't think of any use at all for the analogous
DPM_COMPLETING state, however.)
...
Clearer to say: if (dev->parent->power.status >= DPM_SUSPENDING) {
...
Log a warning here? If this ever happened, it would be the sort of
unexpected regression that people get all excited about.
...
Clearer to say: if (dev->power.status >= DPM_OFF) {
Note that if dev->power.status is equal to DPM_SUSPENDING then you
don't want to call resume_device(), but you still do want to change
dev->power.status to DPM_RESUMING so that new children can be
registered.
A little problem here: You refer to dev after calling put_device().
This isn't the way I imagined doing it (your extra "list"), but it's
fine.
...
...
Same problem with use-after-put. Also present in dpm_prepare().
...
...
Use-after-put again.
Instead you could eliminate the list_splice_init() above and put here:
list_splice(&list, dpm_list->prev);
This will move the entries from list to the end of dpm_list.
On the whole it looks quite good.
Alan Stern
--