Skip to content

Commit

Permalink
net: switchdev: add SET_SWITCHDEV_OPS helper
Browse files Browse the repository at this point in the history
Add a helper to allow switchdev ops to be set if NET_SWITCHDEV is configured
and do nothing otherwise. This allows for slightly cleaner code which
uses switchdev but does not select NET_SWITCHDEV.

Signed-off-by: Simon Horman <[email protected]>
Acked-by: Ivan Vecera <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
shorman-netronome authored and davem330 committed Jul 1, 2017
1 parent 7f304b9 commit d643a75
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/net/switchdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ void switchdev_port_fwd_mark_set(struct net_device *dev,

bool switchdev_port_same_parent_id(struct net_device *a,
struct net_device *b);

#define SWITCHDEV_SET_OPS(netdev, ops) ((netdev)->switchdev_ops = (ops))
#else

static inline void switchdev_deferred_process(void)
Expand Down Expand Up @@ -322,6 +324,8 @@ static inline bool switchdev_port_same_parent_id(struct net_device *a,
return false;
}

#define SWITCHDEV_SET_OPS(netdev, ops) do {} while (0)

#endif

#endif /* _LINUX_SWITCHDEV_H_ */

0 comments on commit d643a75

Please sign in to comment.