mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-30 15:00:34 +00:00
a27bd6c779
In my "build everything" tree, changing hw/qdev-properties.h triggers a recompile of some 2700 out of 6600 objects (not counting tests and objects that don't depend on qemu/osdep.h). Many places including hw/qdev-properties.h (directly or via hw/qdev.h) actually need only hw/qdev-core.h. Include hw/qdev-core.h there instead. hw/qdev.h is actually pointless: all it does is include hw/qdev-core.h and hw/qdev-properties.h, which in turn includes hw/qdev-core.h. Replace the remaining uses of hw/qdev.h by hw/qdev-properties.h. While there, delete a few superfluous inclusions of hw/qdev-core.h. Touching hw/qdev-properties.h now recompiles some 1200 objects. Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: "Daniel P. Berrangé" <berrange@redhat.com> Cc: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Message-Id: <20190812052359.30071-22-armbru@redhat.com>
97 lines
2.3 KiB
C
97 lines
2.3 KiB
C
/*
|
|
* qdev fw helpers
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License,
|
|
* or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "hw/fw-path-provider.h"
|
|
#include "hw/qdev-core.h"
|
|
|
|
const char *qdev_fw_name(DeviceState *dev)
|
|
{
|
|
DeviceClass *dc = DEVICE_GET_CLASS(dev);
|
|
|
|
if (dc->fw_name) {
|
|
return dc->fw_name;
|
|
}
|
|
|
|
return object_get_typename(OBJECT(dev));
|
|
}
|
|
|
|
static char *bus_get_fw_dev_path(BusState *bus, DeviceState *dev)
|
|
{
|
|
BusClass *bc = BUS_GET_CLASS(bus);
|
|
|
|
if (bc->get_fw_dev_path) {
|
|
return bc->get_fw_dev_path(dev);
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
static char *qdev_get_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
|
|
{
|
|
Object *obj = OBJECT(dev);
|
|
char *d = NULL;
|
|
|
|
while (!d && obj->parent) {
|
|
obj = obj->parent;
|
|
d = fw_path_provider_try_get_dev_path(obj, bus, dev);
|
|
}
|
|
return d;
|
|
}
|
|
|
|
char *qdev_get_own_fw_dev_path_from_handler(BusState *bus, DeviceState *dev)
|
|
{
|
|
Object *obj = OBJECT(dev);
|
|
|
|
return fw_path_provider_try_get_dev_path(obj, bus, dev);
|
|
}
|
|
|
|
static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
|
|
{
|
|
int l = 0;
|
|
|
|
if (dev && dev->parent_bus) {
|
|
char *d;
|
|
l = qdev_get_fw_dev_path_helper(dev->parent_bus->parent, p, size);
|
|
d = qdev_get_fw_dev_path_from_handler(dev->parent_bus, dev);
|
|
if (!d) {
|
|
d = bus_get_fw_dev_path(dev->parent_bus, dev);
|
|
}
|
|
if (d) {
|
|
l += snprintf(p + l, size - l, "%s", d);
|
|
g_free(d);
|
|
} else {
|
|
return l;
|
|
}
|
|
}
|
|
l += snprintf(p + l , size - l, "/");
|
|
|
|
return l;
|
|
}
|
|
|
|
char *qdev_get_fw_dev_path(DeviceState *dev)
|
|
{
|
|
char path[128];
|
|
int l;
|
|
|
|
l = qdev_get_fw_dev_path_helper(dev, path, 128);
|
|
|
|
path[l - 1] = '\0';
|
|
|
|
return g_strdup(path);
|
|
}
|