Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp859282imu; Tue, 20 Nov 2018 08:02:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/UbW90776XEj4190uI04P04OlHSqq00qeor5RcdvvaiZyJSKJNkKyThRCmcrGqx6jmoWT5H X-Received: by 2002:a17:902:2c03:: with SMTP id m3mr2134441plb.125.1542729764531; Tue, 20 Nov 2018 08:02:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542729764; cv=none; d=google.com; s=arc-20160816; b=WmRt1KOjmSgEI9bzVpXHRgzaUsxb/5tn/K2fUyxGAj0J3Cyvptb+5JDcz4VhbI66ij yaHGdJqTS1kEpUcdv8SjMIagnwHH3B8mhi55R/9coT7G+KoG0MSUWsa3p2BLcDvCHk+r 1TMDyAT+0IQaX/yFshzqwxIullecVUDKn6z1fJ449us6n3m98XWhxEE5HGn99w4G+2iN P0dsUez+kuIrD70k968BoiQPBzD6/tT+xilWPFtg1ZSq8Yp7EqtknZHmWWqheSPx7oIS qCU1UXVXU85f8ItS44USdtlQwUTuIZ2zEF0b7Pt9H9Sj/Jnj9ZAI5bcoegKENkgUwq5t Eezw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tPRU31NBL3qVJeyVJHHIUW+utFSrORLZLmC5v0uJpNk=; b=k69jutL+QuYwjYRba/H7a96Z6ZQ/ihJeAW+mt/6n4I8txlA9zXurCwje3oKEa12KQx Hjcn41mpd/jbGPeWFQ53m7jb6tYHl7zzPnFeW0z/I4Pq6VVaD+THuDniEg/gNlIREXTR xYnYl9ujG0lzcQLuEbfQB6/ZzPLYeIBva/LLZlHBuVL5ZSBkYSXRDVBT2weCSoBa/rnv j9+tjasnBBzd+8Uw3Kz7YgE3RaR0D8p9FaPyMD+hBJAJq2qH6rjZDlXc3aPABow+J7J7 HTPMtpkLGGFzBAZZ9XpyUDRPvHhcMCgnF4jBjTTaCVqSU6rr0EGgE5poGfJ/Qbmfs5Wo Ze9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j10si43435158pgt.155.2018.11.20.08.02.27; Tue, 20 Nov 2018 08:02:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729484AbeKUBXl (ORCPT + 99 others); Tue, 20 Nov 2018 20:23:41 -0500 Received: from mx2.suse.de ([195.135.220.15]:39242 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727969AbeKUBXk (ORCPT ); Tue, 20 Nov 2018 20:23:40 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6D435AD33; Tue, 20 Nov 2018 14:54:07 +0000 (UTC) From: Nicolas Saenz Julienne To: stefan.wahren@i2se.com, eric@anholt.net, dave.stevenson@raspberrypi.org Cc: linux-rpi-kernel@lists.infradead.org, gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Nicolas Saenz Julienne Subject: [PATCH 04/16] staging: vchiq_arm: use list_for_each_entry when accessing bulk_waiter_list Date: Tue, 20 Nov 2018 15:53:39 +0100 Message-Id: <20181120145351.30390-5-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181120145351.30390-1-nsaenzjulienne@suse.de> References: <20181120145351.30390-1-nsaenzjulienne@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The resulting code is way more readeable and intuitive compared to plain list_for_each. Signed-off-by: Nicolas Saenz Julienne --- .../interface/vchiq_arm/vchiq_arm.c | 52 ++++++------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 835152799433..76de36e9e3b6 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -280,16 +280,11 @@ VCHIQ_STATUS_T vchiq_shutdown(VCHIQ_INSTANCE_T instance) "%s(%p): returning %d", __func__, instance, status); if (status == VCHIQ_SUCCESS) { - struct list_head *pos, *next; + struct bulk_waiter_node *waiter, *next; - list_for_each_safe(pos, next, - &instance->bulk_waiter_list) { - struct bulk_waiter_node *waiter; - - waiter = list_entry(pos, - struct bulk_waiter_node, - list); - list_del(pos); + list_for_each_entry_safe(waiter, next, + &instance->bulk_waiter_list, list) { + list_del(&waiter->list); vchiq_log_info(vchiq_arm_log_level, "bulk_waiter - cleaned up %pK for pid %d", waiter, waiter->pid); @@ -473,7 +468,6 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, VCHIQ_SERVICE_T *service; VCHIQ_STATUS_T status; struct bulk_waiter_node *waiter = NULL; - struct list_head *pos; service = find_service_by_handle(handle); if (!service) @@ -484,13 +478,9 @@ vchiq_blocking_bulk_transfer(VCHIQ_SERVICE_HANDLE_T handle, void *data, unlock_service(service); mutex_lock(&instance->bulk_waiter_list_mutex); - list_for_each(pos, &instance->bulk_waiter_list) { - if (list_entry(pos, struct bulk_waiter_node, - list)->pid == current->pid) { - waiter = list_entry(pos, - struct bulk_waiter_node, - list); - list_del(pos); + list_for_each_entry(waiter, &instance->bulk_waiter_list, list) { + if (waiter->pid == current->pid) { + list_del(&waiter->list); break; } } @@ -1135,21 +1125,16 @@ vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ret = -ENOMEM; break; } + args.userdata = &waiter->bulk_waiter; } else if (args.mode == VCHIQ_BULK_MODE_WAITING) { - struct list_head *pos; - mutex_lock(&instance->bulk_waiter_list_mutex); - list_for_each(pos, &instance->bulk_waiter_list) { - if (list_entry(pos, struct bulk_waiter_node, - list)->pid == current->pid) { - waiter = list_entry(pos, - struct bulk_waiter_node, - list); - list_del(pos); + list_for_each_entry(waiter, &instance->bulk_waiter_list, + list) { + if (waiter->pid == current->pid) { + list_del(&waiter->list); break; } - } mutex_unlock(&instance->bulk_waiter_list_mutex); if (!waiter) { @@ -2163,16 +2148,11 @@ vchiq_release(struct inode *inode, struct file *file) vchiq_release_internal(instance->state, NULL); { - struct list_head *pos, *next; - - list_for_each_safe(pos, next, - &instance->bulk_waiter_list) { - struct bulk_waiter_node *waiter; + struct bulk_waiter_node *waiter, *next; - waiter = list_entry(pos, - struct bulk_waiter_node, - list); - list_del(pos); + list_for_each_entry_safe(waiter, next, + &instance->bulk_waiter_list, list) { + list_del(&waiter->list); vchiq_log_info(vchiq_arm_log_level, "bulk_waiter - cleaned up %pK for pid %d", waiter, waiter->pid); -- 2.19.1