return the maple frame was unhandled if sub-device doesn't exist

This commit is contained in:
Anthony Pesch 2017-11-17 21:57:25 -05:00
parent 00e5376562
commit f18f684b2f
4 changed files with 13 additions and 15 deletions

View File

@ -34,7 +34,7 @@ struct controller {
struct maple_cond cnd;
};
static void controller_frame(struct maple_device *dev,
static int controller_frame(struct maple_device *dev,
const union maple_frame *req,
union maple_frame *res) {
struct controller *ctrl = (struct controller *)dev;
@ -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,

View File

@ -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,

View File

@ -11,7 +11,7 @@ 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 *,
int (*frame)(struct maple_device *, const union maple_frame *,
union maple_frame *);
};

View File

@ -53,7 +53,7 @@ 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,
static int vmu_frame(struct maple_device *dev, const union maple_frame *req,
union maple_frame *res) {
struct vmu *vmu = (struct vmu *)dev;
@ -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) {