scsi: ufs: core: Convert string descriptor format macros to enum
Convert SD_ASCII_STD and SD_RAW from boolean macros to enum values for improved code readability. This makes ufshcd_read_string_desc() calls self-documenting by using explicit enum values instead of true/false. Move the ufshcd_read_string_desc() declaration from include/ufs/ufshcd.h to drivers/ufs/core/ufshcd-priv.h since this function is not exported. Co-developed-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Suggested-by: Avri Altman <Avri.Altman@sandisk.com> Signed-off-by: Bean Huo <beanhuo@micron.com> Link: https://patch.msgid.link/20251107230518.4060231-2-beanhuo@iokpp.de Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
committed by
Martin K. Petersen
parent
211ddde082
commit
0d9a7085ec
@@ -78,11 +78,17 @@ int ufshcd_try_to_abort_task(struct ufs_hba *hba, int tag);
|
|||||||
void ufshcd_release_scsi_cmd(struct ufs_hba *hba,
|
void ufshcd_release_scsi_cmd(struct ufs_hba *hba,
|
||||||
struct ufshcd_lrb *lrbp);
|
struct ufshcd_lrb *lrbp);
|
||||||
|
|
||||||
#define SD_ASCII_STD true
|
/**
|
||||||
#define SD_RAW false
|
* enum ufs_descr_fmt - UFS string descriptor format
|
||||||
int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
|
* @SD_RAW: Raw UTF-16 format
|
||||||
u8 **buf, bool ascii);
|
* @SD_ASCII_STD: Convert to null-terminated ASCII string
|
||||||
|
*/
|
||||||
|
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_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);
|
int ufshcd_send_bsg_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd);
|
||||||
|
|
||||||
|
|||||||
@@ -3773,16 +3773,14 @@ static inline char ufshcd_remove_non_printable(u8 ch)
|
|||||||
* @desc_index: descriptor index
|
* @desc_index: descriptor index
|
||||||
* @buf: pointer to buffer where descriptor would be read,
|
* @buf: pointer to buffer where descriptor would be read,
|
||||||
* the caller should free the memory.
|
* the caller should free the memory.
|
||||||
* @ascii: if true convert from unicode to ascii characters
|
* @fmt: if %SD_ASCII_STD, convert from UTF-16 to ASCII
|
||||||
* null terminated string.
|
|
||||||
*
|
*
|
||||||
* Return:
|
* Return:
|
||||||
* * string size on success.
|
* * string size on success.
|
||||||
* * -ENOMEM: on allocation failure
|
* * -ENOMEM: on allocation failure
|
||||||
* * -EINVAL: on a wrong parameter
|
* * -EINVAL: on a wrong parameter
|
||||||
*/
|
*/
|
||||||
int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
|
int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index, u8 **buf, enum ufs_descr_fmt fmt)
|
||||||
u8 **buf, bool ascii)
|
|
||||||
{
|
{
|
||||||
struct uc_string_id *uc_str;
|
struct uc_string_id *uc_str;
|
||||||
u8 *str;
|
u8 *str;
|
||||||
@@ -3811,7 +3809,7 @@ int ufshcd_read_string_desc(struct ufs_hba *hba, u8 desc_index,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ascii) {
|
if (fmt == SD_ASCII_STD) {
|
||||||
ssize_t ascii_len;
|
ssize_t ascii_len;
|
||||||
int i;
|
int i;
|
||||||
/* remove header and divide by 2 to move from UTF16 to UTF8 */
|
/* remove header and divide by 2 to move from UTF16 to UTF8 */
|
||||||
|
|||||||
@@ -1431,10 +1431,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_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
|
||||||
void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
|
void ufshcd_fixup_dev_quirks(struct ufs_hba *hba,
|
||||||
const struct ufs_dev_quirk *fixups);
|
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_hold(struct ufs_hba *hba);
|
||||||
void ufshcd_release(struct ufs_hba *hba);
|
void ufshcd_release(struct ufs_hba *hba);
|
||||||
|
|||||||
Reference in New Issue
Block a user