From patchwork Sun Feb 19 23:41:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 142082 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5C8A1B6FA7 for ; Mon, 20 Feb 2012 10:41:52 +1100 (EST) Received: from localhost ([::1]:51006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzGO4-0006CD-QZ for incoming@patchwork.ozlabs.org; Sun, 19 Feb 2012 18:41:48 -0500 Received: from eggs.gnu.org ([140.186.70.92]:59972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzGNy-0006Bw-NF for qemu-devel@nongnu.org; Sun, 19 Feb 2012 18:41:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RzGNx-0008P3-K2 for qemu-devel@nongnu.org; Sun, 19 Feb 2012 18:41:42 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzGNx-0008Ox-3x for qemu-devel@nongnu.org; Sun, 19 Feb 2012 18:41:41 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1JNfd51014219 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 19 Feb 2012 18:41:40 -0500 Received: from redhat.com (vpn-200-7.tlv.redhat.com [10.35.200.7]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id q1JNfb4J022503; Sun, 19 Feb 2012 18:41:38 -0500 Date: Mon, 20 Feb 2012 01:41:45 +0200 From: "Michael S. Tsirkin" To: yamahata@valinux.co.jp, kraxel@redhat.com Message-ID: <20120219234145.GA29655@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH] pci_bridge: user-friendly default bus name 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org For a pci bridge device, if we don't override the name with custom code, the bus will be addressed as .0, where id is the id specified by the user. Since PCI Bridge devices have a single bus each, we don't need the index: address the bus using the parent device name. This is better since this way users don't care about our internal bus/device distinctions. As far as I could see, we only have built-in bridges at this point which always override the name. So this change will only affect ioh3420.c. Comments? Signed-off-by: Michael S. Tsirkin --- hw/pci_bridge.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/hw/pci_bridge.c b/hw/pci_bridge.c index fea3873..eeee8a6 100644 --- a/hw/pci_bridge.c +++ b/hw/pci_bridge.c @@ -314,6 +314,16 @@ int pci_bridge_initfn(PCIDevice *dev) pci_set_word(dev->config + PCI_SEC_STATUS, PCI_STATUS_66MHZ | PCI_STATUS_FAST_BACK); + /* + * If we don't specify the name, the bus will be addressed as .0, where + * id is the device id. + * Since PCI Bridge devices have a single bus each, we don't need the index: + * let users address the bus using the device name. + */ + if (!br->bus_name && dev->qdev.id && *dev->qdev.id) { + br->bus_name = dev->qdev.id; + } + qbus_create_inplace(&sec_bus->qbus, &pci_bus_info, &dev->qdev, br->bus_name); sec_bus->parent_dev = dev;