diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2012-01-26 23:24:55 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-02-01 14:15:32 -0500 |
commit | b5d5843a1dd0031d63d9d9484346d86eae9cab3b (patch) | |
tree | 9b10561d8452ab3610df5737d086193db04aa4f5 /drivers/isdn/mISDN | |
parent | 658ddaaf6694adf63f67451dec9ddeb87a7cb2d7 (diff) |
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>
Diffstat (limited to 'drivers/isdn/mISDN')
-rw-r--r-- | drivers/isdn/mISDN/l1oip_core.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c index 22f8ec8b9247..04f115a9c43e 100644 --- a/drivers/isdn/mISDN/l1oip_core.c +++ b/drivers/isdn/mISDN/l1oip_core.c | |||
@@ -1112,7 +1112,7 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) | |||
1112 | struct l1oip *hc = bch->hw; | 1112 | struct l1oip *hc = bch->hw; |
1113 | int ret = -EINVAL; | 1113 | int ret = -EINVAL; |
1114 | struct mISDNhead *hh = mISDN_HEAD_P(skb); | 1114 | struct mISDNhead *hh = mISDN_HEAD_P(skb); |
1115 | int l, ll, i; | 1115 | int l, ll; |
1116 | unsigned char *p; | 1116 | unsigned char *p; |
1117 | 1117 | ||
1118 | switch (hh->prim) { | 1118 | switch (hh->prim) { |
@@ -1128,13 +1128,8 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) | |||
1128 | break; | 1128 | break; |
1129 | } | 1129 | } |
1130 | /* check for AIS / ulaw-silence */ | 1130 | /* check for AIS / ulaw-silence */ |
1131 | p = skb->data; | ||
1132 | l = skb->len; | 1131 | l = skb->len; |
1133 | for (i = 0; i < l; i++) { | 1132 | if (!memchr_inv(skb->data, 0xff, l)) { |
1134 | if (*p++ != 0xff) | ||
1135 | break; | ||
1136 | } | ||
1137 | if (i == l) { | ||
1138 | if (debug & DEBUG_L1OIP_MSG) | 1133 | if (debug & DEBUG_L1OIP_MSG) |
1139 | printk(KERN_DEBUG "%s: got AIS, not sending, " | 1134 | printk(KERN_DEBUG "%s: got AIS, not sending, " |
1140 | "but counting\n", __func__); | 1135 | "but counting\n", __func__); |
@@ -1144,13 +1139,8 @@ handle_bmsg(struct mISDNchannel *ch, struct sk_buff *skb) | |||
1144 | return 0; | 1139 | return 0; |
1145 | } | 1140 | } |
1146 | /* check for silence */ | 1141 | /* check for silence */ |
1147 | p = skb->data; | ||
1148 | l = skb->len; | 1142 | l = skb->len; |
1149 | for (i = 0; i < l; i++) { | 1143 | if (!memchr_inv(skb->data, 0x2a, l)) { |
1150 | if (*p++ != 0x2a) | ||
1151 | break; | ||
1152 | } | ||
1153 | if (i == l) { | ||
1154 | if (debug & DEBUG_L1OIP_MSG) | 1144 | if (debug & DEBUG_L1OIP_MSG) |
1155 | printk(KERN_DEBUG "%s: got silence, not sending" | 1145 | printk(KERN_DEBUG "%s: got silence, not sending" |
1156 | ", but counting\n", __func__); | 1146 | ", but counting\n", __func__); |