device_set_present(&bst->dev, false);
}
+static void
+bridge_free_member(struct bridge_member *bm)
+{
+ struct device *dev = bm->dev.dev;
+
+ bridge_remove_member(bm);
+ device_remove_user(&bm->dev);
+
+ /*
+ * When reloading the config and moving a device from one bridge to
+ * another, the other bridge may have tried to claim this device
+ * before it was removed here.
+ * Ensure that claiming the device is retried by toggling its present
+ * state
+ */
+ if (dev->present) {
+ device_set_present(dev, false);
+ device_set_present(dev, true);
+ }
+
+ free(bm);
+}
+
static void
bridge_member_cb(struct device_user *dev, enum device_event ev)
{
if (node_old) {
bm = container_of(node_old, struct bridge_member, node);
- bridge_remove_member(bm);
- device_remove_user(&bm->dev);
- free(bm);
+ bridge_free_member(bm);
}
}