2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-21 03:33:59 +08:00

mISDN: use memchr_inv

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>
This commit is contained in:
Akinobu Mita 2012-01-27 04:24:55 +00:00 committed by David S. Miller
parent 658ddaaf66
commit b5d5843a1d

View File

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