From 06f280e5b5b7b96017f006d8c41efa4def2e55cb Mon Sep 17 00:00:00 2001 From: Chaithanya Garrepalli Date: Mon, 13 Jan 2020 16:00:34 +0530 Subject: [PATCH] qcacmn: add QDF wrapper for qdf_atomic_inc_not_zero Add API to increment atomic variable only when current value is non zero Change-Id: I3d0df35e39fb1b08b45e0731a86f002b5dbcb662 --- qdf/inc/qdf_atomic.h | 13 ++++++++++++- qdf/linux/src/i_qdf_atomic.h | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/qdf/inc/qdf_atomic.h b/qdf/inc/qdf_atomic.h index 57f66d3ead..3b888c388f 100644 --- a/qdf/inc/qdf_atomic.h +++ b/qdf/inc/qdf_atomic.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -154,6 +154,17 @@ static inline int32_t qdf_atomic_dec_return(qdf_atomic_t *v) return __qdf_atomic_dec_return(v); } +/** + * qdf_atomic_inc_not_zero() - increment if not zero + * @v: A pointer to an opaque atomic variable + * + * Return: Returns non-zero on successful increment and zero otherwise + */ +static inline int32_t qdf_atomic_inc_not_zero(qdf_atomic_t *v) +{ + return __qdf_atomic_inc_not_zero(v); +} + /** * qdf_atomic_set_bit - Atomically set a bit in memory * @nr: bit to set diff --git a/qdf/linux/src/i_qdf_atomic.h b/qdf/linux/src/i_qdf_atomic.h index 1af747d6aa..1d2cb2b30a 100644 --- a/qdf/linux/src/i_qdf_atomic.h +++ b/qdf/linux/src/i_qdf_atomic.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2020 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -147,6 +147,17 @@ static inline int32_t __qdf_atomic_dec_return(__qdf_atomic_t *v) return atomic_dec_return(v); } +/** + * __qdf_atomic_inc_not_zero() - increment if not zero + * @v: A pointer to an opaque atomic variable + * + * Return: Returns non-zero on successful increment and zero otherwise + */ +static inline int32_t __qdf_atomic_inc_not_zero(__qdf_atomic_t *v) +{ + return atomic_inc_not_zero(v); +} + /** * __qdf_atomic_set_bit - Atomically set a bit in memory * @nr: bit to set