From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Igor Mammedov 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> Subject: [Qemu-devel] [PATCH 34/37] qdev: introduce QDEV_FIND_PROP_FROM_BIT and qdev_prop_find_bit() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 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) { -- 1.7.11.7