Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp309167ybm; Wed, 22 May 2019 03:37:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxb5Pz+TfbFmzofJiZF6bGcObJ/TXx9tp6yK5y0gGduzSyH43jiOaG7luQwTcHbM57pdvyo X-Received: by 2002:a17:902:b941:: with SMTP id h1mr30911769pls.289.1558521452666; Wed, 22 May 2019 03:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558521452; cv=none; d=google.com; s=arc-20160816; b=kabyttbyt926iD6UHLpCUD/oPhtMGB0fVpLHUu8AXPF68J+0oBaZ2ktnuYQb/zzSf1 IqlDSs+RA59q3pz9F1DkZBM0aidxafDfMETAV4AFZtnr9G/bRRq0Thg+jskAss2ZC8sl PlGGumfA0LFOyQqS3MDfgk8d9Jz3bDydlXUoXIO//MbF5oH3nLdNr2uhRgHUqxFQGZdA LYzcqS1g3lLlqaLsr6IHQsiz/j5FyF0b6OMagOSjUETVi22AuIiOPj160L5xZOki1EWd RaIdvJ5DG4THsE0NeOM2FGmxPazKB+1n4ONei5Xp2idzl23+OqpzsoBvw90hH4Q56r3x uA/Q== 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 37si25139738pgs.8.2019.05.22.03.37.17; Wed, 22 May 2019 03:37:32 -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 S1729446AbfEVKfs (ORCPT + 99 others); Wed, 22 May 2019 06:35:48 -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(-) 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); } /** -- 2.7.4