From patchwork Mon Apr 15 16:04:06 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: 10901219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D75D314DB for ; Mon, 15 Apr 2019 16:33:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B93842897E for ; Mon, 15 Apr 2019 16:33:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4BE628988; Mon, 15 Apr 2019 16:33:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4FBE928987 for ; Mon, 15 Apr 2019 16:33:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=QLKsC9s8Ga+Rf+GV/tGY5b293yrVP1YO0hp2pvZZOqo=; b=J0UtnFZRJjo1G1q8S+qN8HZNS1 58UyOUnpQ/4hM7QfbKct8xlr3rVa32QcR/pP2SuzEx2inypNoac8CucRZxR7qRMR9am9Ohbo+kHAe Lc19vU/J7ljI8vva+T7QvKnrU2IuYVQZCuiaNy0lOAD4vzVigiRf8Nf1FJWL/csrDLjQYCNgmq43h Id6V619Ptrj7KO4U8kUQC+1f4fFvBKRPbku5juPs21fzoH3lKUozi1CRDbcPepqhivQvblQEb8z4d 07W1VI1+5TWPyqmY+EDQTXT9Gf8qkpwuQH7oWAK3VDoxjIDGw1DWtCUW0tN2KxJS7u4HdWrlPxvSY 4HavZWiw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hG4XZ-0006BN-NS; Mon, 15 Apr 2019 16:33:05 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hG4Vq-0003me-KR for linux-arm-kernel@bombadil.infradead.org; Mon, 15 Apr 2019 16:31:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=A7QNmln8poZlbVc+qbMrbSEzPfmS2GxM0Wh6cJiPCIE=; b=YIa0RwIzD2nbU8rlsSIY0IRoL u2Vf9GD0PP+5SmY+qWosAE/3df9J6nKyyFclB4XrnIoJJg137kPdz4OSdUJ+EYpXa6vOXiP1kmfVH RasjAr/ZMEfSRCpO9Ew1NRJC0yfT5nCnYbaE0eHyPjaW9c8Ueh7EmFGCRcGwOdy7QXs+3ZJIsj04T fyln+BgIWVJxcI4rjR6d5D+z00pMj6t7VCzc7QXwwkkiNP/pIy3fS2CPKv0P0pUf95K6fdxOGZkYj BVhKFILMwSuuSOtJlV8UsfV3nydqpj7HmMbK01SRaPwojWkl+i4PlvuPfmnkOXclQS1Q+ov6x4tk/ QsduGxHZw==; Received: from foss.arm.com ([217.140.101.70]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hG47n-0002hu-MH for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2019 16:06:28 +0000 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 34B6F1A25; Mon, 15 Apr 2019 09:06:25 -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 AE3DC3F68F; Mon, 15 Apr 2019 09:06:23 -0700 (PDT) From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 23/36] coresight: Cleanup coresight_remove_conns Date: Mon, 15 Apr 2019 17:04:06 +0100 Message-Id: <1555344260-12375-24-git-send-email-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1555344260-12375-1-git-send-email-suzuki.poulose@arm.com> References: <1555344260-12375-1-git-send-email-suzuki.poulose@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190415_120627_830060_D1B23E70 X-CRM114-Status: GOOD ( 15.15 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mathieu.poirier@linaro.org, Suzuki K Poulose , coresight@lists.linaro.org, rjw@rjwysocki.net, linux-kernel@vger.kernel.org, robert.walker@arm.com, mike.leach@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: 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 91c63cd..530ad69 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1094,10 +1094,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); } /**