Merge tag 'dt' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
[platform/adaptation/renesas_rcar/renesas_kernel.git] / include / net / dsfield.h
index eb65bf2..e1ad903 100644 (file)
 #include <asm/byteorder.h>
 
 
-static inline __u8 ipv4_get_dsfield(struct iphdr *iph)
+static inline __u8 ipv4_get_dsfield(const struct iphdr *iph)
 {
        return iph->tos;
 }
 
 
-static inline __u8 ipv6_get_dsfield(struct ipv6hdr *ipv6h)
+static inline __u8 ipv6_get_dsfield(const struct ipv6hdr *ipv6h)
 {
-       return ntohs(*(__be16 *) ipv6h) >> 4;
+       return ntohs(*(const __be16 *)ipv6h) >> 4;
 }
 
 
@@ -43,11 +43,9 @@ static inline void ipv4_change_dsfield(struct iphdr *iph,__u8 mask,
 static inline void ipv6_change_dsfield(struct ipv6hdr *ipv6h,__u8 mask,
     __u8 value)
 {
-        __u16 tmp;
+       __be16 *p = (__force __be16 *)ipv6h;
 
-       tmp = ntohs(*(__be16 *) ipv6h);
-       tmp = (tmp & ((mask << 4) | 0xf00f)) | (value << 4);
-       *(__be16 *) ipv6h = htons(tmp);
+       *p = (*p & htons((((u16)mask << 4) | 0xf00f))) | htons((u16)value << 4);
 }