Optimize system_bonding_set_port in netifd?

in system_bonding_set_port, somethings because the port is not deleted from bridge, so setting maybe fail, just like kernel info

[ 87.351061] bond1: (slave lan4): Error: Device is in use and cannot be enslaved
[ 87.358420] bond1: option slaves: unable to set because the bond device is up

so it is better to add some action before add slave to bond, that is , delete slave from bridge

int system_bonding_set_port(struct device *dev, struct device *port, bool add, bool primary)
{
const char *port_name = port->ifname;
const char op_ch = add ? '+' : '-';
char buf[IFNAMSIZ + 1];
char *bridge;
static char buf2[256];

snprintf(buf, sizeof(buf), "%c%s", op_ch, port_name);
system_if_down(port);

bridge = system_get_bridge(port->ifname, buf2, sizeof(buf2));
if (bridge) {
	D(SYSTEM, "bonding:Remove device '%s' from bridge '%s'\n", port->ifname, bridge);
	system_bridge_if(bridge, port, SIOCBRDELIF, NULL);
}

system_set_dev_sysfs("bonding/slaves", dev->ifname, buf);

Ports must be inenslaved to join bridge or bond, nothing new here. Probably doc paragraph could help.