From patchwork Mon Oct 22 15:03:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 193169 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7C7C12C007B for ; Tue, 23 Oct 2012 02:05:41 +1100 (EST) Received: from localhost ([::1]:46032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQJZT-0003rw-6M for incoming@patchwork.ozlabs.org; Mon, 22 Oct 2012 11:05:39 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60028) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQJZF-0003rV-L9 for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:05:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TQJZ8-0001BJ-W5 for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:05:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25574) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TQJZ8-00018r-N2 for qemu-devel@nongnu.org; Mon, 22 Oct 2012 11:05:18 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9MF5CCv016330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 22 Oct 2012 11:05:14 -0400 Received: from nial.brq.redhat.com (dhcp-1-247.brq.redhat.com [10.34.1.247]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9MF3OnZ031350; Mon, 22 Oct 2012 11:05:09 -0400 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Mon, 22 Oct 2012 17:03:20 +0200 Message-Id: <1350918203-25198-35-git-send-email-imammedo@redhat.com> In-Reply-To: <1350918203-25198-1-git-send-email-imammedo@redhat.com> References: <1350918203-25198-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com, ehabkost@redhat.com, jan.kiszka@siemens.com, Don@CloudSwitch.com, mdroth@linux.vnet.ibm.com, blauwirbel@gmail.com, stefanha@redhat.com, pbonzini@redhat.com, afaerber@suse.de Subject: [Qemu-devel] [PATCH 34/37] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit() 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 it allows to find bit static property corresponding to a specific bit in specified field. Signed-off-by: Igor Mammedov --- * it will be used by next commit to print cpuid feature names for unavailable feature bits. --- hw/qdev-properties.h | 8 ++++++++ qom/qdev-properties.c | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/hw/qdev-properties.h b/hw/qdev-properties.h index 19b55c0..88b6782 100644 --- a/hw/qdev-properties.h +++ b/hw/qdev-properties.h @@ -144,4 +144,12 @@ const Property *qdev_prop_find(const DeviceClass *dc, const char *name); for ((_var) = (_class); \ (_var) != DEVICE_CLASS(object_class_by_name(TYPE_DEVICE)); \ (_var) = DEVICE_CLASS(object_class_get_parent(OBJECT_CLASS((_var))))) + +const Property *qdev_prop_find_bit(const DeviceClass *dc, const int offset, + const uint8_t bitnr); +#define QDEV_FIND_PROP_FROM_BIT(_class, _state, _field, _bitnr) \ + qdev_prop_find_bit(_class, \ + offsetof(_state, _field) + \ + type_check(uint32_t, typeof_field(_state, _field)), \ + _bitnr) #endif diff --git a/qom/qdev-properties.c b/qom/qdev-properties.c index 3d3eefa..2e589c6 100644 --- a/qom/qdev-properties.c +++ b/qom/qdev-properties.c @@ -787,6 +787,21 @@ const Property *qdev_prop_find(const DeviceClass *dc, const char *name) return NULL; } +const Property *qdev_prop_find_bit(const DeviceClass *dc, const int offset, + const uint8_t bitnr) +{ + const Property *prop; + + QDEV_CLASS_FOREACH(dc, dc) { + QDEV_PROP_FOREACH(prop, dc) { + if (prop->offset == offset && prop->bitnr == bitnr) { + return prop; + } + } + } + return NULL; +} + void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev, Property *prop, const char *value) {