From: Jie Gan <jie.gan@oss.qualcomm.com>
To: Leo Yan <leo.yan@arm.com>
Cc: Richard Cheng <icheng@nvidia.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Mike Leach <mike.leach@arm.com>,
James Clark <james.clark@linaro.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Tingwei Zhang <tingwei.zhang@oss.qualcomm.com>,
coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] coresight: fix missing error code when trace ID is invalid
Date: Tue, 12 May 2026 08:54:59 +0800 [thread overview]
Message-ID: <eb008f96-41bf-441d-9b16-1ceb79e2ccaf@oss.qualcomm.com> (raw)
In-Reply-To: <20260511144556.GA34802@e132581.arm.com>
On 5/11/2026 10:45 PM, Leo Yan wrote:
> On Mon, May 11, 2026 at 05:27:10PM +0800, Jie Gan wrote:
>
> [...]
>
>>>> @@ -755,10 +755,16 @@ void coresight_path_assign_trace_id(struct coresight_path *path,
>>>> * Non 0 is either success or fail.
>>>> */
>>>> if (trace_id != 0) {
>>>> - path->trace_id = trace_id;
>>>> - return;
>>>> + if (IS_VALID_CS_TRACE_ID(trace_id)) {
>>>> + path->trace_id = trace_id;
>>>> + return 0;
>>>> + }
>>>> +
>>>> + return -EINVAL;
>
> I'd advocate a bit early exit style, like:
>
> /* 0 means the device has no ID assignment, so keep searching */
> if (trace_id == 0)
> continue;
>
> if (!IS_VALID_CS_TRACE_ID(trace_id))
> return -EINVAL;
>
> path->trace_id = trace_id;
> return 0;
>
> Early exit can reduce indentation depth, and it handles simple cases
> first and then the complex logic. In some cases (maye not this case),
> we may benefit a bit from compiler optimization [1].
>
Thanks, that's a good suggestion and much simpler than my solution.
> [1] https://xania.org/202512/18-partial-inlining
>
> [...]
>
>> The return value has been ignored in perf mode. It will introduce noisy by
>> adding __must_check. So I think its better without __must_check?
>
> Wouldn't it need to update perf mode as well?
I will also update the perf mode for consistent usage.
Thanks,
Jie
>
> Regarding __must_check, I searched Documentation but didn't find
> guidance on when it should be used. I don't want to use this annotation
> randomly (some functions use it and some not), this will be hard for
> everyone to follow up.
>
> IMO, it's fine not to use __must_check here. I would leave this to
> Suzuki and other maintainers if have different opinions.
>
> Thanks,
> Leo
prev parent reply other threads:[~2026-05-12 0:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 8:36 [PATCH v3] coresight: fix missing error code when trace ID is invalid Jie Gan
2026-05-11 9:19 ` Richard Cheng
2026-05-11 9:27 ` Jie Gan
2026-05-11 10:26 ` Richard Cheng
2026-05-11 14:45 ` Leo Yan
2026-05-12 0:54 ` Jie Gan [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=eb008f96-41bf-441d-9b16-1ceb79e2ccaf@oss.qualcomm.com \
--to=jie.gan@oss.qualcomm.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=coresight@lists.linaro.org \
--cc=icheng@nvidia.com \
--cc=james.clark@linaro.org \
--cc=leo.yan@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.leach@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=tingwei.zhang@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox