Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp169809imd; Fri, 26 Oct 2018 06:52:13 -0700 (PDT) X-Google-Smtp-Source: AJdET5cGPpesgJG1DIsaP9SOwznKR/ciXU7MV3XArxMshMGj+fh3C8gyuQFD63KXNYEX6c+rsBfh X-Received: by 2002:a62:4151:: with SMTP id o78-v6mr3842929pfa.66.1540561933499; Fri, 26 Oct 2018 06:52:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540561933; cv=none; d=google.com; s=arc-20160816; b=CQuAKWT58y3xzTqNhaDAk4oOC3Eq6rIK1IAn8NIwDyR3yGB5GR+G1KRVTGFXEdEoGP wsybeh1FqCcr4LJl3clx6Tfzg53Qgc90vu7CX5ZLpG4qwOfLma4tYlJ4jnDY+/UlxIUU jjXw8/VTZ6jze6y+9+6TSW2eNbDit/iP57+8m3M30hLGqSKZW8mhvCvPYKSjaHKZ8CLp OuRThLGHqmp5EpLfz5dTE9Qc+IkZMwfLJ0vRchnI169vHSaP+EtCuvLb/+N3cNKs13C9 ENMKijMHTQg1ErWRNsfY5pKqZ1EzoAINnWapYuesmcjgbaO+ZzcenanIASajdJgxdOFb aZoQ== 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=v4Q8jgtXsYjNUBIrXW2LuEskiL2aS5QM3bhTgMfqzy0=; b=KCp4y2bAN7gu9WJbxfFlNsxNt0RS93GUbXonZkq56l0MjQbMjsns7l7QEmqSNdYo6x IIcD+qLOWEB6QVuN15kDAdF+jBFZKDbcLVofa0cEUkG9kV+HKE89v+YnPnDgUig5wFK6 kvWEVRInSJzLJkJmlhpO8+Dw7p1WgwWipo0K+Z0gXmk3f7x9wSk++uwij6Oa8hI/umso Ai1BSlUoLJO6jvB3X6FN0v2Xvk/seglybh8smFzWbkaBnuHbzLmePeisrB14XqxzJJrk y0Yg2SfH9ROLxRxqdupOc9qRJLsfIIvgloqI38V31XumKj2q9nxSt73b5nGpQj5xsJYE WQBg== 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 k3-v6si5224158pld.25.2018.10.26.06.51.58; Fri, 26 Oct 2018 06:52:13 -0700 (PDT) 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 S1727477AbeJZWZn (ORCPT + 99 others); Fri, 26 Oct 2018 18:25:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:44822 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726998AbeJZWZn (ORCPT ); Fri, 26 Oct 2018 18:25:43 -0400 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 05961B01F; Fri, 26 Oct 2018 13:48:33 +0000 (UTC) From: Nicolas Saenz Julienne To: stefan.wahren@i2se.com, eric@anholt.net, dave.stevenson@raspberrypi.org Cc: nsaenzjulienne@suse.de, linux-rpi-kernel@lists.infradead.org, gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH RFC 04/18] stagning: vchiq_arm: use list_for_each_entry when accessing bulk_waiter_list Date: Fri, 26 Oct 2018 15:47:59 +0200 Message-Id: <20181026134813.7775-5-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181026134813.7775-1-nsaenzjulienne@suse.de> References: <20181026134813.7775-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 d88dd7415e1e..5f55c708ade8 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) { @@ -2158,16 +2143,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