Fixes a race condition as the device can be active again; due to a device_claim; by the logic
behind the set_state device type function. In this case the down event cannot be sent anymore
as it would bring down the interface(s) referencing the device.
This can be the case for an aliased device when the underlying device is switched during a reload;
the alias_set_device function can add a new dependency on the new active device which will put the
aliased device in active mode again as the aliased device is already claimed by the interface
using it.
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
device_broadcast_event(dev, DEV_EVENT_TEARDOWN);
if (!dev->external)
dev->set_state(dev, false);
+
+ if (dev->active)
+ return;
+
device_broadcast_event(dev, DEV_EVENT_DOWN);
}