Skip to content

Commit

Permalink
can: add can_free_echo_skb() for upcoming drivers
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Wolfgang Grandegger authored and David S. Miller committed Sep 4, 2009
1 parent fab4e76 commit 39e3ab6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion drivers/net/can/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,29 @@ void can_get_echo_skb(struct net_device *dev, int idx)
{
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]);
priv->echo_skb[idx] = NULL;
}
}
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
*/
Expand Down
1 change: 1 addition & 0 deletions include/linux/can/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_get_echo_skb(struct net_device *dev, int idx);
void can_free_echo_skb(struct net_device *dev, int idx);

#endif /* CAN_DEV_H */

0 comments on commit 39e3ab6

Please sign in to comment.