It doesn't help. What _does_ help is the fact that these traversals
are all serialized (since only one thread can carry out a system sleep
at any time).
Yes, that is the problem. If you try to work around it by using
list_for_each_entry_safe() then you run into a problem when a
concurrent thread removes the device _following_ the one being handled
(or when the device being handled is the last one on the list and a
concurrent thread registers a new device, which can only happen in
dpm_prepare()).
It's not hard to fix. Just something to be aware of.
Alan Stern
P.S.: Oh yes, another related issue... We should call get_device() and
put_device() while holding dpm_list_mtx. Otherwise the device
structure might vanish when the callbacks are invoked.
--