gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / net / ethernet / aquantia / atlantic / aq_utils.h
blobd3a0b2ec02794324fdb34daabbd1d9ee616b785b
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * aQuantia Corporation Network Driver
4 * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
5 */
7 /* File aq_utils.h: Useful macro and structures used in all layers of driver. */
9 #ifndef AQ_UTILS_H
10 #define AQ_UTILS_H
12 #include "aq_common.h"
14 static inline void aq_utils_obj_set(atomic_t *flags, u32 mask)
16 unsigned long flags_old, flags_new;
18 do {
19 flags_old = atomic_read(flags);
20 flags_new = flags_old | (mask);
21 } while (atomic_cmpxchg(flags, flags_old, flags_new) != flags_old);
24 static inline void aq_utils_obj_clear(atomic_t *flags, u32 mask)
26 unsigned long flags_old, flags_new;
28 do {
29 flags_old = atomic_read(flags);
30 flags_new = flags_old & ~(mask);
31 } while (atomic_cmpxchg(flags, flags_old, flags_new) != flags_old);
34 static inline bool aq_utils_obj_test(atomic_t *flags, u32 mask)
36 return atomic_read(flags) & mask;
39 #endif /* AQ_UTILS_H */