diff mbox series

[v4,06/20] nubus: implement BusClass get_dev_path()

Message ID 20210917075057.20924-7-mark.cave-ayland@ilande.co.uk (mailing list archive)
State New, archived
Headers show
Series nubus: bus, device, bridge, IRQ and address space improvements | expand

Commit Message

Mark Cave-Ayland Sept. 17, 2021, 7:50 a.m. UTC
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/nubus/nubus-bus.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Laurent Vivier Sept. 20, 2021, 7:57 p.m. UTC | #1
Le 17/09/2021 à 09:50, Mark Cave-Ayland a écrit :
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  hw/nubus/nubus-bus.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/hw/nubus/nubus-bus.c b/hw/nubus/nubus-bus.c
> index 141876b579..63e7d66b95 100644
> --- a/hw/nubus/nubus-bus.c
> +++ b/hw/nubus/nubus-bus.c
> @@ -87,6 +87,21 @@ static void nubus_init(Object *obj)
>      nubus->slot_available_mask = MAKE_64BIT_MASK(0, 16);
>  }
>  
> +static char *nubus_get_dev_path(DeviceState *dev)
> +{
> +    NubusDevice *nd = NUBUS_DEVICE(dev);
> +    BusState *bus = qdev_get_parent_bus(dev);
> +    char *p = qdev_get_dev_path(bus->parent);
> +
> +    if (p) {
> +        char *ret = g_strdup_printf("%s/%s/%02x", p, bus->name, nd->slot);
> +        g_free(p);
> +        return ret;
> +    } else {
> +        return g_strdup_printf("%s/%02x", bus->name, nd->slot);
> +    }
> +}
> +
>  static bool nubus_check_address(BusState *bus, DeviceState *dev, Error **errp)
>  {
>      NubusDevice *nd = NUBUS_DEVICE(dev);
> @@ -129,6 +144,7 @@ static void nubus_class_init(ObjectClass *oc, void *data)
>  
>      bc->realize = nubus_realize;
>      bc->check_address = nubus_check_address;
> +    bc->get_dev_path = nubus_get_dev_path;
>  }
>  
>  static const TypeInfo nubus_bus_info = {
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
diff mbox series

Patch

diff --git a/hw/nubus/nubus-bus.c b/hw/nubus/nubus-bus.c
index 141876b579..63e7d66b95 100644
--- a/hw/nubus/nubus-bus.c
+++ b/hw/nubus/nubus-bus.c
@@ -87,6 +87,21 @@  static void nubus_init(Object *obj)
     nubus->slot_available_mask = MAKE_64BIT_MASK(0, 16);
 }
 
+static char *nubus_get_dev_path(DeviceState *dev)
+{
+    NubusDevice *nd = NUBUS_DEVICE(dev);
+    BusState *bus = qdev_get_parent_bus(dev);
+    char *p = qdev_get_dev_path(bus->parent);
+
+    if (p) {
+        char *ret = g_strdup_printf("%s/%s/%02x", p, bus->name, nd->slot);
+        g_free(p);
+        return ret;
+    } else {
+        return g_strdup_printf("%s/%02x", bus->name, nd->slot);
+    }
+}
+
 static bool nubus_check_address(BusState *bus, DeviceState *dev, Error **errp)
 {
     NubusDevice *nd = NUBUS_DEVICE(dev);
@@ -129,6 +144,7 @@  static void nubus_class_init(ObjectClass *oc, void *data)
 
     bc->realize = nubus_realize;
     bc->check_address = nubus_check_address;
+    bc->get_dev_path = nubus_get_dev_path;
 }
 
 static const TypeInfo nubus_bus_info = {