linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] nvme-core: pr related small cleanups
@ 2020-10-29 18:59 Chaitanya Kulkarni
  2020-10-29 18:59 ` [PATCH 1/2] nvme-core: cleanup nvme_pr_type() Chaitanya Kulkarni
  2020-10-29 18:59 ` [PATCH 2/2] nvme-core: add new line after variable declatation Chaitanya Kulkarni
  0 siblings, 2 replies; 4+ messages in thread
From: Chaitanya Kulkarni @ 2020-10-29 18:59 UTC (permalink / raw)
  To: linux-nvme; +Cc: kbusch, sagi, Chaitanya Kulkarni, hch

Hi,

This is purely cleanup patch-series for nvme-core pr related code.

-ck

Chaitanya Kulkarni (2):
  nvme-core: cleanup nvme_pr_type()
  nvme-core: add new line after variable declatation

 drivers/nvme/host/core.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] nvme-core: cleanup nvme_pr_type()
  2020-10-29 18:59 [PATCH 0/2] nvme-core: pr related small cleanups Chaitanya Kulkarni
@ 2020-10-29 18:59 ` Chaitanya Kulkarni
  2020-11-03 18:08   ` Christoph Hellwig
  2020-10-29 18:59 ` [PATCH 2/2] nvme-core: add new line after variable declatation Chaitanya Kulkarni
  1 sibling, 1 reply; 4+ messages in thread
From: Chaitanya Kulkarni @ 2020-10-29 18:59 UTC (permalink / raw)
  To: linux-nvme; +Cc: kbusch, sagi, Chaitanya Kulkarni, hch

The switch in the nvme_pr_type() returns values which can be mapped 1:1
on the PR_XXX macors. Get rid of the long switch and replace with simple
conditional operator to return the value.

This is purely code cleanup and doesn't change any functionality.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/host/core.c | 20 ++++----------------
 1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 376096bfc54a..16f590a03486 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2149,23 +2149,11 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
 
 static char nvme_pr_type(enum pr_type type)
 {
-	switch (type) {
-	case PR_WRITE_EXCLUSIVE:
-		return 1;
-	case PR_EXCLUSIVE_ACCESS:
-		return 2;
-	case PR_WRITE_EXCLUSIVE_REG_ONLY:
-		return 3;
-	case PR_EXCLUSIVE_ACCESS_REG_ONLY:
-		return 4;
-	case PR_WRITE_EXCLUSIVE_ALL_REGS:
-		return 5;
-	case PR_EXCLUSIVE_ACCESS_ALL_REGS:
-		return 6;
-	default:
+	if (type < PR_WRITE_EXCLUSIVE || type > PR_EXCLUSIVE_ACCESS_ALL_REGS)
 		return 0;
-	}
-};
+
+	return type;
+}
 
 static int nvme_pr_command(struct block_device *bdev, u32 cdw10,
 				u64 key, u64 sa_key, u8 op)
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] nvme-core: add new line after variable declatation
  2020-10-29 18:59 [PATCH 0/2] nvme-core: pr related small cleanups Chaitanya Kulkarni
  2020-10-29 18:59 ` [PATCH 1/2] nvme-core: cleanup nvme_pr_type() Chaitanya Kulkarni
@ 2020-10-29 18:59 ` Chaitanya Kulkarni
  1 sibling, 0 replies; 4+ messages in thread
From: Chaitanya Kulkarni @ 2020-10-29 18:59 UTC (permalink / raw)
  To: linux-nvme; +Cc: kbusch, sagi, Chaitanya Kulkarni, hch

Add a new line in functions nvme_pr_preempt(), nvme_pr_clear() and
nvme_pr_release() after variable declaration which follows the rest of
the code in the host/core.c.

This is purely code cleanup and doesn't change any functionality.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 drivers/nvme/host/core.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 16f590a03486..b4fcdc373144 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2212,18 +2212,21 @@ static int nvme_pr_preempt(struct block_device *bdev, u64 old, u64 new,
 		enum pr_type type, bool abort)
 {
 	u32 cdw10 = nvme_pr_type(type) << 8 | (abort ? 2 : 1);
+
 	return nvme_pr_command(bdev, cdw10, old, new, nvme_cmd_resv_acquire);
 }
 
 static int nvme_pr_clear(struct block_device *bdev, u64 key)
 {
 	u32 cdw10 = 1 | (key ? 1 << 3 : 0);
+
 	return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_register);
 }
 
 static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type)
 {
 	u32 cdw10 = nvme_pr_type(type) << 8 | (key ? 1 << 3 : 0);
+
 	return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release);
 }
 
-- 
2.22.1


_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] nvme-core: cleanup nvme_pr_type()
  2020-10-29 18:59 ` [PATCH 1/2] nvme-core: cleanup nvme_pr_type() Chaitanya Kulkarni
@ 2020-11-03 18:08   ` Christoph Hellwig
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-11-03 18:08 UTC (permalink / raw)
  To: Chaitanya Kulkarni; +Cc: kbusch, sagi, linux-nvme, hch

On Thu, Oct 29, 2020 at 11:59:57AM -0700, Chaitanya Kulkarni wrote:
> The switch in the nvme_pr_type() returns values which can be mapped 1:1
> on the PR_XXX macors. Get rid of the long switch and replace with simple
> conditional operator to return the value.

We'd need BUILD_BUG_ON statements to check this all actually maps.
At which point just doing the mapping as done in the current code seem
much more sensible for something that isn't exactly a fast path.

_______________________________________________
Linux-nvme mailing list
Linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-03 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 18:59 [PATCH 0/2] nvme-core: pr related small cleanups Chaitanya Kulkarni
2020-10-29 18:59 ` [PATCH 1/2] nvme-core: cleanup nvme_pr_type() Chaitanya Kulkarni
2020-11-03 18:08   ` Christoph Hellwig
2020-10-29 18:59 ` [PATCH 2/2] nvme-core: add new line after variable declatation Chaitanya Kulkarni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).