]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
coresight: Extract device init into coresight_init_device()
authorLeo Yan <leo.yan@arm.com>
Fri, 15 May 2026 20:08:10 +0000 (21:08 +0100)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Mon, 18 May 2026 09:18:44 +0000 (10:18 +0100)
This commit extracts the allocation and initialization of the coresight
device structure into a separate function to make future extensions
easier.

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-3-f88c4a3ecfe9@arm.com
drivers/hwtracing/coresight/coresight-core.c

index 256f6a32621b8e086d02427317e5d35d0f29a3c9..d5d18168b48125c91f556f3867f0719592f0ccc8 100644 (file)
@@ -1334,20 +1334,16 @@ void coresight_release_platform_data(struct device *dev,
        devm_kfree(dev, pdata);
 }
 
-struct coresight_device *coresight_register(struct coresight_desc *desc)
+static struct coresight_device *
+coresight_init_device(struct coresight_desc *desc)
 {
-       int ret;
        struct coresight_device *csdev;
-       bool registered = false;
 
        csdev = kzalloc_obj(*csdev);
-       if (!csdev) {
-               ret = -ENOMEM;
-               goto err_out;
-       }
+       if (!csdev)
+               return ERR_PTR(-ENOMEM);
 
        csdev->pdata = desc->pdata;
-
        csdev->type = desc->type;
        csdev->subtype = desc->subtype;
        csdev->ops = desc->ops;
@@ -1360,6 +1356,21 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
        csdev->dev.release = coresight_device_release;
        csdev->dev.bus = &coresight_bustype;
 
+       return csdev;
+}
+
+struct coresight_device *coresight_register(struct coresight_desc *desc)
+{
+       int ret;
+       struct coresight_device *csdev;
+       bool registered = false;
+
+       csdev = coresight_init_device(desc);
+       if (IS_ERR(csdev)) {
+               ret = PTR_ERR(csdev);
+               goto err_out;
+       }
+
        if (csdev->type == CORESIGHT_DEV_TYPE_SINK ||
            csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) {
                raw_spin_lock_init(&csdev->perf_sink_id_map.lock);