Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1276299

[PATCH v2 2/5] lightnvm: check for max sector

From Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Newsgroups linux.kernel
Subject [PATCH v2 2/5] lightnvm: check for max sector
Date 2015-11-24 11:40 +0100
Message-ID <qyjaX-6V9-29@gated-at.bofh.it> (permalink)
References <qyjaW-6V9-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


If max_phys_sect is greater than 256 then its obviously greater than 1
so we will never hit the else-if block. And moreover, if we check for
max_phys_sect at the end then it might happen that we initialize
successfully only to see at the end that this is not supported.
Lets check for max_phys_sect at the beginning and continue
initialization only if it is supported.

Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
 drivers/lightnvm/core.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index e338048..2ab561f 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -296,6 +296,11 @@ int nvm_register(struct request_queue *q, char *disk_name,
 	if (!ops->identity)
 		return -EINVAL;
 
+	if (ops->max_phys_sect > 256) {
+		pr_info("nvm: max sectors supported is 256.\n");
+		return -EINVAL;
+	}
+
 	dev = kzalloc(sizeof(struct nvm_dev), GFP_KERNEL);
 	if (!dev)
 		return -ENOMEM;
@@ -319,9 +324,6 @@ int nvm_register(struct request_queue *q, char *disk_name,
 			pr_err("nvm: could not create ppa pool\n");
 			return -ENOMEM;
 		}
-	} else if (dev->ops->max_phys_sect > 256) {
-		pr_info("nvm: max sectors supported is 256.\n");
-		return -EINVAL;
 	}
 
 	return 0;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/5] lightnvm: fix memory leak Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-24 11:40 +0100
  [PATCH v2 4/5] lightnvm: release dev if dma pools fails Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-24 11:40 +0100
    Re: [PATCH v2 4/5] lightnvm: release dev if dma pools fails Matias Bjørling <mb@lightnvm.io> - 2015-11-24 12:10 +0100
  [PATCH v2 5/5] lightnvm: return error if manager not found Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-24 11:40 +0100
    Re: [PATCH v2 5/5] lightnvm: return error if manager not found Matias Bjørling <mb@lightnvm.io> - 2015-11-24 12:20 +0100
  [PATCH v2 2/5] lightnvm: check for max sector Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-24 11:40 +0100
    Re: [PATCH v2 2/5] lightnvm: check for max sector Matias Bjørling <mb@lightnvm.io> - 2015-11-24 12:10 +0100
  [PATCH v2 3/5] lightnvm: create dma pool first Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-11-24 11:40 +0100
    Re: [PATCH v2 3/5] lightnvm: create dma pool first Matias Bjørling <mb@lightnvm.io> - 2015-11-24 12:10 +0100
  Re: [PATCH v2 1/5] lightnvm: fix memory leak Matias Bjørling <m@bjorling.me> - 2015-11-24 12:00 +0100

csiph-web