From patchwork Tue May 7 10:52:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suzuki K Poulose X-Patchwork-Id: 163505 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:81:0:0:0:0 with SMTP id l1csp1185257ilm; Tue, 7 May 2019 03:55:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxR3dJ02SNNz0hjWYbFP7edRRbmCaizIorSrVw08Z1BPP2pS2lI9WbfCJiTvVFsvgQmsLRQ X-Received: by 2002:a63:db48:: with SMTP id x8mr1878509pgi.114.1557226533533; Tue, 07 May 2019 03:55:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557226533; cv=none; d=google.com; s=arc-20160816; b=NfFfbw2mSaxxDBkd60qef+jK1dZOhTb7s6vv+rA6PcPAFQuFImeM//NY8YvuqfEGCl 23z5maif8OWQlqvnUP8ZX1XyFD39lEbiB+SHI8123fukeHzJLQ3965PS2C9x8lRrSYKu AeFwGC9tdMymZ5RQNdWzdbZeuGGfiQt1N+Ruu/6PqQ58i8XEJPdkX+9BpvlRZTHzx1Ob kzs5ulpVo+gcVOlnEO9UHgxMpIOGUqsHY790U62xhQDk1UHKyH+9kGtuZUF0H1ARt5RV OqTufansD6bpnUfuMc5085lPnxzpjowh/djJUmidmVKAH1Khcr2kuZ01bORWEK5yrhHD zoeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=clH9z4yLWyirkK5ZTjw7XqgFFzoUHi0sO5pmeN6f1Eo=; b=LlvkQZFXv9jaw2DZLWrSttfUiXcDJtUp76mEjnER4O+gPfbW7buRzxr7SJ+9+7MLFd QaLPWr5jNCqOMPD0leZxqKa43ExY2xFqF+IngJARqP0TQMFomDAHjStXOz1QqZdOI1Xb xNOt3JH3yAR2bL5rVfPi7zYYm31uChVz1pExoCEEMsXiF+bc+vytmlC1PODuUfrCtWvO 9xNOPkmaIss8BEfcEjjGqwmhrEaPomyFXVnzO1EoPQLg8QJLOs58pThwV49fFwktoJFS Ddhv5wcxQiGKAy3N0e6pR6QHQWe4dh//jtICWpfRJLKqcDbUCLJQlqq9FSIKES/AlS8X e0+Q== 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 n22si19207493pgl.425.2019.05.07.03.55.33; Tue, 07 May 2019 03:55:33 -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 S1727217AbfEGKzb (ORCPT + 30 others); Tue, 7 May 2019 06:55:31 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50258 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727087AbfEGKyK (ORCPT ); Tue, 7 May 2019 06:54:10 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 28A77168F; Tue, 7 May 2019 03:54:10 -0700 (PDT) Received: from en101.cambridge.arm.com (en101.cambridge.arm.com [10.1.196.93]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E9E283F5AF; Tue, 7 May 2019 03:54:08 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, coresight@lists.linaro.org, rjw@rjwysocki.net, mathieu.poirier@linaro.org, Suzuki K Poulose Subject: [PATCH v3 20/30] coresight: Cleanup coresight_remove_conns Date: Tue, 7 May 2019 11:52:47 +0100 Message-Id: <1557226378-10131-21-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1557226378-10131-1-git-send-email-suzuki.poulose@arm.com> References: <1557226378-10131-1-git-send-email-suzuki.poulose@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a device is unregistered, we remove all connection references to it, by searching the connection records of all devices in the coresight bus, via coresight_remove_conns. We could avoid searching if this device doesn't have an input port (e.g, a source). Also document the purpose of the function. Reviewed-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 04b5d3c..068bd2f 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1096,10 +1096,21 @@ static int coresight_remove_match(struct device *dev, void *data) return 0; } +/* + * coresight_remove_conns - Remove references to this given devices + * from the connections of other devices. + */ static void coresight_remove_conns(struct coresight_device *csdev) { - bus_for_each_dev(&coresight_bustype, NULL, - csdev, coresight_remove_match); + /* + * Another device will point to this device only if there is + * an output port connected to this one. i.e, if the device + * doesn't have at least one input port, there is no point + * in searching all the devices. + */ + if (csdev->nr_inport) + bus_for_each_dev(&coresight_bustype, NULL, + csdev, coresight_remove_match); } /**