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_ept *rpmsg_ept;
|
||||
|
||||
/* Instance is still being initialized */
|
||||
if (data->state == STATE_BUSY) {
|
||||
/* Instance is not ready */
|
||||
if (atomic_get(&data->state) != STATE_INITED) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/* Instance is not initialized */
|
||||
if (data->state == STATE_READY) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Empty name is not valid */
|
||||
if (cfg->name == NULL || cfg->name[0] == '\0') {
|
||||
return -EINVAL;
|
||||
|
@ -387,16 +382,11 @@ static int send(const struct device *instance, void *token,
|
|||
struct backend_data_t *data = instance->data;
|
||||
struct ipc_rpmsg_ept *rpmsg_ept;
|
||||
|
||||
/* Instance is still being initialized */
|
||||
if (data->state == STATE_BUSY) {
|
||||
/* Instance is not ready */
|
||||
if (atomic_get(&data->state) != STATE_INITED) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/* Instance is not initialized */
|
||||
if (data->state == STATE_READY) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Empty message is not allowed */
|
||||
if (len == 0) {
|
||||
return -EBADMSG;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue