]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - drivers/net/ethernet/aquantia/atlantic/aq_utils.h
ASoC: cs4271: configure reset GPIO as output
[mirror_ubuntu-eoan-kernel.git] / drivers / net / ethernet / aquantia / atlantic / aq_utils.h
CommitLineData
3a35780f
DV
1/*
2 * aQuantia Corporation Network Driver
3 * Copyright (C) 2014-2017 aQuantia Corporation. All rights reserved
4 *
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 */
9
10/* File aq_utils.h: Useful macro and structures used in all layers of driver. */
11
12#ifndef AQ_UTILS_H
13#define AQ_UTILS_H
14
15#include "aq_common.h"
16
17#define AQ_DIMOF(_ARY_) ARRAY_SIZE(_ARY_)
18
19struct aq_obj_s {
20 spinlock_t lock; /* spinlock for nic/rings processing */
21 atomic_t flags;
3a35780f
DV
22};
23
24static inline void aq_utils_obj_set(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 void aq_utils_obj_clear(atomic_t *flags, u32 mask)
35{
36 unsigned long flags_old, flags_new;
37
38 do {
39 flags_old = atomic_read(flags);
40 flags_new = flags_old & ~(mask);
41 } while (atomic_cmpxchg(flags, flags_old, flags_new) != flags_old);
42}
43
44static inline bool aq_utils_obj_test(atomic_t *flags, u32 mask)
45{
46 return atomic_read(flags) & mask;
47}
48
49#endif /* AQ_UTILS_H */