diff options
Diffstat (limited to 'include/net/caif/cfsrvl.h')
-rw-r--r-- | include/net/caif/cfsrvl.h | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/include/net/caif/cfsrvl.h b/include/net/caif/cfsrvl.h index b1fa87ee0992..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 | ||
14 | struct cfsrvl { | 15 | struct cfsrvl { |
15 | struct cflayer layer; | 16 | struct cflayer layer; |
@@ -17,12 +18,13 @@ 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 | ||
25 | void cfsrvl_release(struct kref *kref); | ||
26 | struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); | 28 | struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); |
27 | struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); | 29 | struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); |
28 | struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); | 30 | struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); |
@@ -30,8 +32,12 @@ struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info); | |||
30 | struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info, | 32 | struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info, |
31 | int mtu_size); | 33 | int mtu_size); |
32 | struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); | 34 | struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); |
35 | |||
36 | void cfsrvl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, | ||
37 | int phyid); | ||
38 | |||
33 | bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); | 39 | bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); |
34 | void cfservl_destroy(struct cflayer *layer); | 40 | |
35 | void cfsrvl_init(struct cfsrvl *service, | 41 | void cfsrvl_init(struct cfsrvl *service, |
36 | u8 channel_id, | 42 | u8 channel_id, |
37 | struct dev_info *dev_info, | 43 | struct dev_info *dev_info, |
@@ -41,23 +47,19 @@ u8 cfsrvl_getphyid(struct cflayer *layer); | |||
41 | 47 | ||
42 | static inline void cfsrvl_get(struct cflayer *layr) | 48 | static inline void cfsrvl_get(struct cflayer *layr) |
43 | { | 49 | { |
44 | struct cfsrvl *s; | 50 | struct cfsrvl *s = container_of(layr, struct cfsrvl, layer); |
45 | if (layr == NULL) | 51 | if (layr == NULL || layr->up == NULL || s->hold == NULL) |
46 | return; | 52 | return; |
47 | s = container_of(layr, struct cfsrvl, layer); | 53 | |
48 | kref_get(&s->ref); | 54 | s->hold(layr->up); |
49 | } | 55 | } |
50 | 56 | ||
51 | static inline void cfsrvl_put(struct cflayer *layr) | 57 | static inline void cfsrvl_put(struct cflayer *layr) |
52 | { | 58 | { |
53 | struct cfsrvl *s; | 59 | struct cfsrvl *s = container_of(layr, struct cfsrvl, layer); |
54 | if (layr == NULL) | 60 | if (layr == NULL || layr->up == NULL || s->hold == NULL) |
55 | return; | 61 | return; |
56 | s = container_of(layr, struct cfsrvl, layer); | ||
57 | 62 | ||
58 | WARN_ON(!s->release); | 63 | s->put(layr->up); |
59 | if (s->release) | ||
60 | kref_put(&s->ref, s->release); | ||
61 | } | 64 | } |
62 | |||
63 | #endif /* CFSRVL_H_ */ | 65 | #endif /* CFSRVL_H_ */ |