From patchwork Tue Sep 1 15:26:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Grandegger X-Patchwork-Id: 32751 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id F2430B7B7B for ; Wed, 2 Sep 2009 01:27:14 +1000 (EST) Received: by ozlabs.org (Postfix) id E44A4DDD0B; Wed, 2 Sep 2009 01:27:14 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 72EE9DDD04 for ; Wed, 2 Sep 2009 01:27:14 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754575AbZIAP0R (ORCPT ); Tue, 1 Sep 2009 11:26:17 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754399AbZIAP0P (ORCPT ); Tue, 1 Sep 2009 11:26:15 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:47577 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754497AbZIAP0O (ORCPT ); Tue, 1 Sep 2009 11:26:14 -0400 Received: from mail01.m-online.net (mail.m-online.net [192.168.3.149]) by mail-out.m-online.net (Postfix) with ESMTP id 487BF1C153E2; Tue, 1 Sep 2009 17:26:15 +0200 (CEST) X-Auth-Info: 1zeH6O5DwlYKmaqgkevVPlb+K7O9Z0U5+xarXV1O2Ls= Received: from lancy.denx.de (p4FF06838.dip.t-dialin.net [79.240.104.56]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-auth.mnet-online.de (Postfix) with ESMTP id C6CC4901A8; Tue, 1 Sep 2009 17:26:14 +0200 (CEST) Message-ID: <4A9D3D14.90201@grandegger.com> Date: Tue, 01 Sep 2009 17:26:12 +0200 From: Wolfgang Grandegger User-Agent: Thunderbird 2.0.0.21 (X11/20090320) MIME-Version: 1.0 To: Linux Netdev List CC: SocketCAN Core Mailing List Subject: [PATCH net-next] can: add can_free_echo_skb() for upcoming drivers X-Enigmail-Version: 0.96.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- drivers/net/can/dev.c | 18 +++++++++++++++++- include/linux/can/dev.h | 1 + 2 files changed, 18 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: net-next-2.6/drivers/net/can/dev.c =================================================================== --- net-next-2.6.orig/drivers/net/can/dev.c +++ net-next-2.6/drivers/net/can/dev.c @@ -315,7 +315,7 @@ void can_get_echo_skb(struct net_device { 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; } @@ -323,6 +323,22 @@ void can_get_echo_skb(struct net_device 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 */ void can_restart(unsigned long data) Index: net-next-2.6/include/linux/can/dev.h =================================================================== --- net-next-2.6.orig/include/linux/can/dev.h +++ net-next-2.6/include/linux/can/dev.h @@ -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 */