[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ebd28e82ff6825507a072c4883e156c45b7746dd.camel@gmail.com>
Date: Wed, 08 Oct 2025 22:24:07 +0200
From: Bean Huo <huobean@...il.com>
To: Bart Van Assche <bvanassche@....org>, avri.altman@....com,
avri.altman@...disk.com, alim.akhtar@...sung.com, jejb@...ux.ibm.com,
martin.petersen@...cle.com, can.guo@....qualcomm.com,
ulf.hansson@...aro.org, beanhuo@...ron.com, jens.wiklander@...aro.org
Cc: linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 1/3] scsi: ufs: core: Remove duplicate macro
definitions
Bart,
improved in v4, thanks for reviewing!
Kind regards,
Bean
On Wed, 2025-10-08 at 09:03 -0700, Bart Van Assche wrote:
> On 10/8/25 7:58 AM, Bean Huo wrote:
> > Remove duplicate definitions of SD_ASCII_STD and SD_RAW macros from
> > ufshcd-priv.h as they are already defined in include/ufs/ufshcd.h.
> >
> > Suggested-by: Avri Altman <Avri.Altman@...disk.com>
> > Signed-off-by: Bean Huo <beanhuo@...ron.com>
> > ---
> > drivers/ufs/core/ufshcd-priv.h | 3 ---
> > 1 file changed, 3 deletions(-)
> >
> > diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h
> > index d0a2c963a27d..cadee685eb5e 100644
> > --- a/drivers/ufs/core/ufshcd-priv.h
> > +++ b/drivers/ufs/core/ufshcd-priv.h
> > @@ -77,9 +77,6 @@ int ufshcd_mcq_abort(struct scsi_cmnd *cmd);
> > int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag);
> > void ufshcd_release_scsi_cmd(struct ufs_hba *hba,
> > struct ufshcd_lrb *lrbp);
> > -
> > -#define SD_ASCII_STD true
> > -#define SD_RAW false
> > int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
> > u8 **buf, bool ascii);
> >
>
> Please improve this patch as follows:
> - Remove the ufshcd_read_string_desc() declaration from
> include/ufs/ufshcd.h because this function has not been exported.
> - Change the type of the 'ascii' argument into an enumeration type.
> Code readability improves significantly if boolean arguments are
> replaced with enumeration type arguments.
>
> Below there is an untested patch that illustrates the above.
>
> Thanks,
>
> Bart.
>
>
> diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h
> index 1f0d38aa37f9..85d3d9e64bd7 100644
> --- a/drivers/ufs/core/ufshcd-priv.h
> +++ b/drivers/ufs/core/ufshcd-priv.h
> @@ -80,10 +80,12 @@ int ufshcd_try_to_abort_task(struct ufs_hba *hba,
> int tag);
> void ufshcd_release_scsi_cmd(struct ufs_hba *hba,
> struct ufshcd_lrb *lrbp);
>
> -#define SD_ASCII_STD true
> -#define SD_RAW false
> -int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
> - u8 **buf, bool ascii);
> +enum ufs_descr_fmt {
> + SD_RAW = 0,
> + SD_ASCII_STD = 1,
> +};
> +int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, u8 **buf,
> + enum ufs_descr_fmt fmt);
>
> int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd);
> int ufshcd_send_bsg_uic_cmd(struct ufs_hba *hba, struct uic_command
> *uic_cmd);
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index be4bf435da09..b10de1ade23b 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -3759,16 +3759,15 @@ static inline char
> ufshcd_remove_non_printable(u8 ch)
> * @desc_index: descriptor index
> * @buf: pointer to buffer where descriptor would be read,
> * the caller should free the memory.
> - * @ascii: if true convert from unicode to ascii characters
> - * null terminated string.
> + * @ufs_descr_fmt: if %SD_ASCII_STD, convert from UTF-16 to ASCII
> *
> * Return:
> * * string size on success.
> * * -ENOMEM: on allocation failure
> * * -EINVAL: on a wrong parameter
> */
> -int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
> - u8 **buf, bool ascii)
> +int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, u8 **buf,
> + enum ufs_descr_fmt fmt)
> {
> struct uc_string_id *uc_str;
> u8 *str;
> @@ -3797,7 +3796,7 @@ int ufshcd_read_string_desc(struct ufs_hba *hba,
> u8 desc_index,
> goto out;
> }
>
> - if (ascii) {
> + if (fmt == SD_ASCII_STD) {
> ssize_t ascii_len;
> int i;
> /* remove header and divide by 2 to move from UTF16 to UTF8 */
> diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
> index 8a5649933715..f030e9a062a3 100644
> --- a/include/ufs/ufshcd.h
> +++ b/include/ufs/ufshcd.h
> @@ -1428,10 +1428,6 @@ static inline int
> ufshcd_disable_host_tx_lcc(struct ufs_hba *hba)
> void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
> void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
> const struct ufs_dev_quirk *fixups);
> -#define SD_ASCII_STD true
> -#define SD_RAW false
> -int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
> - u8 **buf, bool ascii);
>
> void ufshcd_hold(struct ufs_hba *hba);
> void ufshcd_release(struct ufs_hba *hba);
>
Powered by blists - more mailing lists