Commit 6b1ffc54 authored by Leo Yan's avatar Leo Yan Committed by Suzuki K Poulose
Browse files

coresight: Move sink validation into etm_perf_add_symlink_sink()



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: default avatarJames Clark <james.clark@linaro.org>
Signed-off-by: default avatarLeo Yan <leo.yan@arm.com>
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260209-arm_coresight_refactor_dev_register-v4-6-62d6042f76f7@arm.com
parent babb9879
Loading
Loading
Loading
Loading
+9 −14
Original line number Diff line number Diff line
@@ -1383,22 +1383,17 @@ 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);

		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().
	 * 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;

+4 −1
Original line number Diff line number Diff line
@@ -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;