fix(ufs): move nutrs assignment to ufs_init

nutrs is set in ufs_enum (used by get_empty_slot), this will not
be assigned if UFS_FLAGS_SKIPINIT is set in flags during init and
might end up crashing read/write commands

Change-Id: I1517b69c56741fd5bf4ef0ebc1fc8738746233d7
Signed-off-by: anans <anans@google.com>
diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c
index b040a95..3c27aff 100644
--- a/drivers/ufs/ufs.c
+++ b/drivers/ufs/ufs.c
@@ -739,11 +739,6 @@
 	unsigned int blk_num, blk_size;
 	int i;
 
-	/* 0 means 1 slot */
-	nutrs = (mmio_read_32(ufs_params.reg_base + CAP) & CAP_NUTRS_MASK) + 1;
-	if (nutrs > (ufs_params.desc_size / UFS_DESC_SIZE))
-		nutrs = ufs_params.desc_size / UFS_DESC_SIZE;
-
 	ufs_verify_init();
 	ufs_verify_ready();
 
@@ -788,6 +783,13 @@
 
 	memcpy(&ufs_params, params, sizeof(ufs_params_t));
 
+	/* 0 means 1 slot */
+	nutrs = (mmio_read_32(ufs_params.reg_base + CAP) & CAP_NUTRS_MASK) + 1;
+	if (nutrs > (ufs_params.desc_size / UFS_DESC_SIZE)) {
+		nutrs = ufs_params.desc_size / UFS_DESC_SIZE;
+	}
+
+
 	if (ufs_params.flags & UFS_FLAGS_SKIPINIT) {
 		result = ufshc_dme_get(0x1571, 0, &data);
 		assert(result == 0);