[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210308080013.GE983@lst.de>
Date: Mon, 8 Mar 2021 09:00:14 +0100
From: Christoph Hellwig <hch@....de>
To: Caleb Connolly <caleb@...nolly.tech>
Cc: Alim Akhtar <alim.akhtar@...sung.com>,
Avri Altman <avri.altman@....com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
ejb@...ux.ibm.com, stanley.chu@...iatek.com, cang@...eaurora.org,
beanhuo@...ron.com, jaegeuk@...nel.org, asutoshd@...eaurora.org,
linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
Christoph Hellwig <hch@....de>
Subject: Re: [PATCH 1/3] scsi: ufshcd: switch to a version macro
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).
Powered by blists - more mailing lists