device: fix build error on 32 bit systems
[project/netifd.git] / bonding.c
index 321f819a6f4b9ea0c2845e8a75a76e70840979d5..1f13148fea41c929bb5dcf5db6771de722d6f072 100644 (file)
--- a/bonding.c
+++ b/bonding.c
@@ -221,10 +221,6 @@ bonding_enable_port(struct bonding_port *bp)
        if (!bp->present)
                return 0;
 
-       ret = bonding_set_active(bdev, true);
-       if (ret)
-               goto error;
-
        /* Disable IPv6 for bonding ports */
        if (!(bp->dev.dev->settings.flags & DEV_OPT_IPV6)) {
                bp->dev.dev->settings.ipv6 = 0;
@@ -233,7 +229,11 @@ bonding_enable_port(struct bonding_port *bp)
 
        ret = device_claim(&bp->dev);
        if (ret < 0)
-               goto error;
+               return ret;
+
+       ret = bonding_set_active(bdev, true);
+       if (ret)
+               goto release;
 
        dev = bp->dev.dev;
        if (dev->settings.auth && !dev->auth_status)
@@ -257,6 +257,7 @@ error:
        bdev->n_failed++;
        bp->present = false;
        bdev->n_present--;
+release:
        device_release(&bp->dev);
 
        return ret;
@@ -352,7 +353,7 @@ bonding_config_init(struct device *dev)
 {
        struct bonding_device *bdev;
        struct blob_attr *cur;
-       int rem;
+       size_t rem;
 
        bdev = container_of(dev, struct bonding_device, dev);
 
@@ -395,7 +396,7 @@ bonding_apply_settings(struct bonding_device *bdev, struct blob_attr **tb)
 
        if ((cur = tb[BOND_ATTR_POLICY]) != NULL) {
                const char *policy = blobmsg_get_string(cur);
-               int i;
+               size_t i;
 
                for (i = 0; i < ARRAY_SIZE(bonding_policy_str); i++) {
                        if (strcmp(policy, bonding_policy_str[i]) != 0)
@@ -441,10 +442,10 @@ bonding_reload(struct device *dev, struct blob_attr *attr)
        struct blob_attr *tb_dev[__DEV_ATTR_MAX];
        struct blob_attr *tb_b[__BOND_ATTR_MAX];
        enum dev_change_type ret = DEV_CONFIG_APPLIED;
-       unsigned long diff;
+       unsigned long diff[2] = {};
        struct bonding_device *bdev;
 
-       BUILD_BUG_ON(sizeof(diff) < __BOND_ATTR_MAX / 8);
+       BUILD_BUG_ON(sizeof(diff[0]) < __BOND_ATTR_MAX / 8);
        BUILD_BUG_ON(sizeof(diff) < __DEV_ATTR_MAX / 8);
 
        bdev = container_of(dev, struct bonding_device, dev);
@@ -471,17 +472,16 @@ bonding_reload(struct device *dev, struct blob_attr *attr)
                blobmsg_parse(device_attr_list.params, __DEV_ATTR_MAX, otb_dev,
                        blob_data(bdev->config_data), blob_len(bdev->config_data));
 
-               diff = 0;
-               uci_blob_diff(tb_dev, otb_dev, &device_attr_list, &diff);
-               if (diff)
+               uci_blob_diff(tb_dev, otb_dev, &device_attr_list, diff);
+               if (diff[0] | diff[1])
                    ret = DEV_CONFIG_RESTART;
 
                blobmsg_parse(bonding_attrs, __BOND_ATTR_MAX, otb_b,
                        blob_data(bdev->config_data), blob_len(bdev->config_data));
 
-               diff = 0;
-               uci_blob_diff(tb_b, otb_b, &bonding_attr_list, &diff);
-               if (diff & ~(1 << BOND_ATTR_PORTS))
+               diff[0] = 0;
+               uci_blob_diff(tb_b, otb_b, &bonding_attr_list, diff);
+               if (diff[0] & ~(1 << BOND_ATTR_PORTS))
                    ret = DEV_CONFIG_RESTART;
 
                bonding_config_init(dev);
@@ -565,8 +565,6 @@ bonding_free_port(struct bonding_port *bp)
 
        bonding_remove_port(bp);
 
-       device_lock();
-
        device_remove_user(&bp->dev);
 
        /*
@@ -581,8 +579,6 @@ bonding_free_port(struct bonding_port *bp)
                device_set_present(dev, true);
        }
 
-       device_unlock();
-
        free(bp);
 }