aboutsummaryrefslogtreecommitdiff
path: root/hw/qdev.h
diff options
context:
space:
mode:
Diffstat (limited to 'hw/qdev.h')
-rw-r--r--hw/qdev.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/hw/qdev.h b/hw/qdev.h
index 1e01a042ce..e13111f093 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -69,9 +69,12 @@ typedef struct DeviceProperty
#define TYPE_DEVICE "device"
#define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)
+#define DEVICE_CLASS(klass) OBJECT_CLASS_CHECK(DeviceClass, (klass), TYPE_DEVICE)
+#define DEVICE_GET_CLASS(obj) OBJECT_GET_CLASS(DeviceClass, (obj), TYPE_DEVICE)
typedef struct DeviceClass {
ObjectClass parent_class;
+ DeviceInfo *info;
} DeviceClass;
/* This structure should not be accessed directly. We declare it here
@@ -83,7 +86,6 @@ struct DeviceState {
enum DevState state;
QemuOpts *opts;
int hotplugged;
- DeviceInfo *info;
BusState *parent_bus;
int num_gpio_out;
qemu_irq *gpio_out;
@@ -389,9 +391,19 @@ void qdev_prop_set_globals(DeviceState *dev);
void error_set_from_qdev_prop_error(Error **errp, int ret, DeviceState *dev,
Property *prop, const char *value);
+DeviceInfo *qdev_get_info(DeviceState *dev);
+
static inline const char *qdev_fw_name(DeviceState *dev)
{
- return dev->info->fw_name ? : dev->info->alias ? : dev->info->name;
+ DeviceInfo *info = qdev_get_info(dev);
+
+ if (info->fw_name) {
+ return info->fw_name;
+ } else if (info->alias) {
+ return info->alias;
+ }
+
+ return info->name;
}
char *qdev_get_fw_dev_path(DeviceState *dev);