ipc_service: static_vrings: Use atomic helpers

Use the correct atomic helpers when accessing atomic_t variables and fix
a possible race condition.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
This commit is contained in:
Carlo Caione 2022-03-16 10:47:58 +01:00 committed by Carles Cufí
commit 3fc5150f36

View file

@ -352,16 +352,11 @@ static int register_ept(const struct device *instance, void **token,
struct ipc_rpmsg_instance *rpmsg_inst; struct ipc_rpmsg_instance *rpmsg_inst;
struct ipc_rpmsg_ept *rpmsg_ept; struct ipc_rpmsg_ept *rpmsg_ept;
/* Instance is still being initialized */ /* Instance is not ready */
if (data->state == STATE_BUSY) { if (atomic_get(&data->state) != STATE_INITED) {
return -EBUSY; return -EBUSY;
} }
/* Instance is not initialized */
if (data->state == STATE_READY) {
return -EINVAL;
}
/* Empty name is not valid */ /* Empty name is not valid */
if (cfg->name == NULL || cfg->name[0] == '\0') { if (cfg->name == NULL || cfg->name[0] == '\0') {
return -EINVAL; return -EINVAL;
@ -387,16 +382,11 @@ static int send(const struct device *instance, void *token,
struct backend_data_t *data = instance->data; struct backend_data_t *data = instance->data;
struct ipc_rpmsg_ept *rpmsg_ept; struct ipc_rpmsg_ept *rpmsg_ept;
/* Instance is still being initialized */ /* Instance is not ready */
if (data->state == STATE_BUSY) { if (atomic_get(&data->state) != STATE_INITED) {
return -EBUSY; return -EBUSY;
} }
/* Instance is not initialized */
if (data->state == STATE_READY) {
return -EINVAL;
}
/* Empty message is not allowed */ /* Empty message is not allowed */
if (len == 0) { if (len == 0) {
return -EBADMSG; return -EBADMSG;