From patchwork Wed May 22 10:34:53 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: 164786 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp693993ili; Wed, 22 May 2019 03:35:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmf2KwH8n3rfCFk2ImSOZq1tF8Og5Z2MqRAexWhaHgv1JCQpulDt4O/as21JMZd/Sb0DaM X-Received: by 2002:a63:ee0a:: with SMTP id e10mr75299954pgi.28.1558521351414; Wed, 22 May 2019 03:35:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558521351; cv=none; d=google.com; s=arc-20160816; b=s5rz2KrymYpeGmzLqd5Z+Lz4Nd/1rFZGgKNdtShrf18j0a0ro8Oa/ZFbk/5Cj23gNJ mvZm0Zl9is6taLIXFINuG0kB84li91wiwc4kbXMWqt+TDrtu4iYZygAr1Svpvs1SLy0L IUQY2JxMS4pN/Bi5doSMGNrUJoHxCIVSPbeGHyOaKpkNsVcE/JYwLSRDSneetMjCOfsK fElYPptmMgwzB2dZKuAEyoGgTXCSK5EqFoK1gVedoSLc0GCvEwet+yqmUy0v4X2gVCZC QHnTIC8q8OImxFEyTfr8aCrj0WCOGaTGCQ++PdTOC7G7kkhL0tHW3/TQAZHqN1OgzhSt W9eQ== 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=fVQwicVDINt2dGSBfse1Q0GXEQ6pjnFIM4twy5LRiWFq3JPNKfsHScVpOetjq9U+b+ 8rCtL/sLG8RK8k80KZRCi0a6pADfDtEHvElp1fb50zAq4XfdCftVJx20mPjFixjNTUih Dz29qiz7IXk/8pWFcMv8ivNaHikseRWmRhfqvmcgJ3LiqXl6wzApb1K6mortSl6g/Fmo Hh+Gfdjepj2UDqIQw0ZIkBfI/rGGTHUIT8mA7MCtsGQg8pceUqpYLaA7C0LE28QoBj5/ zVHFesk2SxunA1QrqsZf0bSFkNsHLAzdtFwZCpex2s0OgzcE2StLNIrrXsagvsaVgc43 hjTA== 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 h68si25312309pgc.270.2019.05.22.03.35.50; Wed, 22 May 2019 03:35:51 -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 S1729450AbfEVKft (ORCPT + 30 others); Wed, 22 May 2019 06:35:49 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47128 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729398AbfEVKfo (ORCPT ); Wed, 22 May 2019 06:35:44 -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 4B7071684; Wed, 22 May 2019 03:35:44 -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 3BC1B3F575; Wed, 22 May 2019 03:35:43 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, coresight@lists.linaro.org, Suzuki K Poulose Subject: [PATCH v4 20/30] coresight: Cleanup coresight_remove_conns Date: Wed, 22 May 2019 11:34:53 +0100 Message-Id: <1558521304-27469-21-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558521304-27469-1-git-send-email-suzuki.poulose@arm.com> References: <1558521304-27469-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); } /**