All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: Lukas Wunner <lukas@wunner.de>
Cc: linux-usb@vger.kernel.org,
	Yehezkel Bernat <YehezkelShB@gmail.com>,
	Michael Jamet <michael.jamet@intel.com>,
	Andreas Noever <andreas.noever@gmail.com>
Subject: Re: [PATCH 3/4] thunderbolt: Add helpers to check if CL states are enabled on port
Date: Wed, 24 Aug 2022 11:33:00 +0300	[thread overview]
Message-ID: <YwXiPPRT1brWHCIv@black.fi.intel.com> (raw)
In-Reply-To: <20220823140216.GA28421@wunner.de>

Hi Lukas,

On Tue, Aug 23, 2022 at 04:02:16PM +0200, Lukas Wunner wrote:
> On Tue, Aug 23, 2022 at 01:53:51PM +0300, Mika Westerberg wrote:
> > +/**
> > + * tb_port_is_clx_enabled() - Is given CL state enabled
> > + * @port: USB4 port to check
> > + * @clx: CL state to check
> > + *
> > + * Returns true if given CL state is enabled for @port.
> > + */
> > +bool tb_port_is_clx_enabled(struct tb_port *port, enum tb_clx clx)
> > +{
> > +	u32 phy, mask = LANE_ADP_CS_1_CL0S_ENABLE | LANE_ADP_CS_1_CL1_ENABLE;
> > +	int ret;
> > +
> > +	if (!tb_port_clx_supported(port, clx))
> > +		return false;
> > +
> > +	ret = tb_port_read(port, &phy, TB_CFG_PORT,
> > +			   port->cap_phy + LANE_ADP_CS_1, 1);
> > +	if (ret)
> > +		return false;
> > +
> > +	return (phy & mask) == mask;
> > +}
> > +
> [...]
> > +static inline bool tb_port_are_clx_enabled(struct tb_port *port)
> > +{
> > +	return tb_port_is_clx_enabled(port, TB_CL1) ||
> > +	       tb_port_is_clx_enabled(port, TB_CL2);
> > +}
> 
> If you change enum tb_clx to use "power of two" values (0 1 2 4 8 ...)
> then you could just pass a bitmask to tb_port_is_clx_enabled()
> and thus need only a single invocation in tb_port_are_clx_enabled().
> Just a thought.

Sure good point. I'll do that in v2 thanks!

  reply	other threads:[~2022-08-24  8:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-23 10:53 [PATCH 0/4] thunderbolt: Add support for receiver lane margining Mika Westerberg
2022-08-23 10:53 ` [PATCH 1/4] thunderbolt: Move tb_xdomain_parent() to tb.h Mika Westerberg
2022-08-23 10:53 ` [PATCH 2/4] thunderbolt: Move port CL state functions into correct place in switch.c Mika Westerberg
2022-08-23 10:53 ` [PATCH 3/4] thunderbolt: Add helpers to check if CL states are enabled on port Mika Westerberg
2022-08-23 14:02   ` Lukas Wunner
2022-08-24  8:33     ` Mika Westerberg [this message]
2022-08-23 10:53 ` [PATCH 4/4] thunderbolt: Add support for receiver lane margining Mika Westerberg

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=YwXiPPRT1brWHCIv@black.fi.intel.com \
    --to=mika.westerberg@linux.intel.com \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=linux-usb@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=michael.jamet@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.