[PATCH v1 4/5] coresight: Separate failure and success flows
Suzuki K Poulose
suzuki.poulose at arm.com
Thu Sep 11 03:03:06 PDT 2025
On 12/05/2025 16:41, Leo Yan wrote:
> For a success registration, it releases mutex, then binds associated CTI
> device, and returns a device pointer.
>
> As a result, it separates flows between the success case and the failure
> flow, any code after the tag 'out_unlock' is only used for failure
> handling.
>
This description is a bit ambiguous. Please could we simply say:
Subject: coresight: Cleanup coresight_register error handling
Separate the failure handling path from the successful case.
Use the out_unlock label only for the failure handling.
Rest looks fine to me.
Suzuki
> Signed-off-by: Leo Yan <leo.yan at arm.com>
> ---
> drivers/hwtracing/coresight/coresight-core.c | 20 ++++++++++++--------
> 1 file changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index 4f51ce152ac7..4fc82206b326 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -1377,17 +1377,21 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
> registered = true;
>
> ret = coresight_create_conns_sysfs_group(csdev);
> - if (!ret)
> - ret = coresight_fixup_orphan_conns(csdev);
> + if (ret)
> + goto out_unlock;
> +
> + ret = coresight_fixup_orphan_conns(csdev);
> + if (ret)
> + goto out_unlock;
> +
> + mutex_unlock(&coresight_mutex);
> +
> + if (cti_assoc_ops && cti_assoc_ops->add)
> + cti_assoc_ops->add(csdev);
> + return csdev;
>
> out_unlock:
> mutex_unlock(&coresight_mutex);
> - /* Success */
> - if (!ret) {
> - if (cti_assoc_ops && cti_assoc_ops->add)
> - cti_assoc_ops->add(csdev);
> - return csdev;
> - }
>
> /* Unregister the device if needed */
> if (registered) {
More information about the linux-arm-kernel
mailing list