linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] aoe: Convert use of __constant_<foo> to <foo>
@ 2015-06-19  3:15 Vaishali Thakkar
  2015-06-20  0:45 ` Ed Cashin
  0 siblings, 1 reply; 2+ messages in thread
From: Vaishali Thakkar @ 2015-06-19  3:15 UTC (permalink / raw)
  To: Ed L. Cashin; +Cc: linux-kernel

In little endian cases, the macros htons and cpu_to_be16 unfolds
to __swab16 which provides special case for constants. In big
endian cases, __constant_htons and htons expand directly to the
same expression. The same applies for __constant_cpu_to_be16 and
cpu_to_be16.

So, replace __constant_htons with htons and __constant_cpu_to_be16
with cpu_to_be16 with the goal of getting rid of the definitions
__constant_htons and __constant_cpu_to_be16 completely.

The semantic patch that performs this transformation is as follows:

@@expression x;@@

(
- __constant_htons(x)
+ htons(x)
|
- __constant_cpu_to_be16(x)
+ cpu_to_be16(x)
)

Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
---
 drivers/block/aoe/aoecmd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
index 422b7d8..6e891d2 100644
--- a/drivers/block/aoe/aoecmd.c
+++ b/drivers/block/aoe/aoecmd.c
@@ -69,7 +69,7 @@ new_skb(ulong len)
 		skb_reserve(skb, MAX_HEADER);
 		skb_reset_mac_header(skb);
 		skb_reset_network_header(skb);
-		skb->protocol = __constant_htons(ETH_P_AOE);
+		skb->protocol = htons(ETH_P_AOE);
 		skb_checksum_none_assert(skb);
 	}
 	return skb;
@@ -132,7 +132,7 @@ aoehdr_atainit(struct aoedev *d, struct aoetgt *t, struct aoe_hdr *h)
 
 	memcpy(h->src, t->ifp->nd->dev_addr, sizeof h->src);
 	memcpy(h->dst, t->addr, sizeof h->dst);
-	h->type = __constant_cpu_to_be16(ETH_P_AOE);
+	h->type = cpu_to_be16(ETH_P_AOE);
 	h->verfl = AOE_HVER;
 	h->major = cpu_to_be16(d->aoemajor);
 	h->minor = d->aoeminor;
@@ -437,7 +437,7 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *qu
 
 		memset(h->dst, 0xff, sizeof h->dst);
 		memcpy(h->src, ifp->dev_addr, sizeof h->src);
-		h->type = __constant_cpu_to_be16(ETH_P_AOE);
+		h->type = cpu_to_be16(ETH_P_AOE);
 		h->verfl = AOE_HVER;
 		h->major = cpu_to_be16(aoemajor);
 		h->minor = aoeminor;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] aoe: Convert use of __constant_<foo> to <foo>
  2015-06-19  3:15 [PATCH] aoe: Convert use of __constant_<foo> to <foo> Vaishali Thakkar
@ 2015-06-20  0:45 ` Ed Cashin
  0 siblings, 0 replies; 2+ messages in thread
From: Ed Cashin @ 2015-06-20  0:45 UTC (permalink / raw)
  To: Vaishali Thakkar; +Cc: linux-kernel

OK.  Thanks.

On 06/18/2015 11:15 PM, Vaishali Thakkar wrote:
> In little endian cases, the macros htons and cpu_to_be16 unfolds
> to __swab16 which provides special case for constants. In big
> endian cases, __constant_htons and htons expand directly to the
> same expression. The same applies for __constant_cpu_to_be16 and
> cpu_to_be16.
>
> So, replace __constant_htons with htons and __constant_cpu_to_be16
> with cpu_to_be16 with the goal of getting rid of the definitions
> __constant_htons and __constant_cpu_to_be16 completely.
>
> The semantic patch that performs this transformation is as follows:
>
> @@expression x;@@
>
> (
> - __constant_htons(x)
> + htons(x)
> |
> - __constant_cpu_to_be16(x)
> + cpu_to_be16(x)
> )
>
> Signed-off-by: Vaishali Thakkar <vthakkar1994@gmail.com>
> ---
>   drivers/block/aoe/aoecmd.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c
> index 422b7d8..6e891d2 100644
> --- a/drivers/block/aoe/aoecmd.c
> +++ b/drivers/block/aoe/aoecmd.c
> @@ -69,7 +69,7 @@ new_skb(ulong len)
>   		skb_reserve(skb, MAX_HEADER);
>   		skb_reset_mac_header(skb);
>   		skb_reset_network_header(skb);
> -		skb->protocol = __constant_htons(ETH_P_AOE);
> +		skb->protocol = htons(ETH_P_AOE);
>   		skb_checksum_none_assert(skb);
>   	}
>   	return skb;
> @@ -132,7 +132,7 @@ aoehdr_atainit(struct aoedev *d, struct aoetgt *t, struct aoe_hdr *h)
>   
>   	memcpy(h->src, t->ifp->nd->dev_addr, sizeof h->src);
>   	memcpy(h->dst, t->addr, sizeof h->dst);
> -	h->type = __constant_cpu_to_be16(ETH_P_AOE);
> +	h->type = cpu_to_be16(ETH_P_AOE);
>   	h->verfl = AOE_HVER;
>   	h->major = cpu_to_be16(d->aoemajor);
>   	h->minor = d->aoeminor;
> @@ -437,7 +437,7 @@ aoecmd_cfg_pkts(ushort aoemajor, unsigned char aoeminor, struct sk_buff_head *qu
>   
>   		memset(h->dst, 0xff, sizeof h->dst);
>   		memcpy(h->src, ifp->dev_addr, sizeof h->src);
> -		h->type = __constant_cpu_to_be16(ETH_P_AOE);
> +		h->type = cpu_to_be16(ETH_P_AOE);
>   		h->verfl = AOE_HVER;
>   		h->major = cpu_to_be16(aoemajor);
>   		h->minor = aoeminor;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-20  0:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-19  3:15 [PATCH] aoe: Convert use of __constant_<foo> to <foo> Vaishali Thakkar
2015-06-20  0:45 ` Ed Cashin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).