mbox: Enforce callback registration before enabling the channel
Specify in the API that the callback must be registered before the channel is enabled, fix the NRFX IPC driver to be compliant and change the MBOX sample. Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
parent
651854a323
commit
67ef1df950
4 changed files with 30 additions and 6 deletions
|
@ -89,7 +89,7 @@ static int mbox_nrf_register_callback(const struct device *dev, uint32_t channel
|
|||
{
|
||||
struct mbox_nrf_data *data = dev->data;
|
||||
|
||||
if (!is_rx_channel_valid(dev, channel)) {
|
||||
if (channel >= IPC_CONF_NUM) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,10 @@ static int mbox_nrf_set_enabled(const struct device *dev, uint32_t channel, bool
|
|||
return -EALREADY;
|
||||
}
|
||||
|
||||
if (enable && (data->cb[channel] == NULL)) {
|
||||
LOG_WRN("Enabling channel without a registered callback\n");
|
||||
}
|
||||
|
||||
if (enable && data->enabled_mask == 0) {
|
||||
irq_enable(DT_INST_IRQN(0));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue