From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16903378D8E for ; Mon, 9 Feb 2026 12:45:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770641101; cv=none; b=JAUZbWHtNp3UBVY3I+e++fFJrzWJy6MyZcq7kQLIJf5tw1tO8B5Ue3MpmJUHwqDSHxqJoCYQs0nz5kWStN5oj7lkr3OZEE3y7zg3OfJnp0m8im+y+O43h16iuF1/4A2hGPaWn20N+zmdLtHgQkZGiMp+a5Rn4YjIcLkpzzp9wtU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770641101; c=relaxed/simple; bh=0BVGBg6d33Awn2mw01YUWbBB/6WKd5fYtSeWWsOZfMQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hZGJCW6wgHNZI/48GpCxmY7DuxVlO5zbmnbQfgm9h3bvFs/zdu9ctNBgFSxrm6ZG0fdlb8sStFheNwp7jGJKdFyrNxX/5G/bQdf057+pjHNfEYoMzmrTpKdN3eODFbbgj5SXxGiCGVvqu+6subJkWYSmyxOwVfO2RDE5/9TyYG0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 44176339; Mon, 9 Feb 2026 04:44:54 -0800 (PST) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D8F233F63F; Mon, 9 Feb 2026 04:44:58 -0800 (PST) From: Leo Yan Date: Mon, 09 Feb 2026 12:44:36 +0000 Subject: [PATCH v4 4/8] coresight: Refactor output connection sysfs link cleanup Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260209-arm_coresight_refactor_dev_register-v4-4-62d6042f76f7@arm.com> References: <20260209-arm_coresight_refactor_dev_register-v4-0-62d6042f76f7@arm.com> In-Reply-To: <20260209-arm_coresight_refactor_dev_register-v4-0-62d6042f76f7@arm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Greg Kroah-Hartman , Mathieu Poirier , Mao Jinlong Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1770641090; l=2629; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=0BVGBg6d33Awn2mw01YUWbBB/6WKd5fYtSeWWsOZfMQ=; b=FiSSHlFmany0fDyo3NevpVBqNw1wgU2jrjaesLo+t9Iu8DZBxT7Eq364TSWKFokt5JzO5eQKj XczHH9VKczZBE0dknYSCNs67NjpoOQaOnrZxo65O3wWgIF2le1x1I9Y X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= To use a central place for releasing connections, move the output connection sysfs link cleanup into coresight_remove_conns(). Also update the comments accordingly. Reviewed-by: James Clark Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-core.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 5aa178b4def336770ae2b7647372174345564776..4b2cc1806c4f9cdd8a22dbce930973aef41f00c6 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1152,7 +1152,6 @@ static int coresight_clear_filter_source(struct device *dev, void *data) return 0; } -/* coresight_remove_conns - Remove other device's references to this device */ static void coresight_remove_conns(struct coresight_device *csdev) { int i, j; @@ -1162,10 +1161,6 @@ static void coresight_remove_conns(struct coresight_device *csdev) bus_for_each_dev(&coresight_bustype, NULL, csdev, coresight_clear_filter_source); - /* - * Remove the input connection references from the destination device - * for each output connection. - */ for (i = 0; i < csdev->pdata->nr_outconns; i++) { conn = csdev->pdata->out_conns[i]; if (conn->filter_src_fwnode) { @@ -1176,6 +1171,13 @@ static void coresight_remove_conns(struct coresight_device *csdev) if (!conn->dest_dev) continue; + /* Remove sysfs links for the output connection */ + coresight_remove_links(csdev, conn); + + /* + * Remove the input connection references from the destination + * device for each output connection. + */ for (j = 0; j < conn->dest_dev->pdata->nr_inconns; ++j) if (conn->dest_dev->pdata->in_conns[j] == conn) { conn->dest_dev->pdata->in_conns[j] = NULL; @@ -1306,9 +1308,6 @@ void coresight_release_platform_data(struct coresight_device *csdev, struct coresight_connection **conns = pdata->out_conns; for (i = 0; i < pdata->nr_outconns; i++) { - /* If we have made the links, remove them now */ - if (csdev && conns[i]->dest_dev) - coresight_remove_links(csdev, conns[i]); /* * Drop the refcount and clear the handle as this device * is going away @@ -1424,7 +1423,6 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) } err_out: - /* Cleanup the connection information */ coresight_release_platform_data(NULL, desc->dev, desc->pdata); return ERR_PTR(ret); } -- 2.34.1