Skip to content

Commit

Permalink
cxgb3: Fix sparse warning and micro-optimize is_pure_response()
Browse files Browse the repository at this point in the history
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 <rolandd@cisco.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Roland Dreier authored and David S. Miller committed Nov 29, 2008
1 parent f95be18 commit c5419e6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/cxgb3/sge.c
Original file line number Diff line number Diff line change
Expand Up @@ -2306,7 +2306,7 @@ static int process_responses(struct adapter *adap, struct sge_qset *qs,

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;
}
Expand Down

0 comments on commit c5419e6

Please sign in to comment.