]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
coresight: Move sink validation into etm_perf_add_symlink_sink()
authorLeo Yan <leo.yan@arm.com>
Mon, 9 Feb 2026 12:44:38 +0000 (12:44 +0000)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Wed, 25 Feb 2026 11:14:44 +0000 (11:14 +0000)
Move the sink device type checks into etm_perf_add_symlink_sink(), and
return -EOPNOTSUPP for unsupported devices.  This simplifies the
registration flow to invoke etm_perf_add_symlink_sink() unconditionally.

Reviewed-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/20260209-arm_coresight_refactor_dev_register-v4-6-62d6042f76f7@arm.com
drivers/hwtracing/coresight/coresight-core.c
drivers/hwtracing/coresight/coresight-etm-perf.c

index 34439ca98d8d3c98319572f6f691a4446afc768e..6ddbc773330e592036ca45c84eeb46cc034670cb 100644 (file)
@@ -1383,21 +1383,16 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
                goto out_unlock;
        }
 
-       if ((csdev->type == CORESIGHT_DEV_TYPE_SINK ||
-            csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) &&
-           sink_ops(csdev)->alloc_buffer) {
-               ret = etm_perf_add_symlink_sink(csdev);
+       ret = etm_perf_add_symlink_sink(csdev);
 
-               if (ret) {
-                       device_unregister(&csdev->dev);
-                       /*
-                        * As with the above, all resources are free'd
-                        * explicitly via coresight_device_release() triggered
-                        * from put_device(), which is in turn called from
-                        * function device_unregister().
-                        */
-                       goto out_unlock;
-               }
+       /*
+        * As with the above, all resources are free'd explicitly via
+        * coresight_device_release() triggered from put_device(), which is in
+        * turn called from function device_unregister().
+        */
+       if (ret && ret != -EOPNOTSUPP) {
+               device_unregister(&csdev->dev);
+               goto out_unlock;
        }
        /* Device is now registered */
        registered = true;
index 72017dcc3b7f1fd16da58f17b566997563462a88..f85dedf89a3f9e85d568ca4c320fa6fa6d9059ff 100644 (file)
@@ -902,7 +902,10 @@ int etm_perf_add_symlink_sink(struct coresight_device *csdev)
 
        if (csdev->type != CORESIGHT_DEV_TYPE_SINK &&
            csdev->type != CORESIGHT_DEV_TYPE_LINKSINK)
-               return -EINVAL;
+               return -EOPNOTSUPP;
+
+       if (!sink_ops(csdev)->alloc_buffer)
+               return -EOPNOTSUPP;
 
        if (csdev->ea != NULL)
                return -EINVAL;