Staging: batman-adv: Unify sysfs file names with their bat_priv atomics
[firefly-linux-kernel-4.4.55.git] / drivers / staging / batman-adv / hard-interface.c
index 6d5b74862f23b8addfdddcac8ea4f5db74924ccb..ff0ac98250014f5ef4848e15f72ca76787056972 100644 (file)
 /* protect update critical side of if_list - but not the content */
 static DEFINE_SPINLOCK(if_list_lock);
 
+static void hardif_free_rcu(struct rcu_head *rcu)
+{
+       struct batman_if *batman_if;
+
+       batman_if = container_of(rcu, struct batman_if, rcu);
+       dev_put(batman_if->net_dev);
+       kref_put(&batman_if->refcount, hardif_free_ref);
+}
+
 struct batman_if *get_batman_if_by_netdev(struct net_device *net_dev)
 {
        struct batman_if *batman_if;
@@ -199,7 +208,7 @@ int hardif_min_mtu(struct net_device *soft_iface)
         * (have MTU > 1500 + BAT_HEADER_LEN) */
        int min_mtu = ETH_DATA_LEN;
 
-       if (atomic_read(&bat_priv->frag_enabled))
+       if (atomic_read(&bat_priv->fragmentation))
                goto out;
 
        rcu_read_lock();
@@ -323,7 +332,7 @@ int hardif_enable_interface(struct batman_if *batman_if, char *iface_name)
        bat_info(batman_if->soft_iface, "Adding interface: %s\n",
                 batman_if->net_dev->name);
 
-       if (atomic_read(&bat_priv->frag_enabled) && batman_if->net_dev->mtu <
+       if (atomic_read(&bat_priv->fragmentation) && batman_if->net_dev->mtu <
                ETH_DATA_LEN + BAT_HEADER_LEN)
                bat_info(batman_if->soft_iface,
                        "The MTU of interface %s is too small (%i) to handle "
@@ -334,7 +343,7 @@ int hardif_enable_interface(struct batman_if *batman_if, char *iface_name)
                        batman_if->net_dev->name, batman_if->net_dev->mtu,
                        ETH_DATA_LEN + BAT_HEADER_LEN);
 
-       if (!atomic_read(&bat_priv->frag_enabled) && batman_if->net_dev->mtu <
+       if (!atomic_read(&bat_priv->fragmentation) && batman_if->net_dev->mtu <
                ETH_DATA_LEN + BAT_HEADER_LEN)
                bat_info(batman_if->soft_iface,
                        "The MTU of interface %s is too small (%i) to handle "
@@ -462,9 +471,8 @@ static void hardif_remove_interface(struct batman_if *batman_if)
                return;
 
        batman_if->if_status = IF_TO_BE_REMOVED;
-       synchronize_rcu();
        sysfs_del_hardif(&batman_if->hardif_obj);
-       kref_put(&batman_if->refcount, hardif_free_ref);
+       call_rcu(&batman_if->rcu, hardif_free_rcu);
 }
 
 void hardif_remove_interfaces(void)