Linux 4.19.133
[linux/fpc-iii.git] / drivers / net / ethernet / aquantia / atlantic / aq_utils.h
blob786ea8187c69b7d5cfc0763880bd433a41c043dc
1 /*
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.
8 */
10 /* File aq_utils.h: Useful macro and structures used in all layers of driver. */
12 #ifndef AQ_UTILS_H
13 #define AQ_UTILS_H
15 #include "aq_common.h"
17 static inline void aq_utils_obj_set(atomic_t *flags, u32 mask)
19 unsigned long flags_old, flags_new;
21 do {
22 flags_old = atomic_read(flags);
23 flags_new = flags_old | (mask);
24 } while (atomic_cmpxchg(flags, flags_old, flags_new) != flags_old);
27 static inline void aq_utils_obj_clear(atomic_t *flags, u32 mask)
29 unsigned long flags_old, flags_new;
31 do {
32 flags_old = atomic_read(flags);
33 flags_new = flags_old & ~(mask);
34 } while (atomic_cmpxchg(flags, flags_old, flags_new) != flags_old);
37 static inline bool aq_utils_obj_test(atomic_t *flags, u32 mask)
39 return atomic_read(flags) & mask;
42 #endif /* AQ_UTILS_H */