aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bna
diff options
context:
space:
mode:
authorRasesh Mody <rmody@brocade.com>2011-07-22 04:07:49 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-22 20:01:14 -0400
commit758ccc34389811c84382a79e198e4b6250ae0478 (patch)
tree99a19f9c3a4ac7f3243b2ac26741d85d757d6d8b /drivers/net/bna
parent9b08a4fce2245748f05b43e1c03fd1676079e003 (diff)
bna: Header File Consolidation
Change details: - Consolidated bfa_sm.h and bfa_wc.h into bfa_cs.h Signed-off-by: Rasesh Mody <rmody@brocade.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bna')
-rw-r--r--drivers/net/bna/bfa_cs.h (renamed from drivers/net/bna/bfa_sm.h)78
-rw-r--r--drivers/net/bna/bfa_ioc.h2
-rw-r--r--drivers/net/bna/bfa_wc.h69
-rw-r--r--drivers/net/bna/bna.h2
-rw-r--r--drivers/net/bna/bna_ctrl.c3
-rw-r--r--drivers/net/bna/bna_txrx.c2
6 files changed, 69 insertions, 87 deletions
diff --git a/drivers/net/bna/bfa_sm.h b/drivers/net/bna/bfa_cs.h
index 46462c49b6f9..3da1a946ccdd 100644
--- a/drivers/net/bna/bfa_sm.h
+++ b/drivers/net/bna/bfa_cs.h
@@ -11,20 +11,24 @@
11 * General Public License for more details. 11 * General Public License for more details.
12 */ 12 */
13/* 13/*
14 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. 14 * Copyright (c) 2005-2011 Brocade Communications Systems, Inc.
15 * All rights reserved 15 * All rights reserved
16 * www.brocade.com 16 * www.brocade.com
17 */ 17 */
18 18
19/** 19/**
20 * @file bfasm.h State machine defines 20 * @file bfa_cs.h BFA common services
21 */ 21 */
22 22
23#ifndef __BFA_SM_H__ 23#ifndef __BFA_CS_H__
24#define __BFA_SM_H__ 24#define __BFA_CS_H__
25 25
26#include "cna.h" 26#include "cna.h"
27 27
28/**
29 * @ BFA state machine interfaces
30 */
31
28typedef void (*bfa_sm_t)(void *sm, int event); 32typedef void (*bfa_sm_t)(void *sm, int event);
29 33
30/** 34/**
@@ -33,7 +37,7 @@ typedef void (*bfa_sm_t)(void *sm, int event);
33 * otype - object type, eg. struct bfa_ioc 37 * otype - object type, eg. struct bfa_ioc
34 * etype - object type, eg. enum ioc_event 38 * etype - object type, eg. enum ioc_event
35 */ 39 */
36#define bfa_sm_state_decl(oc, st, otype, etype) \ 40#define bfa_sm_state_decl(oc, st, otype, etype) \
37 static void oc ## _sm_ ## st(otype * fsm, etype event) 41 static void oc ## _sm_ ## st(otype * fsm, etype event)
38 42
39#define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (bfa_sm_t)(_state)) 43#define bfa_sm_set_state(_sm, _state) ((_sm)->sm = (bfa_sm_t)(_state))
@@ -49,7 +53,7 @@ struct bfa_sm_table {
49 int state; /*!< state machine encoding */ 53 int state; /*!< state machine encoding */
50 char *name; /*!< state name for display */ 54 char *name; /*!< state name for display */
51}; 55};
52#define BFA_SM(_sm) ((bfa_sm_t)(_sm)) 56#define BFA_SM(_sm) ((bfa_sm_t)(_sm))
53 57
54/** 58/**
55 * State machine with entry actions. 59 * State machine with entry actions.
@@ -62,18 +66,18 @@ typedef void (*bfa_fsm_t)(void *fsm, int event);
62 * otype - object type, eg. struct bfa_ioc 66 * otype - object type, eg. struct bfa_ioc
63 * etype - object type, eg. enum ioc_event 67 * etype - object type, eg. enum ioc_event
64 */ 68 */
65#define bfa_fsm_state_decl(oc, st, otype, etype) \ 69#define bfa_fsm_state_decl(oc, st, otype, etype) \
66 static void oc ## _sm_ ## st(otype * fsm, etype event); \ 70 static void oc ## _sm_ ## st(otype * fsm, etype event); \
67 static void oc ## _sm_ ## st ## _entry(otype * fsm) 71 static void oc ## _sm_ ## st ## _entry(otype * fsm)
68 72
69#define bfa_fsm_set_state(_fsm, _state) do { \ 73#define bfa_fsm_set_state(_fsm, _state) do { \
70 (_fsm)->fsm = (bfa_fsm_t)(_state); \ 74 (_fsm)->fsm = (bfa_fsm_t)(_state); \
71 _state ## _entry(_fsm); \ 75 _state ## _entry(_fsm); \
72} while (0) 76} while (0)
73 77
74#define bfa_fsm_send_event(_fsm, _event) ((_fsm)->fsm((_fsm), (_event))) 78#define bfa_fsm_send_event(_fsm, _event) ((_fsm)->fsm((_fsm), (_event)))
75#define bfa_fsm_get_state(_fsm) ((_fsm)->fsm) 79#define bfa_fsm_get_state(_fsm) ((_fsm)->fsm)
76#define bfa_fsm_cmp_state(_fsm, _state) \ 80#define bfa_fsm_cmp_state(_fsm, _state) \
77 ((_fsm)->fsm == (bfa_fsm_t)(_state)) 81 ((_fsm)->fsm == (bfa_fsm_t)(_state))
78 82
79static inline int 83static inline int
@@ -85,4 +89,52 @@ bfa_sm_to_state(const struct bfa_sm_table *smt, bfa_sm_t sm)
85 i++; 89 i++;
86 return smt[i].state; 90 return smt[i].state;
87} 91}
88#endif 92
93/**
94 * @ Generic wait counter.
95 */
96
97typedef void (*bfa_wc_resume_t) (void *cbarg);
98
99struct bfa_wc {
100 bfa_wc_resume_t wc_resume;
101 void *wc_cbarg;
102 int wc_count;
103};
104
105static inline void
106bfa_wc_up(struct bfa_wc *wc)
107{
108 wc->wc_count++;
109}
110
111static inline void
112bfa_wc_down(struct bfa_wc *wc)
113{
114 wc->wc_count--;
115 if (wc->wc_count == 0)
116 wc->wc_resume(wc->wc_cbarg);
117}
118
119/**
120 * Initialize a waiting counter.
121 */
122static inline void
123bfa_wc_init(struct bfa_wc *wc, bfa_wc_resume_t wc_resume, void *wc_cbarg)
124{
125 wc->wc_resume = wc_resume;
126 wc->wc_cbarg = wc_cbarg;
127 wc->wc_count = 0;
128 bfa_wc_up(wc);
129}
130
131/**
132 * Wait for counter to reach zero
133 */
134static inline void
135bfa_wc_wait(struct bfa_wc *wc)
136{
137 bfa_wc_down(wc);
138}
139
140#endif /* __BFA_CS_H__ */
diff --git a/drivers/net/bna/bfa_ioc.h b/drivers/net/bna/bfa_ioc.h
index 4b5dc987453f..bda866ba6e90 100644
--- a/drivers/net/bna/bfa_ioc.h
+++ b/drivers/net/bna/bfa_ioc.h
@@ -19,7 +19,7 @@
19#ifndef __BFA_IOC_H__ 19#ifndef __BFA_IOC_H__
20#define __BFA_IOC_H__ 20#define __BFA_IOC_H__
21 21
22#include "bfa_sm.h" 22#include "bfa_cs.h"
23#include "bfi.h" 23#include "bfi.h"
24#include "cna.h" 24#include "cna.h"
25 25
diff --git a/drivers/net/bna/bfa_wc.h b/drivers/net/bna/bfa_wc.h
deleted file mode 100644
index d0e4caee67b0..000000000000
--- a/drivers/net/bna/bfa_wc.h
+++ /dev/null
@@ -1,69 +0,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
diff --git a/drivers/net/bna/bna.h b/drivers/net/bna/bna.h
index 6b14c1d92871..21e9155d6e56 100644
--- a/drivers/net/bna/bna.h
+++ b/drivers/net/bna/bna.h
@@ -13,7 +13,7 @@
13#ifndef __BNA_H__ 13#ifndef __BNA_H__
14#define __BNA_H__ 14#define __BNA_H__
15 15
16#include "bfa_wc.h" 16#include "bfa_cs.h"
17#include "bfa_ioc.h" 17#include "bfa_ioc.h"
18#include "cna.h" 18#include "cna.h"
19#include "bfi_ll.h" 19#include "bfi_ll.h"
diff --git a/drivers/net/bna/bna_ctrl.c b/drivers/net/bna/bna_ctrl.c
index 7d9bc2ff3a45..cb2594c564dc 100644
--- a/drivers/net/bna/bna_ctrl.c
+++ b/drivers/net/bna/bna_ctrl.c
@@ -16,8 +16,7 @@
16 * www.brocade.com 16 * www.brocade.com
17 */ 17 */
18#include "bna.h" 18#include "bna.h"
19#include "bfa_sm.h" 19#include "bfa_cs.h"
20#include "bfa_wc.h"
21 20
22static void bna_device_cb_port_stopped(void *arg, enum bna_cb_status status); 21static void bna_device_cb_port_stopped(void *arg, enum bna_cb_status status);
23 22
diff --git a/drivers/net/bna/bna_txrx.c b/drivers/net/bna/bna_txrx.c
index 4d4f4d97a345..f0983c832447 100644
--- a/drivers/net/bna/bna_txrx.c
+++ b/drivers/net/bna/bna_txrx.c
@@ -16,7 +16,7 @@
16 * www.brocade.com 16 * www.brocade.com
17 */ 17 */
18#include "bna.h" 18#include "bna.h"
19#include "bfa_sm.h" 19#include "bfa_cs.h"
20#include "bfi.h" 20#include "bfi.h"
21 21
22/** 22/**