Skip to content

Commit

Permalink
can: dev: can_get_echo_skb(): factor out non sending code to __can_ge…
Browse files Browse the repository at this point in the history
…t_echo_skb()

This patch factors out all non sending parts of can_get_echo_skb() into
a seperate function __can_get_echo_skb(), so that it can be re-used in
an upcoming patch.

Cc: linux-stable <stable@vger.kernel.org>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
marckleinebudde committed Nov 9, 2018
1 parent e05237f commit a4310fa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
36 changes: 25 additions & 11 deletions drivers/net/can/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,7 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
}
EXPORT_SYMBOL_GPL(can_put_echo_skb);

/*
* Get the skb from the stack and loop it back locally
*
* The function is typically called when the TX done interrupt
* is handled in the device driver. The driver must protect
* access to priv->echo_skb, if necessary.
*/
unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr)
{
struct can_priv *priv = netdev_priv(dev);

Expand All @@ -495,13 +488,34 @@ unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
struct can_frame *cf = (struct can_frame *)skb->data;
u8 dlc = cf->can_dlc;

netif_rx(priv->echo_skb[idx]);
*len_ptr = dlc;
priv->echo_skb[idx] = NULL;

return dlc;
return skb;
}

return 0;
return NULL;
}

/*
* Get the skb from the stack and loop it back locally
*
* The function is typically called when the TX done interrupt
* is handled in the device driver. The driver must protect
* access to priv->echo_skb, if necessary.
*/
unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
{
struct sk_buff *skb;
u8 len;

skb = __can_get_echo_skb(dev, idx, &len);
if (!skb)
return 0;

netif_rx(skb);

return len;
}
EXPORT_SYMBOL_GPL(can_get_echo_skb);

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 @@ -169,6 +169,7 @@ void can_change_state(struct net_device *dev, struct can_frame *cf,

void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
unsigned int idx);
struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr);
unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx);
void can_free_echo_skb(struct net_device *dev, unsigned int idx);

Expand Down

0 comments on commit a4310fa

Please sign in to comment.