memcpy(skb_put(skb, sizeof(*head)), head, sizeof(*head));
- /* can_frames starting here */
+ if (head->nframes) {
+ /* can_frames starting here */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
- firstframe = (struct can_frame *) skb_tail_pointer(skb);
+ firstframe = (struct can_frame *) skb_tail_pointer(skb);
#else
- firstframe = (struct can_frame *) skb->tail;
+ firstframe = (struct can_frame *) skb->tail;
#endif
+ memcpy(skb_put(skb, datalen), frames, datalen);
+
+ /*
+ * the BCM uses the can_dlc-element of the can_frame
+ * structure for internal purposes. This is only
+ * relevant for updates that are generated by the
+ * BCM, where nframes is 1
+ */
+ if (head->nframes == 1)
+ firstframe->can_dlc &= BCM_CAN_DLC_MASK;
+ }
+
if (has_timestamp) {
/* restore rx timestamp */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
addr->can_family = AF_CAN;
addr->can_ifindex = op->rx_ifindex;
- if (head->nframes) {
- memcpy(skb_put(skb, datalen), frames, datalen);
-
- /*
- * the BCM uses the can_dlc-element of the can_frame
- * structure for internal purposes. This is only
- * relevant for updates that are generated by the
- * BCM, where nframes is 1
- */
- if (head->nframes == 1)
- firstframe->can_dlc &= BCM_CAN_DLC_MASK;
- }
-
err = sock_queue_rcv_skb(sk, skb);
if (err < 0) {
struct bcm_sock *bo = bcm_sk(sk);