diff --git a/src/guest/maple/controller.c b/src/guest/maple/controller.c index b0eaa158..306dfdab 100644 --- a/src/guest/maple/controller.c +++ b/src/guest/maple/controller.c @@ -34,9 +34,9 @@ struct controller { struct maple_cond cnd; }; -static void controller_frame(struct maple_device *dev, - const union maple_frame *req, - union maple_frame *res) { +static int controller_frame(struct maple_device *dev, + const union maple_frame *req, + union maple_frame *res) { struct controller *ctrl = (struct controller *)dev; /* forward to sub-device if specified */ @@ -45,8 +45,7 @@ static void controller_frame(struct maple_device *dev, struct maple_device *sub = maple_get_device(dev->mp, port, unit); if (sub != dev) { - sub->frame(sub, req, res); - return; + return sub && sub->frame(sub, req, res); } switch (req->command) { @@ -98,6 +97,8 @@ static void controller_frame(struct maple_device *dev, res->src_addr |= 1 << i; } + + return 1; } static int controller_input(struct maple_device *dev, int button, diff --git a/src/guest/maple/maple.c b/src/guest/maple/maple.c index bda9a4c8..522c74bf 100644 --- a/src/guest/maple/maple.c +++ b/src/guest/maple/maple.c @@ -49,12 +49,7 @@ int maple_handle_frame(struct maple *mp, int port, union maple_frame *frame, frame data bswap'd. for this reason, it's not valid to inspect the frame data in order to send the frame directly to the correct sub-device */ struct maple_device *dev = mp->devs[port][MAPLE_MAX_UNITS - 1]; - if (!dev) { - return 0; - } - - dev->frame(dev, frame, res); - return 1; + return dev && dev->frame(dev, frame, res); } void maple_handle_input(struct maple *mp, int port, int button, diff --git a/src/guest/maple/maple.h b/src/guest/maple/maple.h index 1b7d090d..75f6d38f 100644 --- a/src/guest/maple/maple.h +++ b/src/guest/maple/maple.h @@ -11,8 +11,8 @@ struct maple_device { struct maple *mp; void (*destroy)(struct maple_device *); int (*input)(struct maple_device *, int, uint16_t); - void (*frame)(struct maple_device *, const union maple_frame *, - union maple_frame *); + int (*frame)(struct maple_device *, const union maple_frame *, + union maple_frame *); }; uint8_t maple_encode_addr(int port, int unit); diff --git a/src/guest/maple/vmu.c b/src/guest/maple/vmu.c index 90764cf2..87714a81 100644 --- a/src/guest/maple/vmu.c +++ b/src/guest/maple/vmu.c @@ -53,8 +53,8 @@ static void vmu_parse_block_param(uint32_t data, int *partition, int *block, *phase = (data >> 8) & 0xff; } -static void vmu_frame(struct maple_device *dev, const union maple_frame *req, - union maple_frame *res) { +static int vmu_frame(struct maple_device *dev, const union maple_frame *req, + union maple_frame *res) { struct vmu *vmu = (struct vmu *)dev; switch (req->command) { @@ -155,6 +155,8 @@ static void vmu_frame(struct maple_device *dev, const union maple_frame *req, res->num_words = 0; } break; } + + return 1; } static void vmu_destroy(struct maple_device *dev) {