On 12/09/2021 16:15, Philippe Mathieu-Daudé wrote:

On 9/12/21 9:48 AM, Mark Cave-Ayland wrote:
This prepares for allowing Nubus devices to be placed in a specific slot instead
of always being auto-allocated by the bus itself.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayl...@ilande.co.uk>
---
  hw/nubus/nubus-device.c  | 6 ++++++
  include/hw/nubus/nubus.h | 2 +-
  2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/nubus/nubus-device.c b/hw/nubus/nubus-device.c
index 36203848e5..c1832f73da 100644
--- a/hw/nubus/nubus-device.c
+++ b/hw/nubus/nubus-device.c
@@ -191,12 +191,18 @@ static void nubus_device_realize(DeviceState *dev, Error 
**errp)
      nubus_register_format_block(nd);
  }
+static Property nubus_device_properties[] = {
+    DEFINE_PROP_INT32("slot", NubusDevice, slot, -1),
+    DEFINE_PROP_END_OF_LIST()
+};
+
  static void nubus_device_class_init(ObjectClass *oc, void *data)
  {
      DeviceClass *dc = DEVICE_CLASS(oc);
dc->realize = nubus_device_realize;
      dc->bus_type = TYPE_NUBUS_BUS;
+    device_class_set_props(dc, nubus_device_properties);

Can we reorder this after #4 where you sanity check 'slot'
in nubus_device_realize()? First sanity check, then expose
the property.

The slot number is already being checked at this point to ensure that it lies between NUBUS_FIRST_SLOT and NUBUS_LAST_SLOT (see the change to NUBUS_FIRST_SLOT in patch 4). Note that patch 4 also converts the range 0x9-0xf to the equivalent bitmask to ensure there should be no change in the available slots.


ATB,

Mark.

Reply via email to