From patchwork Fri Sep 4 14:19:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 11757421 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E04EE618 for ; Fri, 4 Sep 2020 14:23:25 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B2AB9206B7 for ; Fri, 4 Sep 2020 14:23:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=irrelevant.dk header.i=@irrelevant.dk header.b="YOpt66dr" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2AB9206B7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=irrelevant.dk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:41468 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kECce-0000Fl-Oj for patchwork-qemu-devel@patchwork.kernel.org; Fri, 04 Sep 2020 10:23:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32840) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kECaO-0003SM-Mw; Fri, 04 Sep 2020 10:21:04 -0400 Received: from charlie.dont.surf ([128.199.63.193]:48028) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kECaL-0002jh-FE; Fri, 04 Sep 2020 10:21:04 -0400 Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by charlie.dont.surf (Postfix) with ESMTPSA id 4FE7FBFB54; Fri, 4 Sep 2020 14:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=irrelevant.dk; s=default; t=1599229236; bh=S0gbzHUcsCyIvbaedPZcFblTZFt6MpvV2k1wK6JvNRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOpt66dr4Y3myH2wWOtO9/qJFBUkAjlpRuqPNVsoEcQFPXyGVHNMouHpeqr+Yz3bG 3E/ZvV7uX/Ys6V26m9KicXjxSB0qMpbZOqs2Ii08MWIoGhrti6onlV9QIB/RFcntO/ eMoLplY5nF5a+MxdpHfeDyQokcViGNrDpYxAR7S7D71DfMWVc0CQihEkw5Z3a2+lRo LKV7107wveaOBMVbZvGJQ2UO7fhl7kE2PppL8k1BWrbqrb7SYIjs5JL8p2dqiiGgMD n5gWCfMqRAYlGfza8fFWHX1uJmun9S6D4Rh5HdTT5X3Ko8AN8gLgJsNxxiVFnRFEuv RI8f0BI7A0NPg== From: Klaus Jensen To: qemu-devel@nongnu.org Subject: [PATCH 14/17] hw/block/nvme: refactor identify active namespace id list Date: Fri, 4 Sep 2020 16:19:53 +0200 Message-Id: <20200904141956.576630-15-its@irrelevant.dk> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904141956.576630-1-its@irrelevant.dk> References: <20200904141956.576630-1-its@irrelevant.dk> MIME-Version: 1.0 Received-SPF: pass client-ip=128.199.63.193; envelope-from=its@irrelevant.dk; helo=charlie.dont.surf X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 10:20:31 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Eduardo Habkost , qemu-block@nongnu.org, "Michael S. Tsirkin" , Klaus Jensen , Max Reitz , Keith Busch , Klaus Jensen , Maxim Levitsky Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Prepare to support inactive namespaces. Signed-off-by: Klaus Jensen Reviewed-by: Maxim Levitsky --- hw/block/nvme.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 6340af226341..4155cb797856 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1538,7 +1538,7 @@ static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeRequest *req) uint32_t min_nsid = le32_to_cpu(c->nsid); uint32_t *list; uint16_t ret; - int i, j = 0; + int j = 0; trace_pci_nvme_identify_nslist(min_nsid); @@ -1553,11 +1553,11 @@ static uint16_t nvme_identify_nslist(NvmeCtrl *n, NvmeRequest *req) } list = g_malloc0(data_len); - for (i = 0; i < n->num_namespaces; i++) { - if (i < min_nsid) { + for (int i = 1; i <= n->num_namespaces; i++) { + if (i <= min_nsid) { continue; } - list[j++] = cpu_to_le32(i + 1); + list[j++] = cpu_to_le32(i); if (j == data_len / sizeof(uint32_t)) { break; }