blob: f74b7dfd47c7f2eac1d9656f8b8b466c9014b2da [file] [log] [blame]
Prakash Dhavali7090c5f2015-11-02 17:55:19 -08001/*
2 * Copyright (c) 2014-2015 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27#ifndef I_CDF_ATOMIC_H
28#define I_CDF_ATOMIC_H
29
30#include <cdf_status.h> /* CDF_STATUS */
31
32#include <linux/atomic.h>
33
34typedef atomic_t __cdf_atomic_t;
35
36static inline CDF_STATUS __cdf_atomic_init(__cdf_atomic_t *v)
37{
38 atomic_set(v, 0);
39
40 return CDF_STATUS_SUCCESS;
41}
42
43static inline uint32_t __cdf_atomic_read(__cdf_atomic_t *v)
44{
45 return atomic_read(v);
46}
47
48static inline void __cdf_atomic_inc(__cdf_atomic_t *v)
49{
50 atomic_inc(v);
51}
52
53static inline void __cdf_atomic_dec(__cdf_atomic_t *v)
54{
55 atomic_dec(v);
56}
57
58static inline void __cdf_atomic_add(int i, __cdf_atomic_t *v)
59{
60 atomic_add(i, v);
61}
62
63static inline uint32_t __cdf_atomic_dec_and_test(__cdf_atomic_t *v)
64{
65 return atomic_dec_and_test(v);
66}
67
68static inline void __cdf_atomic_set(__cdf_atomic_t *v, int i)
69{
70 atomic_set(v, i);
71}
72
73static inline uint32_t __cdf_atomic_inc_return(__cdf_atomic_t *v)
74{
75 return atomic_inc_return(v);
76}
77
78#endif