From patchwork Wed Apr 7 08:04:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 49577 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 078BFB7D30 for ; Wed, 7 Apr 2010 18:35:50 +1000 (EST) Received: from localhost ([127.0.0.1]:34501 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzQjO-0003Ul-9L for incoming@patchwork.ozlabs.org; Wed, 07 Apr 2010 04:35:26 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NzQIm-0001qG-GK for qemu-devel@nongnu.org; Wed, 07 Apr 2010 04:07:56 -0400 Received: from [140.186.70.92] (port=42772 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NzQIj-0001ox-PM for qemu-devel@nongnu.org; Wed, 07 Apr 2010 04:07:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NzQIg-000855-Mu for qemu-devel@nongnu.org; Wed, 07 Apr 2010 04:07:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43914) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NzQIg-00084v-Fc for qemu-devel@nongnu.org; Wed, 07 Apr 2010 04:07:50 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o3787mfm008584 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 7 Apr 2010 04:07:48 -0400 Received: from redhat.com (vpn2-11-250.ams2.redhat.com [10.36.11.250]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id o3787k0S026818; Wed, 7 Apr 2010 04:07:47 -0400 Date: Wed, 7 Apr 2010 11:04:08 +0300 From: "Michael S. Tsirkin" To: weil@mail.berlios.de, qemu-devel@nongnu.org Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH 2/2] eepro100: convert to new capability API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Using new pci_add_capability_at_offset makes eepro100 code cleaner. Signed-off-by: Michael S. Tsirkin Acked-by: Stefan Weil --- hw/eepro100.c | 22 +++++++++------------- 1 files changed, 9 insertions(+), 13 deletions(-) diff --git a/hw/eepro100.c b/hw/eepro100.c index 785a7da..a74d834 100644 --- a/hw/eepro100.c +++ b/hw/eepro100.c @@ -539,21 +539,17 @@ static void e100_pci_reset(EEPRO100State * s, E100PCIDeviceInfo *e100_device) if (e100_device->power_management) { /* Power Management Capabilities */ - int cfg_offset; - pci_reserve_capability(&s->dev, PCI_CONFIG_HEADER_SIZE, - 0xdc - PCI_CONFIG_HEADER_SIZE); - cfg_offset = pci_add_capability(&s->dev, PCI_CAP_ID_PM, PCI_PM_SIZEOF); - assert(cfg_offset == 0xdc); - if (cfg_offset > 0) { - /* Power Management Capabilities */ - pci_set_word(pci_conf + cfg_offset + PCI_PM_PMC, 0x7e21); + int cfg_offset = 0xdc; + int r = pci_add_capability_at_offset(&s->dev, PCI_CAP_ID_PM, + cfg_offset, PCI_PM_SIZEOF); + assert(r >= 0); + pci_set_word(pci_conf + cfg_offset + PCI_PM_PMC, 0x7e21); #if 0 /* TODO: replace dummy code for power management emulation. */ - /* TODO: Power Management Control / Status. */ - pci_set_word(pci_conf + cfg_offset + PCI_PM_CTRL, 0x0000); - /* TODO: Ethernet Power Consumption Registers (i82559 and later). */ - pci_set_byte(pci_conf + cfg_offset + PCI_PM_PPB_EXTENSIONS, 0x0000); + /* TODO: Power Management Control / Status. */ + pci_set_word(pci_conf + cfg_offset + PCI_PM_CTRL, 0x0000); + /* TODO: Ethernet Power Consumption Registers (i82559 and later). */ + pci_set_byte(pci_conf + cfg_offset + PCI_PM_PPB_EXTENSIONS, 0x0000); #endif - } } #if EEPROM_SIZE > 0