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:
parent
09b2fe1893
commit
3fc5150f36
1 changed files with 4 additions and 14 deletions
|
@ -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;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue