[...]
One more update after some conversations during LinuxCon Europe.
The main point was to make it possible for device_link_add() to figure out the
initial state of the link instead of expecting the caller to provide it which
might not be reliable enough in general.
In this version device_link_add() takes three arguments, the supplier and
consumer pointers and flags and it sets the correct initial state of the link
automatically (unless invoked with the "stateless" flag, of course). The cost
is one additional field in struct device (I moved all of the links-related
fields in struct device to a separate sub-structure while at it) to track
the "driver presence status" of the device (to be used by device_link_add()).
In addition to that, the links list walks in the core.c and dd.c code are
under the device links mutex now, so the iternal link spinlock is not needed
any more and I have renamed symbols to distinguish between flags, link states
and device "driver presence statuses".
More information is there in the changelogs.