Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C9C7C2B9F4 for ; Tue, 22 Jun 2021 13:17:06 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B14286112D for ; Tue, 22 Jun 2021 13:17:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B14286112D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2C94F829C7; Tue, 22 Jun 2021 15:16:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vAcf9CyH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BFE79829BE; Tue, 22 Jun 2021 15:16:42 +0200 (CEST) Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BF16C80F32 for ; Tue, 22 Jun 2021 15:16:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=bmeng.cn@gmail.com Received: by mail-pj1-x102f.google.com with SMTP id t19-20020a17090ae513b029016f66a73701so1716926pjy.3 for ; Tue, 22 Jun 2021 06:16:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Na9ybL3tob7Jd7ptzEIvsGhJv2yN6/Ogm+FhSPkaFcw=; b=vAcf9CyH3w5voJwSJvwDugzyN4xtlrcvUJqHLqJxLxHhZ2FHz2+FE6/tRsiwyRqd1b HcXhTCIo7iO48k9P9yxvj60UhNNFaO/319rnaBMJuWar3Jq7yHy+tbXjjjuqP0ZKUlmF J1puJiwlLfzzlC/Iqc4Yoo3PhWb4W6z/7xQ7sgdC2j2XBlp6ICFCLpGzMwlmGTUN2KWA 2yZEarRW6sgW2d5Ixv8c66+PJpE9Zq6+KGpNsSj4Wve7iMmDT+dYa+M3iiTULyMPtjX+ uN93rRQ4E8xtJDKWZDdtPfL44SAZD3zG3SUN5wc4nASoi59MtYgdJhjFmhqR3z2MZ/jK QpZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Na9ybL3tob7Jd7ptzEIvsGhJv2yN6/Ogm+FhSPkaFcw=; b=tVL9VDO9Ln5wYBn8NqqGoWBqohr1tlA8QFAUNkXtDPHZVzuJaSw5kL67ip8BYR0fxo 8EIGJ7urHbrn/d0OLkM4WsDWtGEmB8EIQaL3MJWRPEPLFSRNDf3QQSbulAAGI6vEz3Wu v5yjNKqJC8q9SQWKCKjYmA1V/q6xCQk5NLn/vpKmL9xmkuCEXO4CJzsAa67+Yhf/6pcW lVgiBrXoieYBAgCiQf3Gzv/rUkghOfYvuGp7FtEbqz/IuBz/YI5NFsZZ1XVVCg16hpmH BmlPBVvgNRtZ82Gx3/fjYNyqt8KB2YHBa2emIpYhr5qPu9zPbfAJwRJFhXHRNMl50FwD eC9A== X-Gm-Message-State: AOAM532bpeo+Dy39jQWSaveOhwQYfJTbMxD6WAn5Fcwk+MH3abssBvP4 EKIe4Dmlys+BKkd8XYoeXuw= X-Google-Smtp-Source: ABdhPJw4eDVEQBarGUwPsJVH6LIx3pM0wf2e8/hRxlmZ0IZjGqTL3g0k008ZKqyoql08G92gMycLXA== X-Received: by 2002:a17:902:7085:b029:114:eb3f:fe29 with SMTP id z5-20020a1709027085b0290114eb3ffe29mr23022265plk.40.1624367797265; Tue, 22 Jun 2021 06:16:37 -0700 (PDT) Received: from i9-aorus-gtx1080.localdomain (144.168.56.201.16clouds.com. [144.168.56.201]) by smtp.gmail.com with ESMTPSA id j24sm18456482pfe.58.2021.06.22.06.16.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Jun 2021 06:16:36 -0700 (PDT) From: Bin Meng To: Tom Rini , u-boot@lists.denx.de Cc: Bin Meng , Heinrich Schuchardt Subject: [PATCH v2 3/7] nvme: Eliminate the offset of one during block dev creation Date: Tue, 22 Jun 2021 21:16:19 +0800 Message-Id: <20210622131623.21265-3-bmeng.cn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210622131623.21265-1-bmeng.cn@gmail.com> References: <20210622131623.21265-1-bmeng.cn@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean At present there is an offset of one added during the creation of block device. This can be very confusing as we wanted to encode the namespace id in the block device name but namespae id cannot be zero. This changes to use the namespace id directly in the block device name, eliminating the offset of one effectively. Suggested-by: Heinrich Schuchardt Signed-off-by: Bin Meng --- Changes in v2: - new patch: Eliminate the offset of one during block dev creation drivers/nvme/nvme.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index bb24c9cdd3..97c665d6a3 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -709,7 +709,7 @@ static int nvme_blk_probe(struct udevice *udev) memset(ns, 0, sizeof(*ns)); ns->dev = ndev; /* extract the namespace id from the block device name */ - ns->ns_id = trailing_strtol(udev->name) + 1; + ns->ns_id = trailing_strtol(udev->name); if (nvme_identify(ndev, ns->ns_id, 0, (dma_addr_t)(long)id)) { free(id); return -EIO; @@ -888,12 +888,12 @@ static int nvme_probe(struct udevice *udev) goto free_queue; } - for (int i = 0; i < ndev->nn; i++) { + for (int i = 1; i <= ndev->nn; i++) { struct udevice *ns_udev; char name[20]; memset(id, 0, sizeof(*id)); - if (nvme_identify(ndev, i + 1, 0, (dma_addr_t)(long)id)) { + if (nvme_identify(ndev, i, 0, (dma_addr_t)(long)id)) { ret = -EIO; goto free_id; } -- 2.25.1