> Subject: [PATCH 16/19] 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>
> ---
> hw/i3c/aspeed_i3c.c | 9 +++++++++
> include/hw/i3c/aspeed_i3c.h | 2 ++
> 2 files changed, 11 insertions(+)
>
> diff --git a/hw/i3c/aspeed_i3c.c b/hw/i3c/aspeed_i3c.c index
> 1ad25e5a00..af1ff5bc12 100644
> --- a/hw/i3c/aspeed_i3c.c
> +++ b/hw/i3c/aspeed_i3c.c
> @@ -153,6 +153,15 @@ static const MemoryRegionOps aspeed_i3c_ops = {
> }
> };
>
> +I3CBus *aspeed_i3c_get_bus(AspeedI3CState *s, uint8_t bus_num) {
> + if (bus_num < ARRAY_SIZE(s->devices)) {
> + return s->devices[bus_num].bus;
> + }
> + /* Developer error, fail fast. */
> + g_assert_not_reached();
> +}
> +
> static void aspeed_i3c_reset(DeviceState *dev) {
> AspeedI3CState *s = ASPEED_I3C(dev); diff --git
> a/include/hw/i3c/aspeed_i3c.h b/include/hw/i3c/aspeed_i3c.h index
> 9833292ec0..b3e4d1055c 100644
> --- a/include/hw/i3c/aspeed_i3c.h
> +++ b/include/hw/i3c/aspeed_i3c.h
> @@ -34,3 +34,5 @@ typedef struct AspeedI3CState {
> uint8_t id;
> } AspeedI3CState;
> #endif /* ASPEED_I3C_H */
> +
> +I3CBus *aspeed_i3c_get_bus(AspeedI3CState *s, uint8_t bus_num);
> --
> 2.50.0.rc1.591.g9c95f17f64-goog
Reviewed-by: Jamin Lin <jamin_lin@aspeedtech.com>
Thanks,
Jamin