Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: add can_free_echo_skb() for upcoming drivers

This patch adds the function can_free_echo_skb to the CAN
device interface to allow upcoming drivers to release echo
skb's in case of error.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Wolfgang Grandegger and committed by
David S. Miller
39e3ab6f fab4e763

+18 -1
+17 -1
drivers/net/can/dev.c
··· 315 315 { 316 316 struct can_priv *priv = netdev_priv(dev); 317 317 318 - if ((dev->flags & IFF_ECHO) && priv->echo_skb[idx]) { 318 + if (priv->echo_skb[idx]) { 319 319 netif_rx(priv->echo_skb[idx]); 320 320 priv->echo_skb[idx] = NULL; 321 321 } 322 322 } 323 323 EXPORT_SYMBOL_GPL(can_get_echo_skb); 324 + 325 + /* 326 + * Remove the skb from the stack and free it. 327 + * 328 + * The function is typically called when TX failed. 329 + */ 330 + void can_free_echo_skb(struct net_device *dev, int idx) 331 + { 332 + struct can_priv *priv = netdev_priv(dev); 333 + 334 + if (priv->echo_skb[idx]) { 335 + kfree_skb(priv->echo_skb[idx]); 336 + priv->echo_skb[idx] = NULL; 337 + } 338 + } 339 + EXPORT_SYMBOL_GPL(can_free_echo_skb); 324 340 325 341 /* 326 342 * CAN device restart for bus-off recovery
+1
include/linux/can/dev.h
··· 66 66 67 67 void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, int idx); 68 68 void can_get_echo_skb(struct net_device *dev, int idx); 69 + void can_free_echo_skb(struct net_device *dev, int idx); 69 70 70 71 #endif /* CAN_DEV_H */