[PATCH v1 1/7] ufs: decode string descriptors as UTF-16 big-endian
Jorge Ramirez-Ortiz <[email protected]> Mon, 20 Jul 2026 10:51:41 +0200
| Newsgroups | de.denx.lists.u-boot |
|---|---|
| Message-ID | <[email protected]> |
UFS string descriptors are UTF-16 big-endian (JESD220), but ufshcd_read_string_desc() fed the raw bytes to utf16_to_utf8(), which reads host-endian code units, leaving dev_desc->model blank. Byte-swap to host order before decoding, matching the kernel. Signed-off-by: Jorge Ramirez-Ortiz <[email protected]> --- drivers/ufs/ufs-uclass.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/ufs/ufs-uclass.c b/drivers/ufs/ufs-uclass.c index 6a51f337e47..4d10e0b11fe 100644 --- a/drivers/ufs/ufs-uclass.c +++ b/drivers/ufs/ufs-uclass.c @@ -1765,6 +1765,14 @@ static int ufshcd_read_string_desc(struct ufs_hba *hba, int desc_index, goto out; } + { + u16 *ustr = (u16 *)&buf[QUERY_DESC_HDR_SIZE]; + int num_chars = (desc_len - QUERY_DESC_HDR_SIZE) / 2; + + for (i = 0; i < num_chars; i++) + ustr[i] = be16_to_cpu(ustr[i]); + } + /* * the descriptor contains string in UTF16 format * we need to convert to utf-8 so it can be displayed -- 2.54.0