Commit 39e3ab6f authored by Wolfgang Grandegger's avatar Wolfgang Grandegger Committed by David S. Miller

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: default avatarWolfgang Grandegger <wg@grandegger.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fab4e763
...@@ -315,13 +315,29 @@ void can_get_echo_skb(struct net_device *dev, int idx) ...@@ -315,13 +315,29 @@ void can_get_echo_skb(struct net_device *dev, int idx)
{ {
struct can_priv *priv = netdev_priv(dev); struct can_priv *priv = netdev_priv(dev);
if ((dev->flags & IFF_ECHO) && priv->echo_skb[idx]) { if (priv->echo_skb[idx]) {
netif_rx(priv->echo_skb[idx]); netif_rx(priv->echo_skb[idx]);
priv->echo_skb[idx] = NULL; priv->echo_skb[idx] = NULL;
} }
} }
EXPORT_SYMBOL_GPL(can_get_echo_skb); EXPORT_SYMBOL_GPL(can_get_echo_skb);
/*
* Remove the skb from the stack and free it.
*
* The function is typically called when TX failed.
*/
void can_free_echo_skb(struct net_device *dev, int idx)
{
struct can_priv *priv = netdev_priv(dev);
if (priv->echo_skb[idx]) {
kfree_skb(priv->echo_skb[idx]);
priv->echo_skb[idx] = NULL;
}
}
EXPORT_SYMBOL_GPL(can_free_echo_skb);
/* /*
* CAN device restart for bus-off recovery * CAN device restart for bus-off recovery
*/ */
......
...@@ -66,5 +66,6 @@ void can_bus_off(struct net_device *dev); ...@@ -66,5 +66,6 @@ void can_bus_off(struct net_device *dev);
void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, int idx); void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, int idx);
void can_get_echo_skb(struct net_device *dev, int idx); void can_get_echo_skb(struct net_device *dev, int idx);
void can_free_echo_skb(struct net_device *dev, int idx);
#endif /* CAN_DEV_H */ #endif /* CAN_DEV_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment