tun: add tun_is_little_endian() helper
authorGreg Kurz <gkurz@linux.vnet.ibm.com>
Fri, 24 Apr 2015 12:24:38 +0000 (14:24 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 1 Jun 2015 13:48:50 +0000 (15:48 +0200)
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
drivers/net/tun.c

index e470ae59d40536fe7530774cb473ebe57000f9a8..301e87c89a9f432e86d37c60094f4a11138a49fd 100644 (file)
@@ -206,14 +206,19 @@ struct tun_struct {
        u32 flow_count;
 };
 
+static inline bool tun_is_little_endian(struct tun_struct *tun)
+{
+       return tun->flags & TUN_VNET_LE;
+}
+
 static inline u16 tun16_to_cpu(struct tun_struct *tun, __virtio16 val)
 {
-       return __virtio16_to_cpu(tun->flags & TUN_VNET_LE, val);
+       return __virtio16_to_cpu(tun_is_little_endian(tun), val);
 }
 
 static inline __virtio16 cpu_to_tun16(struct tun_struct *tun, u16 val)
 {
-       return __cpu_to_virtio16(tun->flags & TUN_VNET_LE, val);
+       return __cpu_to_virtio16(tun_is_little_endian(tun), val);
 }
 
 static inline u32 tun_hashfn(u32 rxhash)