From patchwork Thu Feb 18 20:06:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 8353861 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C77229F727 for ; Thu, 18 Feb 2016 20:07:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C2102024F for ; Thu, 18 Feb 2016 20:07:39 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C254A2020F for ; Thu, 18 Feb 2016 20:07:38 +0000 (UTC) Received: from localhost ([::1]:45036 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWUrR-0002cj-LN for patchwork-qemu-devel@patchwork.kernel.org; Thu, 18 Feb 2016 15:07:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55009) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWUqC-0000fR-AT for qemu-devel@nongnu.org; Thu, 18 Feb 2016 15:06:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWUq8-0008GX-1Y for qemu-devel@nongnu.org; Thu, 18 Feb 2016 15:06:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40371) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWUq7-0008GH-Sk for qemu-devel@nongnu.org; Thu, 18 Feb 2016 15:06:15 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 8D99751D; Thu, 18 Feb 2016 20:06:15 +0000 (UTC) Received: from gimli.home (ovpn-113-102.phx2.redhat.com [10.3.113.102]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1IK6FEe024089; Thu, 18 Feb 2016 15:06:15 -0500 From: Alex Williamson To: qemu-devel@nongnu.org Date: Thu, 18 Feb 2016 13:06:15 -0700 Message-ID: <20160218200614.29220.80255.stgit@gimli.home> In-Reply-To: <20160218200419.29220.39836.stgit@gimli.home> References: <20160218200419.29220.39836.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Wei Yang Subject: [Qemu-devel] [PULL 05/13] vfio/pci: replace 1 with PCI_CAP_LIST_NEXT to make code self-explain X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wei Yang Use the macro PCI_CAP_LIST_NEXT instead of 1, so that the code would be more self-explain. This patch makes this change and also fixs one typo in comment. Signed-off-by: Wei Yang Signed-off-by: Alex Williamson --- hw/vfio/pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index e671506..dc5fa9f 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -1509,7 +1509,7 @@ static uint8_t vfio_std_cap_max_size(PCIDevice *pdev, uint8_t pos) uint16_t next = PCI_CONFIG_SPACE_SIZE; for (tmp = pdev->config[PCI_CAPABILITY_LIST]; tmp; - tmp = pdev->config[tmp + 1]) { + tmp = pdev->config[tmp + PCI_CAP_LIST_NEXT]) { if (tmp > pos && tmp < next) { next = tmp; } @@ -1698,7 +1698,7 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos) int ret; cap_id = pdev->config[pos]; - next = pdev->config[pos + 1]; + next = pdev->config[pos + PCI_CAP_LIST_NEXT]; /* * If it becomes important to configure capabilities to their actual @@ -1712,7 +1712,7 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos) * pci_add_capability always inserts the new capability at the head * of the chain. Therefore to end up with a chain that matches the * physical device, we insert from the end by making this recursive. - * This is also why we pre-caclulate size above as cached config space + * This is also why we pre-calculate size above as cached config space * will be changed as we unwind the stack. */ if (next) { @@ -1728,7 +1728,7 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev, uint8_t pos) } /* Use emulated next pointer to allow dropping caps */ - pci_set_byte(vdev->emulated_config_bits + pos + 1, 0xff); + pci_set_byte(vdev->emulated_config_bits + pos + PCI_CAP_LIST_NEXT, 0xff); switch (cap_id) { case PCI_CAP_ID_MSI: