coresight: Extract device init into coresight_init_device()

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
This commit is contained in:
Leo Yan 2026-05-15 21:08:10 +01:00 committed by Suzuki K Poulose
parent 864754d0a0
commit 10be00dd73

View 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);