From a475518337e15935469543b1cce353e5b337ef52 Mon Sep 17 00:00:00 2001 From: anans Date: Mon, 18 Apr 2022 12:21:43 +0530 Subject: [PATCH] fix(ufs): read and write attribute based on spec according to the spec, the response to read attr comes in the ts.attr.value field and not in the data segment. Signed-off-by: anans Change-Id: Iaf21883bb7e364fd7c7e4bccb33359367a0cf99d --- drivers/ufs/ufs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c index 720b73235..c71ff5a76 100644 --- a/drivers/ufs/ufs.c +++ b/drivers/ufs/ufs.c @@ -441,7 +441,7 @@ static int ufs_prepare_query(utp_utrd_t *utrd, uint8_t op, uint8_t idn, break; case QUERY_WRITE_ATTR: query_upiu->query_func = QUERY_FUNC_STD_WRITE; - memcpy((void *)&query_upiu->ts.attr.value, (void *)buf, length); + query_upiu->ts.attr.value = htobe32(*((uint32_t *)buf)); break; default: assert(0); @@ -624,12 +624,14 @@ static void ufs_query(uint8_t op, uint8_t idn, uint8_t index, uint8_t sel, case QUERY_READ_FLAG: *(uint32_t *)buf = (uint32_t)resp->ts.flag.value; break; - case QUERY_READ_ATTR: case QUERY_READ_DESC: memcpy((void *)buf, (void *)(utrd.resp_upiu + sizeof(query_resp_upiu_t)), size); break; + case QUERY_READ_ATTR: + *(uint32_t *)buf = htobe32(resp->ts.attr.value); + break; default: /* Do nothing in default case */ break;