The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Leo Yan <leo.yan@arm.com>
To: Jie Gan <jie.gan@oss.qualcomm.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: Mon, 11 May 2026 15:45:56 +0100	[thread overview]
Message-ID: <20260511144556.GA34802@e132581.arm.com> (raw)
In-Reply-To: <146d34e9-caa3-4119-a3f3-79515b3f2c46@oss.qualcomm.com>

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].

[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?

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

  parent reply	other threads:[~2026-05-11 14:46 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 [this message]
2026-05-12  0:54       ` Jie Gan

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=20260511144556.GA34802@e132581.arm.com \
    --to=leo.yan@arm.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=coresight@lists.linaro.org \
    --cc=icheng@nvidia.com \
    --cc=james.clark@linaro.org \
    --cc=jie.gan@oss.qualcomm.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