* [PATCH] mISDN: use memchr_inv
[not found] <1327674295-3700-1-git-send-email-akinobu.mita@gmail.com>
@ 2012-01-27 14:24 ` Akinobu Mita
2012-02-01 19:15 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Akinobu Mita @ 2012-01-27 14:24 UTC (permalink / raw)
To: linux-kernel, akpm; +Cc: Akinobu Mita, Karsten Keil, netdev
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
---
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 22f8ec8..04f115a 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)
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__);
--
1.7.4.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mISDN: use memchr_inv
2012-01-27 14:24 ` [PATCH] mISDN: use memchr_inv Akinobu Mita
@ 2012-02-01 19:15 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-02-01 19:15 UTC (permalink / raw)
To: akinobu.mita; +Cc: linux-kernel, akpm, isdn, netdev
From: Akinobu Mita <akinobu.mita@gmail.com>
Date: Fri, 27 Jan 2012 23:24:55 +0900
> 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>
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-01 19:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1327674295-3700-1-git-send-email-akinobu.mita@gmail.com>
2012-01-27 14:24 ` [PATCH] mISDN: use memchr_inv Akinobu Mita
2012-02-01 19:15 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).