Linux CXL
 help / color / mirror / Atom feed
From: Alison Schofield <alison.schofield@intel.com>
To: Dave Jiang <dave.jiang@intel.com>
Cc: linux-cxl@vger.kernel.org, dan.j.williams@intel.com,
	ira.weiny@intel.com, vishal.l.verma@intel.com
Subject: Re: [PATCH] cxl: update var names for interleave ways conversion macros
Date: Tue, 11 Oct 2022 18:15:02 -0700	[thread overview]
Message-ID: <Y0YVFqSAv4Pf10wi@aschofie-mobl2> (raw)
In-Reply-To: <166552461397.1940763.17766745890158322847.stgit@djiang5-desk3.ch.intel.com>

On Tue, Oct 11, 2022 at 02:43:33PM -0700, Dave Jiang wrote:
> Change var names for interleave ways macros to clearly indicate which
> variable is encoded and which is the actual ways value.
> 
> iw == interleave ways
> eniw == encoded interleave ways
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  drivers/cxl/cxl.h |   22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/cxl/cxl.h b/drivers/cxl/cxl.h
> index 7a4f740d710c..c0d826084465 100644
> --- a/drivers/cxl/cxl.h
> +++ b/drivers/cxl/cxl.h
> @@ -78,14 +78,14 @@ static inline int cxl_to_granularity(u16 enig, unsigned int *ig)
>  }
>  
>  /* Encode defined in CXL ECN "3, 6, 12 and 16-way memory Interleaving" */
> -static inline int cxl_to_ways(u8 eniw, unsigned int *val)
> +static inline int cxl_to_ways(u8 eniw, unsigned int *iw)

How about -
+static inline int cxl_eniw_to_ways(u8 eniw, unsigned int *ways)
+static inline int cxl_ways_to_eniw(unsigned int ways, u8 *eniw)

and similarly for granularity.

I think 'ways' (same with 'granularity') is used more in the drivers,
although core/region.c uses iw often.

What you have is certainly clearer, so just chiming in here.

Alison

>  {
>  	switch (eniw) {
>  	case 0 ... 4:
> -		*val = 1 << eniw;
> +		*iw = 1 << eniw;
>  		break;
>  	case 8 ... 10:
> -		*val = 3 << (eniw - 8);
> +		*iw = 3 << (eniw - 8);
>  		break;
>  	default:
>  		return -EINVAL;
> @@ -102,20 +102,20 @@ static inline int granularity_to_cxl(int ig, u16 *enig)
>  	return 0;
>  }
>  
> -static inline int ways_to_cxl(unsigned int ways, u8 *iw)
> +static inline int ways_to_cxl(unsigned int iw, u8 *eniw)
>  {
> -	if (ways > 16)
> +	if (iw > 16)
>  		return -EINVAL;
> -	if (is_power_of_2(ways)) {
> -		*iw = ilog2(ways);
> +	if (is_power_of_2(iw)) {
> +		*eniw = ilog2(iw);
>  		return 0;
>  	}
> -	if (ways % 3)
> +	if (iw % 3)
>  		return -EINVAL;
> -	ways /= 3;
> -	if (!is_power_of_2(ways))
> +	iw /= 3;
> +	if (!is_power_of_2(iw))
>  		return -EINVAL;
> -	*iw = ilog2(ways) + 8;
> +	*eniw = ilog2(iw) + 8;
>  	return 0;
>  }
>  
> 
> 

  reply	other threads:[~2022-10-12  1:15 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-11 21:43 [PATCH] cxl: update var names for interleave ways conversion macros Dave Jiang
2022-10-12  1:15 ` Alison Schofield [this message]
2022-10-12 15:47   ` Dave Jiang
2022-10-12  1:18 ` Alison Schofield
2022-10-12 12:45   ` Jonathan Cameron
2022-10-12 15:47   ` Dave Jiang

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=Y0YVFqSAv4Pf10wi@aschofie-mobl2 \
    --to=alison.schofield@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=ira.weiny@intel.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=vishal.l.verma@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox