Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754376AbbKXLAn (ORCPT ); Tue, 24 Nov 2015 06:00:43 -0500 Received: from mail-lf0-f49.google.com ([209.85.215.49]:35828 "EHLO mail-lf0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753337AbbKXLAl (ORCPT ); Tue, 24 Nov 2015 06:00:41 -0500 Message-ID: <56544356.6020102@lightnvm.io> Date: Tue, 24 Nov 2015 12:00:38 +0100 From: =?windows-1252?Q?Matias_Bj=F8rling?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Sudip Mukherjee CC: linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/5] lightnvm: check for max sector References: <1448361300-26718-1-git-send-email-sudipm.mukherjee@gmail.com> <1448361300-26718-2-git-send-email-sudipm.mukherjee@gmail.com> In-Reply-To: <1448361300-26718-2-git-send-email-sudipm.mukherjee@gmail.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1913 Lines: 53 On 11/24/2015 11:34 AM, Sudip Mukherjee wrote: > 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 > --- > 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; > Thanks. Wenwei Tao already sent a fix for this. You can see the latest patches queued for upstream at: https://github.com/OpenChannelSSD/linux/commits/for-next (remember to switch to the for-next branch in the qemu-nvme repo if you're testing with qemu). -- 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/