2 * aQuantia Corporation Network Driver
3 * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
10 /* File aq_utils.h: Useful macro and structures used in all layers of driver. */
15 #include "aq_common.h"
17 #define AQ_DIMOF(_ARY_) ARRAY_SIZE(_ARY_)
23 static inline void aq_utils_obj_set(atomic_t *flags, u32 mask)
25 unsigned long flags_old, flags_new;
28 flags_old = atomic_read(flags);
29 flags_new = flags_old | (mask);
30 } while (atomic_cmpxchg(flags, flags_old, flags_new) != flags_old);
33 static inline void aq_utils_obj_clear(atomic_t *flags, u32 mask)
35 unsigned long flags_old, flags_new;
38 flags_old = atomic_read(flags);
39 flags_new = flags_old & ~(mask);
40 } while (atomic_cmpxchg(flags, flags_old, flags_new) != flags_old);
43 static inline bool aq_utils_obj_test(atomic_t *flags, u32 mask)
45 return atomic_read(flags) & mask;
48 #endif /* AQ_UTILS_H */