}
static int
-bridge_hotplug_prepare(struct device *dev)
+bridge_hotplug_prepare(struct device *dev, struct device **bridge_dev)
{
struct bridge_state *bst;
+ if (bridge_dev)
+ *bridge_dev = dev;
+
bst = container_of(dev, struct bridge_state, dev);
bst->force_active = true;
device_set_present(&bst->dev, true);
};
struct device_hotplug_ops {
- int (*prepare)(struct device *dev);
+ int (*prepare)(struct device *dev, struct device **bridge_dev);
int (*add)(struct device *main, struct device *member, struct blob_attr *vlan);
int (*del)(struct device *main, struct device *member);
};
struct blob_attr *msg)
{
struct interface *iface;
- struct device *dev;
+ struct device *dev, *bridge_dev = NULL;
const struct device_hotplug_ops *ops;
iface = container_of(obj, struct interface, ubus);
dev = iface->main_dev.dev;
if (!dev)
- return 0;
+ goto out;
ops = dev->hotplug_ops;
if (!ops)
- return 0;
+ goto out;
+
+ ops->prepare(dev, &bridge_dev);
+
+out:
+ blob_buf_init(&b, 0);
+ if (bridge_dev)
+ blobmsg_add_string(&b, "bridge", bridge_dev->ifname);
+ ubus_send_reply(ctx, req, b.head);
- return ops->prepare(dev);
+ return 0;
}
static int
}
static int
-vlan_hotplug_prepare(struct device *dev)
+vlan_hotplug_prepare(struct device *dev, struct device **bridge_dev)
{
struct vlan_device *vldev = container_of(dev, struct vlan_device, dev);
if (!dev || !dev->hotplug_ops)
return UBUS_STATUS_NOT_SUPPORTED;
- return dev->hotplug_ops->prepare(dev);
+ return dev->hotplug_ops->prepare(dev, bridge_dev);
}
static void vlan_hotplug_check(struct vlan_device *vldev, struct device *dev)
}
static int
-vlandev_hotplug_prepare(struct device *dev)
+vlandev_hotplug_prepare(struct device *dev, struct device **bridge_dev)
{
struct vlandev_device *mvdev = container_of(dev, struct vlandev_device, dev);
if (!dev || !dev->hotplug_ops)
return UBUS_STATUS_NOT_SUPPORTED;
- return dev->hotplug_ops->prepare(dev);
+ return dev->hotplug_ops->prepare(dev, bridge_dev);
}
static void vlandev_hotplug_check(struct vlandev_device *mvdev)
if (!dev)
return;
- if (!dev->type->bridge_capability)
+ if (!dev->hotplug_ops)
return;
}
return;
if (dev->hotplug_ops && dev->hotplug_ops->prepare)
- dev->hotplug_ops->prepare(dev);
+ dev->hotplug_ops->prepare(dev, &dev);
+
+ if (!dev || !dev->type->bridge_capability)
+ return;
blobmsg_add_string(buf, "bridge", dev->ifname);