]> git.karo-electronics.de Git - mv-sheeva.git/commit
can: provide library functions for skb allocation
authorWolfgang Grandegger <wg@grandegger.com>
Tue, 20 Oct 2009 07:08:01 +0000 (00:08 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 20 Oct 2009 07:08:01 +0000 (00:08 -0700)
commit7b6856a0296a8f187bb88ba31fa83a08abba7966
tree0afbcc9291eeb368e4e4616b6eed9062df646de0
parent0eae750e6019a93643063924209c1daf9cb9b4a7
can: provide library functions for skb allocation

This patch makes the private functions alloc_can_skb() and
alloc_can_err_skb() of the at91_can driver public and adapts all
drivers to use these. While making the patch I realized, that
the skb's are *not* setup consistently. It's now done as shown
below:

  skb->protocol = htons(ETH_P_CAN);
  skb->pkt_type = PACKET_BROADCAST;
  skb->ip_summed = CHECKSUM_UNNECESSARY;
  *cf = (struct can_frame *)skb_put(skb, sizeof(struct can_frame));
  memset(*cf, 0, sizeof(struct can_frame));

The frame is zeroed out to avoid uninitialized data to be passed to
user space. Some drivers or library code did not set "pkt_type" or
"ip_summed". Also,  "__constant_htons()" should not be used for
runtime invocations, as pointed out by David Miller.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/can/at91_can.c
drivers/net/can/dev.c
drivers/net/can/sja1000/sja1000.c
drivers/net/can/ti_hecc.c
drivers/net/can/usb/ems_usb.c
include/linux/can/dev.h