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 static inline void aq_utils_obj_set(atomic_t *flags, u32 mask)
19 unsigned long flags_old, flags_new;
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;
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 */