From patchwork Thu Feb 2 16:45:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 139177 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 5C877104792 for ; Fri, 3 Feb 2012 04:17:16 +1100 (EST) Received: from localhost ([::1]:52812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RszoI-0006lH-5J for incoming@patchwork.ozlabs.org; Thu, 02 Feb 2012 11:46:58 -0500 Received: from eggs.gnu.org ([140.186.70.92]:35339) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rszno-0005R3-7e for qemu-devel@nongnu.org; Thu, 02 Feb 2012 11:46:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rsznh-0002bf-Oj for qemu-devel@nongnu.org; Thu, 02 Feb 2012 11:46:28 -0500 Received: from mail-pw0-f45.google.com ([209.85.160.45]:42927) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rsznh-0002Zb-Jw for qemu-devel@nongnu.org; Thu, 02 Feb 2012 11:46:21 -0500 Received: by mail-pw0-f45.google.com with SMTP id a11so2778423pba.4 for ; Thu, 02 Feb 2012 08:46:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:subject:date:message-id:x-mailer:in-reply-to :references; bh=tKP1aDTi5xQDhQ4Y7u9RmFUNiRlAMeQfak9kzcGc4og=; b=DW3wIsRn+7RdRteYGncfyMAObXs2mlRXltTGDDNOd6O+9HqNuNgmT254eDAE1dg4xI KflNnkYrCywazv+kc7asVy6kmX6zTxiLOMvgmTnpWhKhje1/dkzqukh4Bjr0l+wizKHt qI3Q4e5cgNPaHVOb1TQtQeuAkthBBkSP5XTZA= Received: by 10.68.227.132 with SMTP id sa4mr9173432pbc.64.1328201181204; Thu, 02 Feb 2012 08:46:21 -0800 (PST) Received: from yakj.usersys.redhat.com (93-34-182-16.ip50.fastwebnet.it. [93.34.182.16]) by mx.google.com with ESMTPS id x4sm6756321pbx.16.2012.02.02.08.46.18 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 02 Feb 2012 08:46:20 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 2 Feb 2012 17:45:36 +0100 Message-Id: <1328201142-26145-11-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.7.6 In-Reply-To: <1328201142-26145-1-git-send-email-pbonzini@redhat.com> References: <1328201142-26145-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Subject: [Qemu-devel] [PATCH 10/16] qdev: make the non-legacy pci address property accept an integer 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 PCI addresses are set with qdev_prop_uint32. Thus we make the QOM property accept a device and function encoded in an 8-bit integer, instead of the magic dd.f hex string. Signed-off-by: Paolo Bonzini --- hw/qdev-properties.c | 25 +++++++------------------ 1 files changed, 7 insertions(+), 18 deletions(-) diff --git a/hw/qdev-properties.c b/hw/qdev-properties.c index 4fb5cf8..e4bcc6d 100644 --- a/hw/qdev-properties.c +++ b/hw/qdev-properties.c @@ -950,30 +950,19 @@ static int print_pci_devfn(DeviceState *dev, Property *prop, char *dest, size_t } } -static void get_pci_devfn(Object *obj, Visitor *v, void *opaque, - const char *name, Error **errp) -{ - DeviceState *dev = DEVICE(obj); - Property *prop = opaque; - uint32_t *ptr = qdev_get_prop_ptr(dev, prop); - char buffer[32]; - char *p = buffer; - - buffer[0] = 0; - if (*ptr != -1) { - snprintf(buffer, sizeof(buffer), "%02x.%x", *ptr >> 3, *ptr & 7); - } - visit_type_str(v, &p, name, errp); -} - PropertyInfo qdev_prop_pci_devfn = { .name = "pci-devfn", .type = PROP_TYPE_UINT32, .size = sizeof(uint32_t), .parse = parse_pci_devfn, .print = print_pci_devfn, - .get = get_pci_devfn, - .set = set_generic, + .get = get_int32, + .set = set_int32, + /* FIXME: this should be -1...255, but the address is stored + * into an uint32_t rather than int32_t. + */ + .min = 0, + .max = 0xFFFFFFFFULL, }; /* --- public helpers --- */