public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Caleb Connolly <caleb@connolly.tech>
Cc: Alim Akhtar <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	ejb@linux.ibm.com, stanley.chu@mediatek.com, cang@codeaurora.org,
	beanhuo@micron.com, jaegeuk@kernel.org, asutoshd@codeaurora.org,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 1/3] scsi: ufshcd: switch to a version macro
Date: Mon, 8 Mar 2021 09:00:14 +0100	[thread overview]
Message-ID: <20210308080013.GE983@lst.de> (raw)
In-Reply-To: <20210308005739.1998483-2-caleb@connolly.tech>

This looks like a really nice improvement!

A bunch of comments below:

> @@ -696,10 +685,21 @@ static inline u32 ufshcd_get_intr_mask(struct ufs_hba *hba)
>   */
>  static inline u32 ufshcd_get_ufs_version(struct ufs_hba *hba)
>  {
> +	u32 ufshci_ver;

missing eempty line after the declaration.

>  	if (hba->quirks & UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION)
> +		ufshci_ver = ufshcd_vops_get_ufs_hci_version(hba);
> +	else
> +		ufshci_ver = ufshcd_readl(hba, REG_UFS_VERSION);
>  
> +	/*
> +	 * UFSHCI v1.x uses a different version scheme, in order
> +	 * to allow the use of comparisons with the UFSHCI_VER
> +	 * macro, we convert it to the same scheme as ufs 2.0+.
> +	 */
> +	if (ufshci_ver & 0x00010000)
> +		ufshci_ver = UFSHCI_VER(1, ufshci_ver & 0x00000100);
> +
> +	return ufshci_ver;

I'd use early returns here to clean this up a bit:

 	if (hba->quirks & UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION)
		ufshci_ver = ufshcd_vops_get_ufs_hci_version(hba);

	...
	ufshci_ver = ufshcd_readl(hba, REG_UFS_VERSION);
	if (ufshci_ver & 0x00010000)
		return UFSHCI_VER(1, ufshci_ver & 0x00000100);
	return ufshci_ver;

> +#define UFSHCI_VER(major, minor) \
> +	((major << 8) + (minor << 4))

This needs braces around major and minor.  Or better just convert it
to an inline function (and use a lower case name).

  reply	other threads:[~2021-03-08  8:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-08  0:58 scsi: ufshcd: use a macro for UFS versions Caleb Connolly
2021-03-08  0:58 ` [PATCH 1/3] scsi: ufshcd: switch to a version macro Caleb Connolly
2021-03-08  8:00   ` Christoph Hellwig [this message]
2021-03-08 10:42     ` Caleb Connolly
2021-03-09  9:32       ` Christoph Hellwig
2021-03-08  0:58 ` [PATCH 2/3] scsi: ufs: qcom: use UFSHCI_VER macro Caleb Connolly
2021-03-08  0:59 ` [PATCH 3/3] scsi: ufshcd: remove version check Caleb Connolly

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=20210308080013.GE983@lst.de \
    --to=hch@lst.de \
    --cc=alim.akhtar@samsung.com \
    --cc=asutoshd@codeaurora.org \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=caleb@connolly.tech \
    --cc=cang@codeaurora.org \
    --cc=ejb@linux.ibm.com \
    --cc=jaegeuk@kernel.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stanley.chu@mediatek.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