Re: [PATCH 3/4] thunderbolt: Add helpers to check if CL states are enabled on port

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Thanks,

Lukas



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux