Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933072AbbLRQfq (ORCPT ); Fri, 18 Dec 2015 11:35:46 -0500 Received: from m50-134.163.com ([123.125.50.134]:41274 "EHLO m50-134.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932985AbbLRQfl (ORCPT ); Fri, 18 Dec 2015 11:35:41 -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] usb: gadget: rndis: use list_for_each_entry_safe Date: Sat, 19 Dec 2015 00:34:33 +0800 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: <1ec91b8ad8d81a446e08f3c4f15f2d3df620b186.1450455485.git.geliangtang@163.com> References: <1ec91b8ad8d81a446e08f3c4f15f2d3df620b186.1450455485.git.geliangtang@163.com> In-Reply-To: <1ec91b8ad8d81a446e08f3c4f15f2d3df620b186.1450455485.git.geliangtang@163.com> References: <1ec91b8ad8d81a446e08f3c4f15f2d3df620b186.1450455485.git.geliangtang@163.com> X-CM-TRANSID: DtGowEAJdEWqNXRW5n4fAA--.9492S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zw48GF18AFWfGF47Aw1xuFg_yoW8ur18pa 1rZw17Jr48GrnIvrWkWwsYqF43Z3s7Wr17Gay0k343Xr17AFsYgFyxCF1FgrWrtrZ8Cw4j qF4UKr45Kr4xAa7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U4wZcUUUUU= X-Originating-IP: [116.77.150.30] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiMAvUmVWBTMeGuwAAsU Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2218 Lines: 71 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 | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/usb/gadget/function/rndis.c b/drivers/usb/gadget/function/rndis.c index 70d3917..34a76db 100644 --- a/drivers/usb/gadget/function/rndis.c +++ b/drivers/usb/gadget/function/rndis.c @@ -914,7 +914,7 @@ struct rndis_params *rndis_register(void (*resp_avail)(void *v), void *v) params->media_state = RNDIS_MEDIA_STATE_DISCONNECTED; params->resp_avail = resp_avail; params->v = v; - INIT_LIST_HEAD(&(params->resp_queue)); + INIT_LIST_HEAD(¶ms->resp_queue); pr_debug("%s: configNr = %d\n", __func__, i); return params; @@ -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; @@ -1053,7 +1047,7 @@ static rndis_resp_t *rndis_add_response(struct rndis_params *params, u32 length) r->length = length; r->send = 0; - list_add_tail(&r->list, &(params->resp_queue)); + list_add_tail(&r->list, ¶ms->resp_queue); return r; } -- 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/