[1/2] batman-adv: compat: add the case if dev is NULL
Commit Message
From: Yajun Deng <yajun.deng@linux.dev>
Add the case if dev is NULL in dev_{put, hold}, so the caller doesn't
need to care whether dev is NULL or not.
Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
Signed-off-by: David S. Miller <davem@davemloft.net>
[sven@narfation.org: Convert to compat code]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
compat-include/linux/netdevice.h | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
@@ -67,4 +67,27 @@ static inline int batadv_netif_rx_any_context(struct sk_buff *skb)
#endif /* LINUX_VERSION_IS_LESS(5, 10, 0) */
+
+#if LINUX_VERSION_IS_LESS(5, 15, 0)
+
+static inline void batadv_dev_put(struct net_device *dev)
+{
+ if (!dev)
+ return;
+
+ dev_put(dev);
+}
+#define dev_put batadv_dev_put
+
+static inline void batadv_dev_hold(struct net_device *dev)
+{
+ if (!dev)
+ return;
+
+ dev_hold(dev);
+}
+#define dev_hold batadv_dev_hold
+
+#endif /* LINUX_VERSION_IS_LESS(5, 15, 0) */
+
#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_NETDEVICE_H_ */