From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
To: Matias Bjorling <mb@lightnvm.io>
Cc: linux-kernel@vger.kernel.org,
Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Subject: [PATCH v2 2/5] lightnvm: check for max sector
Date: Tue, 24 Nov 2015 16:04:57 +0530 [thread overview]
Message-ID: <1448361300-26718-2-git-send-email-sudipm.mukherjee@gmail.com> (raw)
In-Reply-To: <1448361300-26718-1-git-send-email-sudipm.mukherjee@gmail.com>
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
next prev parent reply other threads:[~2015-11-24 10:35 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-24 10:34 [PATCH v2 1/5] lightnvm: fix memory leak Sudip Mukherjee
2015-11-24 10:34 ` Sudip Mukherjee [this message]
2015-11-24 11:00 ` [PATCH v2 2/5] lightnvm: check for max sector Matias Bjørling
2015-11-24 10:34 ` [PATCH v2 3/5] lightnvm: create dma pool first Sudip Mukherjee
2015-11-24 11:01 ` Matias Bjørling
2015-11-24 10:34 ` [PATCH v2 4/5] lightnvm: release dev if dma pools fails Sudip Mukherjee
2015-11-24 11:06 ` Matias Bjørling
2015-11-24 10:35 ` [PATCH v2 5/5] lightnvm: return error if manager not found Sudip Mukherjee
2015-11-24 11:10 ` Matias Bjørling
2015-11-24 10:57 ` [PATCH v2 1/5] lightnvm: fix memory leak Matias Bjørling
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=1448361300-26718-2-git-send-email-sudipm.mukherjee@gmail.com \
--to=sudipm.mukherjee@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mb@lightnvm.io \
/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
all inboxes | Powered by JetHome®