diff mbox series

[net-next,1/6] net: refactor all NETDEV_CHANGE notifier calls to a single function

Message ID 20220408200337.718067-2-vladimir.oltean@nxp.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series Disable host flooding for DSA ports under a bridge | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/cc_maintainers warning 2 maintainers not CCed: petrm@nvidia.com edumazet@google.com
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 50 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Vladimir Oltean April 8, 2022, 8:03 p.m. UTC
Create a __netdev_state_change() helper function which emits a
NETDEV_CHANGE notifier with the given changed flags as argument.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/core/dev.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/net/core/dev.c b/net/core/dev.c
index e027410e861b..433f006a796b 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1314,6 +1314,19 @@  void netdev_features_change(struct net_device *dev)
 }
 EXPORT_SYMBOL(netdev_features_change);
 
+static void __netdev_state_change(struct net_device *dev,
+				  unsigned int flags_changed)
+{
+	struct netdev_notifier_change_info change_info = {
+		.info = {
+			.dev = dev,
+		},
+		.flags_changed = flags_changed,
+	};
+
+	call_netdevice_notifiers_info(NETDEV_CHANGE, &change_info.info);
+}
+
 /**
  *	netdev_state_change - device changes state
  *	@dev: device to cause notification
@@ -1325,12 +1338,7 @@  EXPORT_SYMBOL(netdev_features_change);
 void netdev_state_change(struct net_device *dev)
 {
 	if (dev->flags & IFF_UP) {
-		struct netdev_notifier_change_info change_info = {
-			.info.dev = dev,
-		};
-
-		call_netdevice_notifiers_info(NETDEV_CHANGE,
-					      &change_info.info);
+		__netdev_state_change(dev, 0);
 		rtmsg_ifinfo(RTM_NEWLINK, dev, 0, GFP_KERNEL);
 	}
 }
@@ -8479,16 +8487,8 @@  void __dev_notify_flags(struct net_device *dev, unsigned int old_flags,
 	}
 
 	if (dev->flags & IFF_UP &&
-	    (changes & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI | IFF_VOLATILE))) {
-		struct netdev_notifier_change_info change_info = {
-			.info = {
-				.dev = dev,
-			},
-			.flags_changed = changes,
-		};
-
-		call_netdevice_notifiers_info(NETDEV_CHANGE, &change_info.info);
-	}
+	    (changes & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI | IFF_VOLATILE)))
+		__netdev_state_change(dev, changes);
 }
 
 /**