1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * aQuantia Corporation Network Driver
4 * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
7 /* File aq_utils.h: Useful macro and structures used in all layers of driver. */
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
;
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
;
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 */