]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
coresight: Use helpers to fetch first and last nodes
authorLeo Yan <leo.yan@arm.com>
Fri, 15 May 2026 20:08:24 +0000 (21:08 +0100)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Mon, 18 May 2026 09:18:46 +0000 (10:18 +0100)
Replace open code with coresight_path_first_node() and
coresight_path_last_node() for fetching the nodes.

Check that the node is not NULL before accessing csdev field.

Tested-by: Jie Gan <jie.gan@oss.qualcomm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Tested-by: James Clark <james.clark@linaro.org>
Signed-off-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260515-arm_coresight_path_power_management_improvement-v14-17-f88c4a3ecfe9@arm.com
drivers/hwtracing/coresight/coresight-core.c

index 62a12a90988949ccc8c181c8edde7939e4f986ab..61ae7b6c7a836caafaf87787af91a1f5326c16ec 100644 (file)
@@ -174,11 +174,16 @@ void coresight_put_percpu_source_ref(struct coresight_device *csdev)
 struct coresight_device *coresight_get_source(struct coresight_path *path)
 {
        struct coresight_device *csdev;
+       struct coresight_node *nd;
 
        if (!path)
                return NULL;
 
-       csdev = list_first_entry(&path->path_list, struct coresight_node, link)->csdev;
+       nd = coresight_path_first_node(path);
+       if (!nd)
+               return NULL;
+
+       csdev = nd->csdev;
        if (!coresight_is_device_source(csdev))
                return NULL;
 
@@ -711,11 +716,16 @@ int coresight_enable_path(struct coresight_path *path, enum cs_mode mode)
 struct coresight_device *coresight_get_sink(struct coresight_path *path)
 {
        struct coresight_device *csdev;
+       struct coresight_node *nd;
 
        if (!path)
                return NULL;
 
-       csdev = list_last_entry(&path->path_list, struct coresight_node, link)->csdev;
+       nd = coresight_path_last_node(path);
+       if (!nd)
+               return NULL;
+
+       csdev = nd->csdev;
        if (csdev->type != CORESIGHT_DEV_TYPE_SINK &&
            csdev->type != CORESIGHT_DEV_TYPE_LINKSINK)
                return NULL;