PageRenderTime 28ms CodeModel.GetById 21ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/net/bna/bfa_wc.h

https://bitbucket.org/wisechild/galaxy-nexus
C++ Header | 69 lines | 34 code | 9 blank | 26 comment | 2 complexity | 490ff3efeb0b7a61542a36582b52e4ed MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
 1/*
 2 * Linux network driver for Brocade Converged Network Adapter.
 3 *
 4 * This program is free software; you can redistribute it and/or modify it
 5 * under the terms of the GNU General Public License (GPL) Version 2 as
 6 * published by the Free Software Foundation
 7 *
 8 * This program is distributed in the hope that it will be useful, but
 9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 * General Public License for more details.
12 */
13/*
14 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
15 * All rights reserved
16 * www.brocade.com
17 */
18
19/**
20 * @file bfa_wc.h Generic wait counter.
21 */
22
23#ifndef __BFA_WC_H__
24#define __BFA_WC_H__
25
26typedef void (*bfa_wc_resume_t) (void *cbarg);
27
28struct bfa_wc {
29	bfa_wc_resume_t wc_resume;
30	void		*wc_cbarg;
31	int		wc_count;
32};
33
34static inline void
35bfa_wc_up(struct bfa_wc *wc)
36{
37	wc->wc_count++;
38}
39
40static inline void
41bfa_wc_down(struct bfa_wc *wc)
42{
43	wc->wc_count--;
44	if (wc->wc_count == 0)
45		wc->wc_resume(wc->wc_cbarg);
46}
47
48/**
49 * Initialize a waiting counter.
50 */
51static inline void
52bfa_wc_init(struct bfa_wc *wc, bfa_wc_resume_t wc_resume, void *wc_cbarg)
53{
54	wc->wc_resume = wc_resume;
55	wc->wc_cbarg = wc_cbarg;
56	wc->wc_count = 0;
57	bfa_wc_up(wc);
58}
59
60/**
61 * Wait for counter to reach zero
62 */
63static inline void
64bfa_wc_wait(struct bfa_wc *wc)
65{
66	bfa_wc_down(wc);
67}
68
69#endif