aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/caif/cfsrvl.h
diff options
context:
space:
mode:
authorsjur.brandeland@stericsson.com <sjur.brandeland@stericsson.com>2011-05-12 22:44:03 -0400
committerDavid S. Miller <davem@davemloft.net>2011-05-15 17:45:55 -0400
commit43e3692101086add8719c3b8b50b05c9ac5b14e1 (patch)
tree736fc7d0792a492d9ef3a19ac8fff7ca800ced99 /include/net/caif/cfsrvl.h
parentcb3cb423a0f3c627639535e5d87977ae662d779f (diff)
caif: Move refcount from service layer to sock and dev.
Instead of having reference counts in caif service layers, we hook into existing refcount handling in socket layer and netdevice. Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/caif/cfsrvl.h')
-rw-r--r--include/net/caif/cfsrvl.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/include/net/caif/cfsrvl.h b/include/net/caif/cfsrvl.h
index 6c8279c1ae9a..0f5905241843 100644
--- a/include/net/caif/cfsrvl.h
+++ b/include/net/caif/cfsrvl.h
@@ -10,6 +10,7 @@
10#include <linux/stddef.h> 10#include <linux/stddef.h>
11#include <linux/types.h> 11#include <linux/types.h>
12#include <linux/kref.h> 12#include <linux/kref.h>
13#include <linux/rculist.h>
13 14
14struct cfsrvl { 15struct cfsrvl {
15 struct cflayer layer; 16 struct cflayer layer;
@@ -17,9 +18,11 @@ struct cfsrvl {
17 bool phy_flow_on; 18 bool phy_flow_on;
18 bool modem_flow_on; 19 bool modem_flow_on;
19 bool supports_flowctrl; 20 bool supports_flowctrl;
20 void (*release)(struct kref *); 21 void (*release)(struct cflayer *layer);
21 struct dev_info dev_info; 22 struct dev_info dev_info;
22 struct kref ref; 23 void (*hold)(struct cflayer *lyr);
24 void (*put)(struct cflayer *lyr);
25 struct rcu_head rcu;
23}; 26};
24 27
25struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); 28struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info);
@@ -29,6 +32,10 @@ struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info);
29struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info, 32struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info,
30 int mtu_size); 33 int mtu_size);
31struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); 34struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info);
35
36void cfsrvl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
37 int phyid);
38
32bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); 39bool cfsrvl_phyid_match(struct cflayer *layer, int phyid);
33 40
34void cfsrvl_init(struct cfsrvl *service, 41void cfsrvl_init(struct cfsrvl *service,
@@ -40,23 +47,19 @@ u8 cfsrvl_getphyid(struct cflayer *layer);
40 47
41static inline void cfsrvl_get(struct cflayer *layr) 48static inline void cfsrvl_get(struct cflayer *layr)
42{ 49{
43 struct cfsrvl *s; 50 struct cfsrvl *s = container_of(layr, struct cfsrvl, layer);
44 if (layr == NULL) 51 if (layr == NULL || layr->up == NULL || s->hold == NULL)
45 return; 52 return;
46 s = container_of(layr, struct cfsrvl, layer); 53
47 kref_get(&s->ref); 54 s->hold(layr->up);
48} 55}
49 56
50static inline void cfsrvl_put(struct cflayer *layr) 57static inline void cfsrvl_put(struct cflayer *layr)
51{ 58{
52 struct cfsrvl *s; 59 struct cfsrvl *s = container_of(layr, struct cfsrvl, layer);
53 if (layr == NULL) 60 if (layr == NULL || layr->up == NULL || s->hold == NULL)
54 return; 61 return;
55 s = container_of(layr, struct cfsrvl, layer);
56 62
57 WARN_ON(!s->release); 63 s->put(layr->up);
58 if (s->release)
59 kref_put(&s->ref, s->release);
60} 64}
61
62#endif /* CFSRVL_H_ */ 65#endif /* CFSRVL_H_ */