Skip to content

Commit a4310fa

Browse files
can: dev: can_get_echo_skb(): factor out non sending code to __can_get_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 <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent e05237f commit a4310fa

2 files changed

Lines changed: 26 additions & 11 deletions

File tree

drivers/net/can/dev.c

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,7 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
477477
}
478478
EXPORT_SYMBOL_GPL(can_put_echo_skb);
479479

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

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

498-
netif_rx(priv->echo_skb[idx]);
491+
*len_ptr = dlc;
499492
priv->echo_skb[idx] = NULL;
500493

501-
return dlc;
494+
return skb;
502495
}
503496

504-
return 0;
497+
return NULL;
498+
}
499+
500+
/*
501+
* Get the skb from the stack and loop it back locally
502+
*
503+
* The function is typically called when the TX done interrupt
504+
* is handled in the device driver. The driver must protect
505+
* access to priv->echo_skb, if necessary.
506+
*/
507+
unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx)
508+
{
509+
struct sk_buff *skb;
510+
u8 len;
511+
512+
skb = __can_get_echo_skb(dev, idx, &len);
513+
if (!skb)
514+
return 0;
515+
516+
netif_rx(skb);
517+
518+
return len;
505519
}
506520
EXPORT_SYMBOL_GPL(can_get_echo_skb);
507521

include/linux/can/dev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ void can_change_state(struct net_device *dev, struct can_frame *cf,
169169

170170
void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
171171
unsigned int idx);
172+
struct sk_buff *__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr);
172173
unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx);
173174
void can_free_echo_skb(struct net_device *dev, unsigned int idx);
174175

0 commit comments

Comments
 (0)