Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754643AbbLWNxW (ORCPT ); Wed, 23 Dec 2015 08:53:22 -0500 Received: from m50-132.163.com ([123.125.50.132]:55198 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753270AbbLWNxU (ORCPT ); Wed, 23 Dec 2015 08:53:20 -0500 From: Geliang Tang To: Felipe Balbi , Greg Kroah-Hartman , Andrzej Pietrasiewicz Cc: Geliang Tang , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/9 v2] usb: gadget: rndis: use list_for_each_entry_safe Date: Wed, 23 Dec 2015 21:51:46 +0800 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: <878u4mpdb3.fsf@saruman.tx.rr.com> X-CM-TRANSID: DNGowEDpyEP3pnpW6Sp_AA--.2045S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zw48Aryxuw17GF18WFWrAFb_yoW8GFW5pF 45Aa47Gr48CwnIqrWkWws5uF43Z397Wry7KFWjk343Xr17Ar4vgry2k3WFgrZ0qrZ8Aw4a qF4UGryrKr48ua7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U4OJOUUUUU= X-Originating-IP: [116.77.148.162] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiGRnZmVXlQGu9oQAAsH Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1608 Lines: 53 Use list_for_each_entry_safe() instead of list_for_each_safe() to simplify the code. Signed-off-by: Geliang Tang --- drivers/usb/gadget/function/rndis.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c index 70d3917..13280f5 100644 --- a/drivers/usb/gadget/function/rndis.c +++ b/drivers/usb/gadget/function/rndis.c @@ -1006,12 +1006,9 @@ EXPORT_SYMBOL_GPL(rndis_add_hdr); void rndis_free_response(struct rndis_params *params, u8 *buf) { - rndis_resp_t *r; - struct list_head *act, *tmp; + rndis_resp_t *r, *n; - list_for_each_safe(act, tmp, &(params->resp_queue)) - { - r = list_entry(act, rndis_resp_t, list); + list_for_each_entry_safe(r, n, ¶ms->resp_queue, list) { if (r && r->buf == buf) { list_del(&r->list); kfree(r); @@ -1022,14 +1019,11 @@ EXPORT_SYMBOL_GPL(rndis_free_response); u8 *rndis_get_next_response(struct rndis_params *params, u32 *length) { - rndis_resp_t *r; - struct list_head *act, *tmp; + rndis_resp_t *r, *n; if (!length) return NULL; - list_for_each_safe(act, tmp, &(params->resp_queue)) - { - r = list_entry(act, rndis_resp_t, list); + list_for_each_entry_safe(r, n, ¶ms->resp_queue, list) { if (!r->send) { r->send = 1; *length = r->length; -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/