[PATCH 2/2] Enhancement to do_status_get() function for detailed Response info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This enhancement covers detailed status register decoding with ERROR/STATUS information when host sends CMD13(with SQS=0)

Signed-off-by : shankar.ma@xxxxxxxxxxxx
Reviewed-by: mohanraj.v@xxxxxxxxxxx
---
 mmc_cmds.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 64 insertions(+), 1 deletion(-)

diff --git a/mmc_cmds.c b/mmc_cmds.c
index 5e5e79e..f9f1d52 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -848,6 +848,8 @@ int do_status_get(int nargs, char **argv)
 	__u32 response;
 	int fd, ret;
 	char *device;
+	const char *str; 
+	__u8 state;
 
 	if (nargs != 2) {
 		fprintf(stderr, "Usage: mmc status get </path/to/mmcblkX>\n");
@@ -869,7 +871,68 @@ int do_status_get(int nargs, char **argv)
 	}
 
 	printf("SEND_STATUS response: 0x%08x\n", response);
-
+	if((response >> 31) & 0x01) printf("ERROR: ADDRESS_OUT_OF_RANGE\n");
+	if((response >> 30) & 0x01) printf("ERROR: ADDRESS_MISALIGN\n");
+	if((response >> 29) & 0x01) printf("ERROR: BLOCK_LEN_ERROR\n");
+	if((response >> 28) & 0x01) printf("ERROR: ERASE_SEQ_ERROR\n");
+	if((response >> 27) & 0x01) printf("ERROR: ERASE_PARAM_ERROR\n");
+	if((response >> 26) & 0x01) printf("ERROR: WP_VOILATION\n");
+	if((response >> 25) & 0x01) printf("STATUS: DEVICE_IS_LOCKED\n");
+	if((response >> 24) & 0x01) printf("ERROR: LOCK_UNLOCK_IS_FAILED\n");
+	if((response >> 23) & 0x01) printf("ERROR: COM_CRC_ERROR\n");
+	if((response >> 22) & 0x01) printf("ERROR: ILLEGAL_COMMAND\n");
+	if((response >> 21) & 0x01) printf("ERROR: DEVICE_ECC_FAILED\n");
+	if((response >> 20) & 0x01) printf("ERROR: CC_ERROR\n");
+	if((response >> 19) & 0x01) printf("ERROR: ERROR\n");
+	if((response >> 16) & 0x01) printf("ERROR: CID/CSD OVERWRITE\n");
+	if((response >> 15) & 0x01) printf("ERROR: WP_ERASE_SKIP\n");
+	if((response >> 13) & 0x01) printf("ERROR: ERASE_RESET\n");
+	state = (response >> 9)& 0xF;
+	switch(state)
+	{
+		case 0:
+			str = "IDLE";
+			break;
+		case 1:
+			str = "READY";
+			break;
+		case 2:
+			str = "IDENT";
+			break;
+		case 3:
+			str = "STDBY";
+			break;
+		case 4:
+			str = "TRANS";
+			break;
+		case 5:
+			str = "DATA";
+			break;
+		case 6:
+			str = "RCV";
+			break;
+		case 7:
+			str = "PRG";
+			break;
+		case 8:
+			str = " DIS";
+			break;
+		case 9:
+			str = "BTST";
+			break;
+		case 10:
+			str = "SLP" ;
+			break;
+		default:
+			printf("Attention : Device state is INVALID: Kindly check the Response\n");
+			goto out_free;
+	}
+	printf("DEVICE STATE: %s\n",str);
+	if((response >> 8) & 0x01) printf("STATUS: READY_FOR_DATA\n");
+	if((response >> 7) & 0x01) printf("ERROR: SWITCH_ERROR\n");
+	if((response >> 6) & 0x01) printf("STATUS: EXCEPTION_EVENT\n");  /* Check EXCEPTION_EVENTS_STATUS field to understand what further actions are needed*/
+	if((response >> 5) & 0x01) printf("STATUS: APP_CMD\n");
+out_free:
 	close(fd);
 	return ret;
 }
-- 
2.25.1




[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux