Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6649026imu; Wed, 14 Nov 2018 05:02:32 -0800 (PST) X-Google-Smtp-Source: AJdET5drW7K5Uzuq0p++mCVdMvZCvW1B8jStUnkNgdGUeWI6kN0joAQEj1MRa8abnp1R6ooQSBM1 X-Received: by 2002:a62:ca12:: with SMTP id n18-v6mr1838428pfg.191.1542200552148; Wed, 14 Nov 2018 05:02:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542200552; cv=none; d=google.com; s=arc-20160816; b=V2Tvt+Q+UuoTTB+V6PAmpZVHdmBWQEOuuC5CQ4dzcYaESfh5E4kOzAGIZbQk/AP9HR y9vxRhVBi0I4imcTKV31u0r4eOi+H7tbuzP1ukt51evckC/M3F13rAxs4AGjgf0zHvWk LLIHl/qwJ95NfceyUy/O9wW6TU0+VfvWT080MSi5VqZRT8blDxVtULLFrozFthgLaWAQ aVlxsl7GlTAA3woHn+5JmY307RX/sFb+El2TJXPlOx+oJPJTDvx/6n8jgzG+6PePZG2A G0rzrhVZ31jw67U00AgXwrsDYrf12qkFkqp5EVh1se9Pz3y9QM1w/ak8dpqlLdWLXRyw a/uw== 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=IwGK8ghxsPiTC2E2MeT6d0JnyTAh4k+SxDJ1KDlh9zlTa2BSRMPkyGdjCd7hQ8FZwE THQ8tAZha74fav7frdpxFzK3H1ZvGGvnTRlDhVqTHU53Vao0QDLEBKnWboiUvuSvWg3b qEffX9ZirNVD41dN2Ezu1E98m/Ckk3S+KtxE7kMZk/V6AlNqSWa7cwveqs7v2VRNnFGe VQQHh9xLYjs9MwGrn1ZPmVlvEkTg7BC8WkP+fw+9Lx0uGNlP3jROGtM1+URWY5ITQ++E E7tjw/QgOMjJG2eW/fmYaGmX4KmCzZoqB9VEQ+sMxE0ufb6e7vDF72pLHXx1uEu8K5YG vzVA== 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 y10-v6si23969627plt.145.2018.11.14.05.02.16; Wed, 14 Nov 2018 05:02:32 -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 S1732822AbeKNXDa (ORCPT + 99 others); Wed, 14 Nov 2018 18:03:30 -0500 Received: from mx2.suse.de ([195.135.220.15]:44554 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728343AbeKNXD2 (ORCPT ); Wed, 14 Nov 2018 18:03:28 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id C0E4EB0DB; Wed, 14 Nov 2018 13:00:17 +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: Wed, 14 Nov 2018 13:59:30 +0100 Message-Id: <20181114125942.25163-5-nsaenzjulienne@suse.de> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181114125942.25163-1-nsaenzjulienne@suse.de> References: <20181114125942.25163-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