[02/16] common/cnxk: use previous value atomic fetch operations
Checks
Commit Message
Use __atomic_fetch_{add,and,or,sub,xor} instead of
__atomic_{add,and,or,sub,xor}_fetch adding the necessary code to
allow consumption of the resulting value.
Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
---
drivers/common/cnxk/roc_ae.c | 2 +-
drivers/common/cnxk/roc_ae_fpm_tables.c | 2 +-
drivers/common/cnxk/roc_npa.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
@@ -203,6 +203,6 @@ struct ae_ec_grp_tbl {
ec_grp = mz->addr;
/* Decrement number of devices using EC grp table */
- if (__atomic_sub_fetch(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) == 0)
+ if (__atomic_fetch_sub(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0)
plt_memzone_free(mz);
}
@@ -1135,6 +1135,6 @@ struct ae_fpm_tbl {
fpm = (struct ae_fpm_tbl *)mz->addr;
/* Decrement number of devices using FPM table */
- if (__atomic_sub_fetch(&fpm->refcount, 1, __ATOMIC_SEQ_CST) == 0)
+ if (__atomic_fetch_sub(&fpm->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0)
plt_memzone_free(mz);
}
@@ -946,7 +946,7 @@
return NPA_ERR_ALLOC;
/* Not the last PCI device */
- if (__atomic_sub_fetch(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) != 0)
+ if (__atomic_fetch_sub(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) - 1 != 0)
return 0;
npa_unregister_irqs(idev->npa);