public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: kusumi.tomohiro@gmail.com
To: subhashj@codeaurora.org, vinholikatti@gmail.com,
	linux-scsi@vger.kernel.org
Cc: Tomohiro Kusumi <tkusumi@tuxera.com>
Subject: [PATCH 2/2] scsi: ufs: make ufshcd_get_lists_status() register operation obvious
Date: Thu, 20 Apr 2017 15:01:45 +0300	[thread overview]
Message-ID: <20170420120145.7035-2-tkusumi@tuxera.com> (raw)
In-Reply-To: <20170420120145.7035-1-tkusumi@tuxera.com>

From: Tomohiro Kusumi <tkusumi@tuxera.com>

It could be just cmp 0xe instead of >>1 and cmp 0x7, with readable code.

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
---
 drivers/scsi/ufs/ufshcd.c | 11 +----------
 drivers/scsi/ufs/ufshci.h |  4 ++++
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 9278666..ad9532b 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -668,16 +668,7 @@ static inline void ufshcd_outstanding_req_clear(struct ufs_hba *hba, int tag)
  */
 static inline int ufshcd_get_lists_status(u32 reg)
 {
-	/*
-	 * The mask 0xFF is for the following HCS register bits
-	 * Bit		Description
-	 *  0		Device Present
-	 *  1		UTRLRDY
-	 *  2		UTMRLRDY
-	 *  3		UCRDY
-	 * 4-7		reserved
-	 */
-	return ((reg & 0xFF) >> 1) ^ 0x07;
+	return !((reg & UFSHCD_STATUS_READY) == (u32)UFSHCD_STATUS_READY);
 }
 
 /**
diff --git a/drivers/scsi/ufs/ufshci.h b/drivers/scsi/ufs/ufshci.h
index d14e9b9..8cd4f0e 100644
--- a/drivers/scsi/ufs/ufshci.h
+++ b/drivers/scsi/ufs/ufshci.h
@@ -159,6 +159,10 @@ enum {
 #define DEVICE_ERROR_INDICATOR			UFS_BIT(5)
 #define UIC_POWER_MODE_CHANGE_REQ_STATUS_MASK	UFS_MASK(0x7, 8)
 
+#define UFSHCD_STATUS_READY	(UTP_TRANSFER_REQ_LIST_READY |\
+				UTP_TASK_REQ_LIST_READY |\
+				UIC_COMMAND_READY)
+
 enum {
 	PWR_OK		= 0x0,
 	PWR_LOCAL	= 0x01,
-- 
2.9.3

  reply	other threads:[~2017-04-20 12:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-20 12:01 [PATCH 1/2] scsi: ufs: use MASK_EE_STATUS kusumi.tomohiro
2017-04-20 12:01 ` kusumi.tomohiro [this message]
2017-04-26 16:49   ` [PATCH 2/2] scsi: ufs: make ufshcd_get_lists_status() register operation obvious Subhash Jadavani
2017-04-26 17:04     ` Tomohiro Kusumi
2017-04-24 22:34 ` [PATCH 1/2] scsi: ufs: use MASK_EE_STATUS Martin K. Petersen
2017-04-26 16:39 ` Subhash Jadavani
2017-04-26 22:29 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170420120145.7035-2-tkusumi@tuxera.com \
    --to=kusumi.tomohiro@gmail.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=subhashj@codeaurora.org \
    --cc=tkusumi@tuxera.com \
    --cc=vinholikatti@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox