Right, but this case still seems like an error. My understanding is that
only drivers will use this API directly and it will not be used by the
device driver core (unlike dev_pm_domain_attach), so if anyone calls this
attempting to attach another PM domain when one is already attached, they
are doing something wrong.
[...]
You may be right!
What I was thinking of is whether multiple PM domains may be optional
in some cases, but instead a PM domain have already been attached by
dev_pm_domain_attach(), prior the driver starts to probe.
Then, assuming we return an error for this case, that means the caller
then need to check the dev->pm_domain pointer, prior calling
dev_pm_domain_attach_by_id(). Wouldn't it? Perhaps that is more clear
though?