diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2012-03-04 19:47:13 -0500 |
commit | c71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch) | |
tree | ecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /net/caif/cfsrvl.c | |
parent | ea53c912f8a86a8567697115b6a0d8152beee5c8 (diff) | |
parent | 6a00f206debf8a5c8899055726ad127dbeeed098 (diff) |
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts:
litmus/sched_cedf.c
Diffstat (limited to 'net/caif/cfsrvl.c')
-rw-r--r-- | net/caif/cfsrvl.c | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/net/caif/cfsrvl.c b/net/caif/cfsrvl.c index f40939a91211..535a1e72b366 100644 --- a/net/caif/cfsrvl.c +++ b/net/caif/cfsrvl.c | |||
@@ -4,10 +4,13 @@ | |||
4 | * License terms: GNU General Public License (GPL) version 2 | 4 | * License terms: GNU General Public License (GPL) version 2 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__ | ||
8 | |||
7 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
8 | #include <linux/types.h> | 10 | #include <linux/types.h> |
9 | #include <linux/errno.h> | 11 | #include <linux/errno.h> |
10 | #include <linux/slab.h> | 12 | #include <linux/slab.h> |
13 | #include <linux/module.h> | ||
11 | #include <net/caif/caif_layer.h> | 14 | #include <net/caif/caif_layer.h> |
12 | #include <net/caif/cfsrvl.h> | 15 | #include <net/caif/cfsrvl.h> |
13 | #include <net/caif/cfpkt.h> | 16 | #include <net/caif/cfpkt.h> |
@@ -25,8 +28,8 @@ static void cfservl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, | |||
25 | { | 28 | { |
26 | struct cfsrvl *service = container_obj(layr); | 29 | struct cfsrvl *service = container_obj(layr); |
27 | 30 | ||
28 | caif_assert(layr->up != NULL); | 31 | if (layr->up == NULL || layr->up->ctrlcmd == NULL) |
29 | caif_assert(layr->up->ctrlcmd != NULL); | 32 | return; |
30 | 33 | ||
31 | switch (ctrl) { | 34 | switch (ctrl) { |
32 | case CAIF_CTRLCMD_INIT_RSP: | 35 | case CAIF_CTRLCMD_INIT_RSP: |
@@ -79,8 +82,7 @@ static void cfservl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, | |||
79 | layr->up->ctrlcmd(layr->up, ctrl, phyid); | 82 | layr->up->ctrlcmd(layr->up, ctrl, phyid); |
80 | break; | 83 | break; |
81 | default: | 84 | default: |
82 | pr_warning("CAIF: %s(): " | 85 | pr_warn("Unexpected ctrl in cfsrvl (%d)\n", ctrl); |
83 | "Unexpected ctrl in cfsrvl (%d)\n", __func__, ctrl); | ||
84 | /* We have both modem and phy flow on, send flow on */ | 86 | /* We have both modem and phy flow on, send flow on */ |
85 | layr->up->ctrlcmd(layr->up, ctrl, phyid); | 87 | layr->up->ctrlcmd(layr->up, ctrl, phyid); |
86 | service->phy_flow_on = true; | 88 | service->phy_flow_on = true; |
@@ -107,14 +109,12 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl) | |||
107 | u8 flow_on = SRVL_FLOW_ON; | 109 | u8 flow_on = SRVL_FLOW_ON; |
108 | pkt = cfpkt_create(SRVL_CTRL_PKT_SIZE); | 110 | pkt = cfpkt_create(SRVL_CTRL_PKT_SIZE); |
109 | if (!pkt) { | 111 | if (!pkt) { |
110 | pr_warning("CAIF: %s(): Out of memory\n", | 112 | pr_warn("Out of memory\n"); |
111 | __func__); | ||
112 | return -ENOMEM; | 113 | return -ENOMEM; |
113 | } | 114 | } |
114 | 115 | ||
115 | if (cfpkt_add_head(pkt, &flow_on, 1) < 0) { | 116 | if (cfpkt_add_head(pkt, &flow_on, 1) < 0) { |
116 | pr_err("CAIF: %s(): Packet is erroneous!\n", | 117 | pr_err("Packet is erroneous!\n"); |
117 | __func__); | ||
118 | cfpkt_destroy(pkt); | 118 | cfpkt_destroy(pkt); |
119 | return -EPROTO; | 119 | return -EPROTO; |
120 | } | 120 | } |
@@ -131,14 +131,12 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl) | |||
131 | u8 flow_off = SRVL_FLOW_OFF; | 131 | u8 flow_off = SRVL_FLOW_OFF; |
132 | pkt = cfpkt_create(SRVL_CTRL_PKT_SIZE); | 132 | pkt = cfpkt_create(SRVL_CTRL_PKT_SIZE); |
133 | if (!pkt) { | 133 | if (!pkt) { |
134 | pr_warning("CAIF: %s(): Out of memory\n", | 134 | pr_warn("Out of memory\n"); |
135 | __func__); | ||
136 | return -ENOMEM; | 135 | return -ENOMEM; |
137 | } | 136 | } |
138 | 137 | ||
139 | if (cfpkt_add_head(pkt, &flow_off, 1) < 0) { | 138 | if (cfpkt_add_head(pkt, &flow_off, 1) < 0) { |
140 | pr_err("CAIF: %s(): Packet is erroneous!\n", | 139 | pr_err("Packet is erroneous!\n"); |
141 | __func__); | ||
142 | cfpkt_destroy(pkt); | 140 | cfpkt_destroy(pkt); |
143 | return -EPROTO; | 141 | return -EPROTO; |
144 | } | 142 | } |
@@ -154,14 +152,9 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl) | |||
154 | return -EINVAL; | 152 | return -EINVAL; |
155 | } | 153 | } |
156 | 154 | ||
157 | void cfservl_destroy(struct cflayer *layer) | 155 | static void cfsrvl_release(struct cflayer *layer) |
158 | { | ||
159 | kfree(layer); | ||
160 | } | ||
161 | |||
162 | void cfsrvl_release(struct kref *kref) | ||
163 | { | 156 | { |
164 | struct cfsrvl *service = container_of(kref, struct cfsrvl, ref); | 157 | struct cfsrvl *service = container_of(layer, struct cfsrvl, layer); |
165 | kfree(service); | 158 | kfree(service); |
166 | } | 159 | } |
167 | 160 | ||
@@ -181,10 +174,8 @@ void cfsrvl_init(struct cfsrvl *service, | |||
181 | service->dev_info = *dev_info; | 174 | service->dev_info = *dev_info; |
182 | service->supports_flowctrl = supports_flowctrl; | 175 | service->supports_flowctrl = supports_flowctrl; |
183 | service->release = cfsrvl_release; | 176 | service->release = cfsrvl_release; |
184 | kref_init(&service->ref); | ||
185 | } | 177 | } |
186 | 178 | ||
187 | |||
188 | bool cfsrvl_ready(struct cfsrvl *service, int *err) | 179 | bool cfsrvl_ready(struct cfsrvl *service, int *err) |
189 | { | 180 | { |
190 | if (service->open && service->modem_flow_on && service->phy_flow_on) | 181 | if (service->open && service->modem_flow_on && service->phy_flow_on) |
@@ -197,6 +188,7 @@ bool cfsrvl_ready(struct cfsrvl *service, int *err) | |||
197 | *err = -EAGAIN; | 188 | *err = -EAGAIN; |
198 | return false; | 189 | return false; |
199 | } | 190 | } |
191 | |||
200 | u8 cfsrvl_getphyid(struct cflayer *layer) | 192 | u8 cfsrvl_getphyid(struct cflayer *layer) |
201 | { | 193 | { |
202 | struct cfsrvl *servl = container_obj(layer); | 194 | struct cfsrvl *servl = container_obj(layer); |
@@ -208,3 +200,26 @@ bool cfsrvl_phyid_match(struct cflayer *layer, int phyid) | |||
208 | struct cfsrvl *servl = container_obj(layer); | 200 | struct cfsrvl *servl = container_obj(layer); |
209 | return servl->dev_info.id == phyid; | 201 | return servl->dev_info.id == phyid; |
210 | } | 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); | ||