brintos

brintos / linux-shallow public Read only

0
0
Text · 934 B · d3a0b2e Raw
40 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * aQuantia Corporation Network Driver4 * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved5 */6 7/* File aq_utils.h: Useful macro and structures used in all layers of driver. */8 9#ifndef AQ_UTILS_H10#define AQ_UTILS_H11 12#include "aq_common.h"13 14static inline void aq_utils_obj_set(atomic_t *flags, u32 mask)15{16	unsigned long flags_old, flags_new;17 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);22}23 24static inline void aq_utils_obj_clear(atomic_t *flags, u32 mask)25{26	unsigned long flags_old, flags_new;27 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);32}33 34static inline bool aq_utils_obj_test(atomic_t *flags, u32 mask)35{36	return atomic_read(flags) & mask;37}38 39#endif /* AQ_UTILS_H */40