diff options
author | sjur.brandeland@stericsson.com <sjur.brandeland@stericsson.com> | 2011-05-12 22:44:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-05-15 17:45:55 -0400 |
commit | 43e3692101086add8719c3b8b50b05c9ac5b14e1 (patch) | |
tree | 736fc7d0792a492d9ef3a19ac8fff7ca800ced99 /net | |
parent | cb3cb423a0f3c627639535e5d87977ae662d779f (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 'net')
-rw-r--r-- | net/caif/cfrfml.c | 4 | ||||
-rw-r--r-- | net/caif/cfsrvl.c | 35 |
2 files changed, 31 insertions, 8 deletions
diff --git a/net/caif/cfrfml.c b/net/caif/cfrfml.c index e2fb5fa75795..0deabb440051 100644 --- a/net/caif/cfrfml.c +++ b/net/caif/cfrfml.c | |||
@@ -31,9 +31,9 @@ struct cfrfml { | |||
31 | spinlock_t sync; | 31 | spinlock_t sync; |
32 | }; | 32 | }; |
33 | 33 | ||
34 | static void cfrfml_release(struct kref *kref) | 34 | static void cfrfml_release(struct cflayer *layer) |
35 | { | 35 | { |
36 | struct cfsrvl *srvl = container_of(kref, struct cfsrvl, ref); | 36 | struct cfsrvl *srvl = container_of(layer, struct cfsrvl, layer); |
37 | struct cfrfml *rfml = container_obj(&srvl->layer); | 37 | struct cfrfml *rfml = container_obj(&srvl->layer); |
38 | 38 | ||
39 | if (rfml->incomplete_frm) | 39 | if (rfml->incomplete_frm) |
diff --git a/net/caif/cfsrvl.c b/net/caif/cfsrvl.c index 24ba392f203b..535a1e72b366 100644 --- a/net/caif/cfsrvl.c +++ b/net/caif/cfsrvl.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/types.h> | 10 | #include <linux/types.h> |
11 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
12 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/module.h> | ||
13 | #include <net/caif/caif_layer.h> | 14 | #include <net/caif/caif_layer.h> |
14 | #include <net/caif/cfsrvl.h> | 15 | #include <net/caif/cfsrvl.h> |
15 | #include <net/caif/cfpkt.h> | 16 | #include <net/caif/cfpkt.h> |
@@ -27,8 +28,8 @@ static void cfservl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, | |||
27 | { | 28 | { |
28 | struct cfsrvl *service = container_obj(layr); | 29 | struct cfsrvl *service = container_obj(layr); |
29 | 30 | ||
30 | caif_assert(layr->up != NULL); | 31 | if (layr->up == NULL || layr->up->ctrlcmd == NULL) |
31 | caif_assert(layr->up->ctrlcmd != NULL); | 32 | return; |
32 | 33 | ||
33 | switch (ctrl) { | 34 | switch (ctrl) { |
34 | case CAIF_CTRLCMD_INIT_RSP: | 35 | case CAIF_CTRLCMD_INIT_RSP: |
@@ -151,9 +152,9 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl) | |||
151 | return -EINVAL; | 152 | return -EINVAL; |
152 | } | 153 | } |
153 | 154 | ||
154 | static void cfsrvl_release(struct kref *kref) | 155 | static void cfsrvl_release(struct cflayer *layer) |
155 | { | 156 | { |
156 | struct cfsrvl *service = container_of(kref, struct cfsrvl, ref); | 157 | struct cfsrvl *service = container_of(layer, struct cfsrvl, layer); |
157 | kfree(service); | 158 | kfree(service); |
158 | } | 159 | } |
159 | 160 | ||
@@ -173,10 +174,8 @@ void cfsrvl_init(struct cfsrvl *service, | |||
173 | service->dev_info = *dev_info; | 174 | service->dev_info = *dev_info; |
174 | service->supports_flowctrl = supports_flowctrl; | 175 | service->supports_flowctrl = supports_flowctrl; |
175 | service->release = cfsrvl_release; | 176 | service->release = cfsrvl_release; |
176 | kref_init(&service->ref); | ||
177 | } | 177 | } |
178 | 178 | ||
179 | |||
180 | bool cfsrvl_ready(struct cfsrvl *service, int *err) | 179 | bool cfsrvl_ready(struct cfsrvl *service, int *err) |
181 | { | 180 | { |
182 | if (service->open && service->modem_flow_on && service->phy_flow_on) | 181 | if (service->open && service->modem_flow_on && service->phy_flow_on) |
@@ -189,6 +188,7 @@ bool cfsrvl_ready(struct cfsrvl *service, int *err) | |||
189 | *err = -EAGAIN; | 188 | *err = -EAGAIN; |
190 | return false; | 189 | return false; |
191 | } | 190 | } |
191 | |||
192 | u8 cfsrvl_getphyid(struct cflayer *layer) | 192 | u8 cfsrvl_getphyid(struct cflayer *layer) |
193 | { | 193 | { |
194 | struct cfsrvl *servl = container_obj(layer); | 194 | struct cfsrvl *servl = container_obj(layer); |
@@ -200,3 +200,26 @@ bool cfsrvl_phyid_match(struct cflayer *layer, int phyid) | |||
200 | struct cfsrvl *servl = container_obj(layer); | 200 | struct cfsrvl *servl = container_obj(layer); |
201 | return servl->dev_info.id == phyid; | 201 | return servl->dev_info.id == phyid; |
202 | } | 202 | } |
203 | |||
204 | void caif_free_client(struct cflayer *adap_layer) | ||
205 | { | ||
206 | struct cfsrvl *servl; | ||
207 | if (adap_layer == NULL || adap_layer->dn == NULL) | ||
208 | return; | ||
209 | servl = container_obj(adap_layer->dn); | ||
210 | servl->release(&servl->layer); | ||
211 | } | ||
212 | EXPORT_SYMBOL(caif_free_client); | ||
213 | |||
214 | void caif_client_register_refcnt(struct cflayer *adapt_layer, | ||
215 | void (*hold)(struct cflayer *lyr), | ||
216 | void (*put)(struct cflayer *lyr)) | ||
217 | { | ||
218 | struct cfsrvl *service; | ||
219 | service = container_of(adapt_layer->dn, struct cfsrvl, layer); | ||
220 | |||
221 | WARN_ON(adapt_layer == NULL || adapt_layer->dn == NULL); | ||
222 | service->hold = hold; | ||
223 | service->put = put; | ||
224 | } | ||
225 | EXPORT_SYMBOL(caif_client_register_refcnt); | ||