From: Roland Dreier Date: Sat, 29 Nov 2008 05:55:42 +0000 (-0800) Subject: cxgb3: Fix sparse warning and micro-optimize is_pure_response() X-Git-Tag: v3.12-rc1~16879^2~357 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c5419e6f054c877339f754e02c3b1dafd88cd96c;p=kernel%2Fkernel-generic.git cxgb3: Fix sparse warning and micro-optimize is_pure_response() The function is_pure_response() does "ntohl(var) & const" and then essentially just tests whether the result is 0 or not; this can be done more efficiently by computing "var & htonl(const)" instead and doing the byte swap at compile time instead of run time. This change slightly shrinks the compiled code; eg on x86-64 we save a couple of bswapl instructions: add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-8 (-8) function old new delta t3_sge_intr_msix_napi 544 536 -8 and this also has the pleasant side effect of fixing a sparse warning: drivers/net/cxgb3/sge.c:2313:15: warning: restricted degrades to integer Signed-off-by: Roland Dreier Signed-off-by: David S. Miller --- diff --git a/drivers/net/cxgb3/sge.c b/drivers/net/cxgb3/sge.c index bc6a8dc..d3a6e24 100644 --- a/drivers/net/cxgb3/sge.c +++ b/drivers/net/cxgb3/sge.c @@ -2306,7 +2306,7 @@ next_fl: static inline int is_pure_response(const struct rsp_desc *r) { - u32 n = ntohl(r->flags) & (F_RSPD_ASYNC_NOTIF | F_RSPD_IMM_DATA_VALID); + __be32 n = r->flags & htonl(F_RSPD_ASYNC_NOTIF | F_RSPD_IMM_DATA_VALID); return (n | r->len_cq) == 0; }