mISDN: use memchr_inv
authorAkinobu Mita <akinobu.mita@gmail.com>
Fri, 27 Jan 2012 04:24:55 +0000 (04:24 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 1 Feb 2012 19:15:32 +0000 (14:15 -0500)
Use memchr_inv to check if the data contains all same bytes.  It is
faster than looping for each byte.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Karsten Keil <isdn@linux-pingi.de>
Cc: netdev@vger.kernel.org
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/isdn/mISDN/l1oip_core.c

index 22f8ec8b9247af6de560b9bc1e095c66cf6668b5..04f115a9c43e02fe70fb3c9e718c59e0f0a49646 100644 (file)
@@ -1112,7 +1112,7 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb)
        struct l1oip                    *hc = bch->hw;
        int                     ret = -EINVAL;
        struct mISDNhead        *hh = mISDN_HEAD_P(skb);
-       int                     l, ll, i;
+       int                     l, ll;
        unsigned char           *p;
 
        switch (hh->prim) {
@@ -1128,13 +1128,8 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb)
                        break;
                }
                /* check for AIS / ulaw-silence */
-               p = skb->data;
                l = skb->len;
-               for (i = 0; i < l; i++) {
-                       if (*p++ != 0xff)
-                               break;
-               }
-               if (i == l) {
+               if (!memchr_inv(skb->data, 0xff, l)) {
                        if (debug & DEBUG_L1OIP_MSG)
                                printk(KERN_DEBUG "%s: got AIS, not sending, "
                                        "but counting\n", __func__);
@@ -1144,13 +1139,8 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb)
                        return 0;
                }
                /* check for silence */
-               p = skb->data;
                l = skb->len;
-               for (i = 0; i < l; i++) {
-                       if (*p++ != 0x2a)
-                               break;
-               }
-               if (i == l) {
+               if (!memchr_inv(skb->data, 0x2a, l)) {
                        if (debug & DEBUG_L1OIP_MSG)
                                printk(KERN_DEBUG "%s: got silence, not sending"
                                        ", but counting\n", __func__);