@samitouri / QOSamiQemu / commits / 7ffc895802

hw/i3c/aspeed: Add I3C bus get function

To retrieve the I3C bus object normally, the order is Aspeed I3C -> DW I3C[n] -> bus object, so make a nice wrapper for people to use. Signed-off-by: Joe Komlodi <komlodi@google.com> Reviewed-by: Jamin Lin <jamin_lin@aspeedtech.com> Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com> Tested-by: Jithu Joseph <jithu.joseph@oss.qualcomm.com> Link: https://lore.kernel.org/qemu-devel/20260225021158.1586584-18-jamin_lin@aspeedtech.com Signed-off-by: Cédric Le Goater <clg@redhat.com>

Jamin Lin committed Feb 25, 2026 at 02:12 UTC 7ffc8958028c8e1539f1ccda8db6d4dd86f6e5e4
2 files changed +12
hw/i3c/aspeed_i3c.c
+9
@@ -153,6 +153,15 @@ static const MemoryRegionOps aspeed_i3c_ops = {
153 }
154 };
155
156 +I3CBus *aspeed_i3c_get_bus(AspeedI3CState *s, uint8_t bus_num)
157 +{
158 + if (bus_num < ARRAY_SIZE(s->devices)) {
159 + return s->devices[bus_num].bus;
160 + }
161 + /* Developer error, fail fast. */
162 + g_assert_not_reached();
163 +}
164 +
165 static void aspeed_i3c_reset(DeviceState *dev)
166 {
167 AspeedI3CState *s = ASPEED_I3C(dev);
include/hw/i3c/aspeed_i3c.h
+3
@@ -31,4 +31,7 @@ struct AspeedI3CState {
31 DWI3C devices[ASPEED_I3C_NR_DEVICES];
32 uint8_t id;
33 };
34 +
35 +I3CBus *aspeed_i3c_get_bus(AspeedI3CState *s, uint8_t bus_num);
36 +
37 #endif /* ASPEED_I3C_H */