[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/16] qdev: introduce qdev_prop_find_bit()
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 12/16] qdev: introduce qdev_prop_find_bit() |
Date: |
Wed, 27 Nov 2013 23:28:52 +0100 |
helper to find a static property corresponding to a specific bit
in a specified field.
Signed-off-by: Igor Mammedov <address@hidden>
---
hw/core/qdev-properties.c | 15 +++++++++++++++
include/hw/qdev-properties.h | 13 +++++++++++++
2 files changed, 28 insertions(+)
diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c
index dc8ae69..5b8b059 100644
--- a/hw/core/qdev-properties.c
+++ b/hw/core/qdev-properties.c
@@ -965,6 +965,21 @@ static Property *qdev_prop_find(DeviceState *dev, 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)
{
diff --git a/include/hw/qdev-properties.h b/include/hw/qdev-properties.h
index 692f82e..c559197 100644
--- a/include/hw/qdev-properties.h
+++ b/include/hw/qdev-properties.h
@@ -195,4 +195,17 @@ void qdev_property_add_static(DeviceState *dev, Property
*prop, Error **errp);
*/
void qdev_prop_set_after_realize(DeviceState *dev, const char *name,
Error **errp);
+
+#define QDEV_PROP_FOREACH(_var, _class) \
+ for ((_var) = DEVICE_CLASS((_class))->props; \
+ (_var) && (_var)->name; \
+ (_var)++)
+
+#define QDEV_CLASS_FOREACH(_var, _class) \
+ 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);
#endif
--
1.8.3.1
- [Qemu-devel] [PATCH 03/16] target-i386: cpu: convert 'level' to static property, (continued)
- [Qemu-devel] [PATCH 03/16] target-i386: cpu: convert 'level' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 04/16] target-i386: cpu: convert 'xlevel' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 06/16] target-i386: cpu: convert 'model' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 07/16] target-i386: cpu: convert 'stepping' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 08/16] target-i386: cpu: convert 'vendor' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 11/16] target-i386: set [+-]feature using static properties, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 09/16] target-i386: cpu: convert 'model-id' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 10/16] target-i386: cpu: convert 'tsc-frequency' to static property, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 13/16] target-i386: use static properties in check_features_against_host() to print CPUID feature names, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 14/16] target-i386: use static properties to list CPUID features, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 12/16] qdev: introduce qdev_prop_find_bit(),
Igor Mammedov <=
- [Qemu-devel] [PATCH 16/16] target-i386: cpu: fix invalid use of error_is_set(errp) if errp == NULL, Igor Mammedov, 2013/11/27
- [Qemu-devel] [PATCH 15/16] target-i386: remove unused *_feature_name arrays, Igor Mammedov, 2013/11/27