diff options
author | Stephen Hemminger <shemminger@vyatta.com> | 2011-04-11 06:43:50 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-04-11 18:08:47 -0400 |
commit | 73d6ac633c6c0ca703f90db0b808d9593e46aef6 (patch) | |
tree | 738fb16f97e24288f9db9c6b43b4bcee4f794dc6 | |
parent | 1c01a80cfec6f806246f31ff2680cd3639b30e67 (diff) |
caif: code cleanup
Cleanup of new CAIF code.
* make local functions static
* remove code that is never used
* expand get_caif_conf() since wrapper is no longer needed
* make args to comparison functions const
* rename connect_req_to_link_param to keep exported names
consistent
Compile tested only.
Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Acked-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/caif/caif_dev.h | 27 | ||||
-rw-r--r-- | include/net/caif/cfctrl.h | 12 | ||||
-rw-r--r-- | include/net/caif/cfmuxl.h | 2 | ||||
-rw-r--r-- | include/net/caif/cfpkt.h | 75 | ||||
-rw-r--r-- | include/net/caif/cfsrvl.h | 3 | ||||
-rw-r--r-- | net/caif/caif_config_util.c | 6 | ||||
-rw-r--r-- | net/caif/caif_dev.c | 24 | ||||
-rw-r--r-- | net/caif/cfcnfg.c | 2 | ||||
-rw-r--r-- | net/caif/cfctrl.c | 75 | ||||
-rw-r--r-- | net/caif/cfmuxl.c | 35 | ||||
-rw-r--r-- | net/caif/cfpkt_skbuff.c | 178 | ||||
-rw-r--r-- | net/caif/cfsrvl.c | 7 |
12 files changed, 30 insertions, 416 deletions
diff --git a/include/net/caif/caif_dev.h b/include/net/caif/caif_dev.h index 8eff83b95366..7e3f7a6d2ba3 100644 --- a/include/net/caif/caif_dev.h +++ b/include/net/caif/caif_dev.h | |||
@@ -74,19 +74,8 @@ int caif_connect_client(struct caif_connect_request *conn_req, | |||
74 | int caif_disconnect_client(struct cflayer *client_layer); | 74 | int caif_disconnect_client(struct cflayer *client_layer); |
75 | 75 | ||
76 | /** | 76 | /** |
77 | * caif_release_client - Release adaptation layer reference to client. | 77 | * caif_connect_req_to_link_param - Translate configuration parameters |
78 | * | 78 | * from socket format to internal format. |
79 | * @client_layer: Client layer. | ||
80 | * | ||
81 | * Releases a client/adaptation layer use of the caif stack. | ||
82 | * This function must be used after caif_disconnect_client to | ||
83 | * decrease the reference count of the service layer. | ||
84 | */ | ||
85 | void caif_release_client(struct cflayer *client_layer); | ||
86 | |||
87 | /** | ||
88 | * connect_req_to_link_param - Translate configuration parameters | ||
89 | * from socket format to internal format. | ||
90 | * @cnfg: Pointer to configuration handler | 79 | * @cnfg: Pointer to configuration handler |
91 | * @con_req: Configuration parameters supplied in function | 80 | * @con_req: Configuration parameters supplied in function |
92 | * caif_connect_client | 81 | * caif_connect_client |
@@ -94,14 +83,8 @@ void caif_release_client(struct cflayer *client_layer); | |||
94 | * setting up channels. | 83 | * setting up channels. |
95 | * | 84 | * |
96 | */ | 85 | */ |
97 | int connect_req_to_link_param(struct cfcnfg *cnfg, | 86 | int caif_connect_req_to_link_param(struct cfcnfg *cnfg, |
98 | struct caif_connect_request *con_req, | 87 | struct caif_connect_request *con_req, |
99 | struct cfctrl_link_param *channel_setup_param); | 88 | struct cfctrl_link_param *setup_param); |
100 | |||
101 | /** | ||
102 | * get_caif_conf() - Get the configuration handler. | ||
103 | */ | ||
104 | struct cfcnfg *get_caif_conf(void); | ||
105 | |||
106 | 89 | ||
107 | #endif /* CAIF_DEV_H_ */ | 90 | #endif /* CAIF_DEV_H_ */ |
diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h index e54f6396fa4c..d84416fa175a 100644 --- a/include/net/caif/cfctrl.h +++ b/include/net/caif/cfctrl.h | |||
@@ -121,19 +121,9 @@ int cfctrl_linkup_request(struct cflayer *cfctrl, | |||
121 | struct cflayer *user_layer); | 121 | struct cflayer *user_layer); |
122 | int cfctrl_linkdown_req(struct cflayer *cfctrl, u8 linkid, | 122 | int cfctrl_linkdown_req(struct cflayer *cfctrl, u8 linkid, |
123 | struct cflayer *client); | 123 | struct cflayer *client); |
124 | void cfctrl_sleep_req(struct cflayer *cfctrl); | 124 | |
125 | void cfctrl_wake_req(struct cflayer *cfctrl); | ||
126 | void cfctrl_getstartreason_req(struct cflayer *cfctrl); | ||
127 | struct cflayer *cfctrl_create(void); | 125 | struct cflayer *cfctrl_create(void); |
128 | void cfctrl_set_dnlayer(struct cflayer *this, struct cflayer *dn); | ||
129 | void cfctrl_set_uplayer(struct cflayer *this, struct cflayer *up); | ||
130 | struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer); | 126 | struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer); |
131 | bool cfctrl_req_eq(struct cfctrl_request_info *r1, | ||
132 | struct cfctrl_request_info *r2); | ||
133 | void cfctrl_insert_req(struct cfctrl *ctrl, | ||
134 | struct cfctrl_request_info *req); | ||
135 | struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl, | ||
136 | struct cfctrl_request_info *req); | ||
137 | void cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer); | 127 | void cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer); |
138 | 128 | ||
139 | #endif /* CFCTRL_H_ */ | 129 | #endif /* CFCTRL_H_ */ |
diff --git a/include/net/caif/cfmuxl.h b/include/net/caif/cfmuxl.h index 4e1b4f33423e..5847a196b8ad 100644 --- a/include/net/caif/cfmuxl.h +++ b/include/net/caif/cfmuxl.h | |||
@@ -16,7 +16,5 @@ int cfmuxl_set_uplayer(struct cflayer *layr, struct cflayer *up, u8 linkid); | |||
16 | struct cflayer *cfmuxl_remove_dnlayer(struct cflayer *layr, u8 phyid); | 16 | struct cflayer *cfmuxl_remove_dnlayer(struct cflayer *layr, u8 phyid); |
17 | int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *up, u8 phyid); | 17 | int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *up, u8 phyid); |
18 | struct cflayer *cfmuxl_remove_uplayer(struct cflayer *layr, u8 linkid); | 18 | struct cflayer *cfmuxl_remove_uplayer(struct cflayer *layr, u8 linkid); |
19 | bool cfmuxl_is_phy_inuse(struct cflayer *layr, u8 phyid); | ||
20 | u8 cfmuxl_get_phyid(struct cflayer *layr, u8 channel_id); | ||
21 | 19 | ||
22 | #endif /* CFMUXL_H_ */ | 20 | #endif /* CFMUXL_H_ */ |
diff --git a/include/net/caif/cfpkt.h b/include/net/caif/cfpkt.h index fbc681beff52..8b550f8950d7 100644 --- a/include/net/caif/cfpkt.h +++ b/include/net/caif/cfpkt.h | |||
@@ -16,12 +16,6 @@ struct cfpkt; | |||
16 | */ | 16 | */ |
17 | struct cfpkt *cfpkt_create(u16 len); | 17 | struct cfpkt *cfpkt_create(u16 len); |
18 | 18 | ||
19 | /* Create a CAIF packet. | ||
20 | * data Data to copy. | ||
21 | * len Length of packet to be created | ||
22 | * @return New packet. | ||
23 | */ | ||
24 | struct cfpkt *cfpkt_create_uplink(const unsigned char *data, unsigned int len); | ||
25 | /* | 19 | /* |
26 | * Destroy a CAIF Packet. | 20 | * Destroy a CAIF Packet. |
27 | * pkt Packet to be destoyed. | 21 | * pkt Packet to be destoyed. |
@@ -181,22 +175,6 @@ u16 cfpkt_iterate(struct cfpkt *pkt, | |||
181 | u16 (*iter_func)(u16 chks, void *buf, u16 len), | 175 | u16 (*iter_func)(u16 chks, void *buf, u16 len), |
182 | u16 data); | 176 | u16 data); |
183 | 177 | ||
184 | /* Append by giving user access to packet buffer | ||
185 | * cfpkt Packet to append to | ||
186 | * buf Buffer inside pkt that user shall copy data into | ||
187 | * buflen Length of buffer and number of bytes added to packet | ||
188 | * @return 0 on error, 1 on success | ||
189 | */ | ||
190 | int cfpkt_raw_append(struct cfpkt *cfpkt, void **buf, unsigned int buflen); | ||
191 | |||
192 | /* Extract by giving user access to packet buffer | ||
193 | * cfpkt Packet to extract from | ||
194 | * buf Buffer inside pkt that user shall copy data from | ||
195 | * buflen Length of buffer and number of bytes removed from packet | ||
196 | * @return 0 on error, 1 on success | ||
197 | */ | ||
198 | int cfpkt_raw_extract(struct cfpkt *cfpkt, void **buf, unsigned int buflen); | ||
199 | |||
200 | /* Map from a "native" packet (e.g. Linux Socket Buffer) to a CAIF packet. | 178 | /* Map from a "native" packet (e.g. Linux Socket Buffer) to a CAIF packet. |
201 | * dir - Direction indicating whether this packet is to be sent or received. | 179 | * dir - Direction indicating whether this packet is to be sent or received. |
202 | * nativepkt - The native packet to be transformed to a CAIF packet | 180 | * nativepkt - The native packet to be transformed to a CAIF packet |
@@ -210,59 +188,6 @@ struct cfpkt *cfpkt_fromnative(enum caif_direction dir, void *nativepkt); | |||
210 | */ | 188 | */ |
211 | void *cfpkt_tonative(struct cfpkt *pkt); | 189 | void *cfpkt_tonative(struct cfpkt *pkt); |
212 | 190 | ||
213 | /* | ||
214 | * Insert a packet in the packet queue. | ||
215 | * pktq Packet queue to insert into | ||
216 | * pkt Packet to be inserted in queue | ||
217 | * prio Priority of packet | ||
218 | */ | ||
219 | void cfpkt_queue(struct cfpktq *pktq, struct cfpkt *pkt, | ||
220 | unsigned short prio); | ||
221 | |||
222 | /* | ||
223 | * Remove a packet from the packet queue. | ||
224 | * pktq Packet queue to fetch packets from. | ||
225 | * @return Dequeued packet. | ||
226 | */ | ||
227 | struct cfpkt *cfpkt_dequeue(struct cfpktq *pktq); | ||
228 | |||
229 | /* | ||
230 | * Peek into a packet from the packet queue. | ||
231 | * pktq Packet queue to fetch packets from. | ||
232 | * @return Peeked packet. | ||
233 | */ | ||
234 | struct cfpkt *cfpkt_qpeek(struct cfpktq *pktq); | ||
235 | |||
236 | /* | ||
237 | * Initiates the packet queue. | ||
238 | * @return Pointer to new packet queue. | ||
239 | */ | ||
240 | struct cfpktq *cfpktq_create(void); | ||
241 | |||
242 | /* | ||
243 | * Get the number of packets in the queue. | ||
244 | * pktq Packet queue to fetch count from. | ||
245 | * @return Number of packets in queue. | ||
246 | */ | ||
247 | int cfpkt_qcount(struct cfpktq *pktq); | ||
248 | |||
249 | /* | ||
250 | * Put content of packet into buffer for debuging purposes. | ||
251 | * pkt Packet to copy data from | ||
252 | * buf Buffer to copy data into | ||
253 | * buflen Length of data to copy | ||
254 | * @return Pointer to copied data | ||
255 | */ | ||
256 | char *cfpkt_log_pkt(struct cfpkt *pkt, char *buf, int buflen); | ||
257 | |||
258 | /* | ||
259 | * Clones a packet and releases the original packet. | ||
260 | * This is used for taking ownership of a packet e.g queueing. | ||
261 | * pkt Packet to clone and release. | ||
262 | * @return Cloned packet. | ||
263 | */ | ||
264 | struct cfpkt *cfpkt_clone_release(struct cfpkt *pkt); | ||
265 | |||
266 | 191 | ||
267 | /* | 192 | /* |
268 | * Returns packet information for a packet. | 193 | * Returns packet information for a packet. |
diff --git a/include/net/caif/cfsrvl.h b/include/net/caif/cfsrvl.h index b1fa87ee0992..6c8279c1ae9a 100644 --- a/include/net/caif/cfsrvl.h +++ b/include/net/caif/cfsrvl.h | |||
@@ -22,7 +22,6 @@ struct cfsrvl { | |||
22 | struct kref ref; | 22 | struct kref ref; |
23 | }; | 23 | }; |
24 | 24 | ||
25 | void cfsrvl_release(struct kref *kref); | ||
26 | struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); | 25 | struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); |
27 | struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); | 26 | struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); |
28 | struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); | 27 | struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); |
@@ -31,7 +30,7 @@ struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info, | |||
31 | int mtu_size); | 30 | int mtu_size); |
32 | struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); | 31 | struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); |
33 | bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); | 32 | bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); |
34 | void cfservl_destroy(struct cflayer *layer); | 33 | |
35 | void cfsrvl_init(struct cfsrvl *service, | 34 | void cfsrvl_init(struct cfsrvl *service, |
36 | u8 channel_id, | 35 | u8 channel_id, |
37 | struct dev_info *dev_info, | 36 | struct dev_info *dev_info, |
diff --git a/net/caif/caif_config_util.c b/net/caif/caif_config_util.c index d522d8c1703e..9b63e4e3910e 100644 --- a/net/caif/caif_config_util.c +++ b/net/caif/caif_config_util.c | |||
@@ -10,9 +10,9 @@ | |||
10 | #include <net/caif/cfcnfg.h> | 10 | #include <net/caif/cfcnfg.h> |
11 | #include <net/caif/caif_dev.h> | 11 | #include <net/caif/caif_dev.h> |
12 | 12 | ||
13 | int connect_req_to_link_param(struct cfcnfg *cnfg, | 13 | int caif_connect_req_to_link_param(struct cfcnfg *cnfg, |
14 | struct caif_connect_request *s, | 14 | struct caif_connect_request *s, |
15 | struct cfctrl_link_param *l) | 15 | struct cfctrl_link_param *l) |
16 | { | 16 | { |
17 | struct dev_info *dev_info; | 17 | struct dev_info *dev_info; |
18 | enum cfcnfg_phy_preference pref; | 18 | enum cfcnfg_phy_preference pref; |
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c index a42a408306e4..b533bb09a002 100644 --- a/net/caif/caif_dev.c +++ b/net/caif/caif_dev.c | |||
@@ -257,7 +257,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what, | |||
257 | break; | 257 | break; |
258 | } | 258 | } |
259 | dev_hold(dev); | 259 | dev_hold(dev); |
260 | cfcnfg_add_phy_layer(get_caif_conf(), | 260 | cfcnfg_add_phy_layer(cfg, |
261 | phy_type, | 261 | phy_type, |
262 | dev, | 262 | dev, |
263 | &caifd->layer, | 263 | &caifd->layer, |
@@ -300,7 +300,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what, | |||
300 | if (atomic_read(&caifd->in_use)) | 300 | if (atomic_read(&caifd->in_use)) |
301 | netdev_warn(dev, | 301 | netdev_warn(dev, |
302 | "Unregistering an active CAIF device\n"); | 302 | "Unregistering an active CAIF device\n"); |
303 | cfcnfg_del_phy_layer(get_caif_conf(), &caifd->layer); | 303 | cfcnfg_del_phy_layer(cfg, &caifd->layer); |
304 | dev_put(dev); | 304 | dev_put(dev); |
305 | atomic_set(&caifd->state, what); | 305 | atomic_set(&caifd->state, what); |
306 | break; | 306 | break; |
@@ -322,24 +322,18 @@ static struct notifier_block caif_device_notifier = { | |||
322 | .priority = 0, | 322 | .priority = 0, |
323 | }; | 323 | }; |
324 | 324 | ||
325 | |||
326 | struct cfcnfg *get_caif_conf(void) | ||
327 | { | ||
328 | return cfg; | ||
329 | } | ||
330 | EXPORT_SYMBOL(get_caif_conf); | ||
331 | |||
332 | int caif_connect_client(struct caif_connect_request *conn_req, | 325 | int caif_connect_client(struct caif_connect_request *conn_req, |
333 | struct cflayer *client_layer, int *ifindex, | 326 | struct cflayer *client_layer, int *ifindex, |
334 | int *headroom, int *tailroom) | 327 | int *headroom, int *tailroom) |
335 | { | 328 | { |
336 | struct cfctrl_link_param param; | 329 | struct cfctrl_link_param param; |
337 | int ret; | 330 | int ret; |
338 | ret = connect_req_to_link_param(get_caif_conf(), conn_req, ¶m); | 331 | |
332 | ret = caif_connect_req_to_link_param(cfg, conn_req, ¶m); | ||
339 | if (ret) | 333 | if (ret) |
340 | return ret; | 334 | return ret; |
341 | /* Hook up the adaptation layer. */ | 335 | /* Hook up the adaptation layer. */ |
342 | return cfcnfg_add_adaptation_layer(get_caif_conf(), ¶m, | 336 | return cfcnfg_add_adaptation_layer(cfg, ¶m, |
343 | client_layer, ifindex, | 337 | client_layer, ifindex, |
344 | headroom, tailroom); | 338 | headroom, tailroom); |
345 | } | 339 | } |
@@ -347,16 +341,10 @@ EXPORT_SYMBOL(caif_connect_client); | |||
347 | 341 | ||
348 | int caif_disconnect_client(struct cflayer *adap_layer) | 342 | int caif_disconnect_client(struct cflayer *adap_layer) |
349 | { | 343 | { |
350 | return cfcnfg_disconn_adapt_layer(get_caif_conf(), adap_layer); | 344 | return cfcnfg_disconn_adapt_layer(cfg, adap_layer); |
351 | } | 345 | } |
352 | EXPORT_SYMBOL(caif_disconnect_client); | 346 | EXPORT_SYMBOL(caif_disconnect_client); |
353 | 347 | ||
354 | void caif_release_client(struct cflayer *adap_layer) | ||
355 | { | ||
356 | cfcnfg_release_adap_layer(adap_layer); | ||
357 | } | ||
358 | EXPORT_SYMBOL(caif_release_client); | ||
359 | |||
360 | /* Per-namespace Caif devices handling */ | 348 | /* Per-namespace Caif devices handling */ |
361 | static int caif_init_net(struct net *net) | 349 | static int caif_init_net(struct net *net) |
362 | { | 350 | { |
diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c index f1f98d967d8a..25c0b198e285 100644 --- a/net/caif/cfcnfg.c +++ b/net/caif/cfcnfg.c | |||
@@ -253,7 +253,7 @@ static void cfcnfg_linkdestroy_rsp(struct cflayer *layer, u8 channel_id) | |||
253 | { | 253 | { |
254 | } | 254 | } |
255 | 255 | ||
256 | int protohead[CFCTRL_SRV_MASK] = { | 256 | static const int protohead[CFCTRL_SRV_MASK] = { |
257 | [CFCTRL_SRV_VEI] = 4, | 257 | [CFCTRL_SRV_VEI] = 4, |
258 | [CFCTRL_SRV_DATAGRAM] = 7, | 258 | [CFCTRL_SRV_DATAGRAM] = 7, |
259 | [CFCTRL_SRV_UTIL] = 4, | 259 | [CFCTRL_SRV_UTIL] = 4, |
diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c index 3cd8f978e309..397a2c099e2c 100644 --- a/net/caif/cfctrl.c +++ b/net/caif/cfctrl.c | |||
@@ -58,7 +58,8 @@ struct cflayer *cfctrl_create(void) | |||
58 | return &this->serv.layer; | 58 | return &this->serv.layer; |
59 | } | 59 | } |
60 | 60 | ||
61 | static bool param_eq(struct cfctrl_link_param *p1, struct cfctrl_link_param *p2) | 61 | static bool param_eq(const struct cfctrl_link_param *p1, |
62 | const struct cfctrl_link_param *p2) | ||
62 | { | 63 | { |
63 | bool eq = | 64 | bool eq = |
64 | p1->linktype == p2->linktype && | 65 | p1->linktype == p2->linktype && |
@@ -100,8 +101,8 @@ static bool param_eq(struct cfctrl_link_param *p1, struct cfctrl_link_param *p2) | |||
100 | return false; | 101 | return false; |
101 | } | 102 | } |
102 | 103 | ||
103 | bool cfctrl_req_eq(struct cfctrl_request_info *r1, | 104 | static bool cfctrl_req_eq(const struct cfctrl_request_info *r1, |
104 | struct cfctrl_request_info *r2) | 105 | const struct cfctrl_request_info *r2) |
105 | { | 106 | { |
106 | if (r1->cmd != r2->cmd) | 107 | if (r1->cmd != r2->cmd) |
107 | return false; | 108 | return false; |
@@ -112,7 +113,7 @@ bool cfctrl_req_eq(struct cfctrl_request_info *r1, | |||
112 | } | 113 | } |
113 | 114 | ||
114 | /* Insert request at the end */ | 115 | /* Insert request at the end */ |
115 | void cfctrl_insert_req(struct cfctrl *ctrl, | 116 | static void cfctrl_insert_req(struct cfctrl *ctrl, |
116 | struct cfctrl_request_info *req) | 117 | struct cfctrl_request_info *req) |
117 | { | 118 | { |
118 | spin_lock(&ctrl->info_list_lock); | 119 | spin_lock(&ctrl->info_list_lock); |
@@ -123,8 +124,8 @@ void cfctrl_insert_req(struct cfctrl *ctrl, | |||
123 | } | 124 | } |
124 | 125 | ||
125 | /* Compare and remove request */ | 126 | /* Compare and remove request */ |
126 | struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl, | 127 | static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl, |
127 | struct cfctrl_request_info *req) | 128 | struct cfctrl_request_info *req) |
128 | { | 129 | { |
129 | struct cfctrl_request_info *p, *tmp, *first; | 130 | struct cfctrl_request_info *p, *tmp, *first; |
130 | 131 | ||
@@ -154,16 +155,6 @@ struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer) | |||
154 | return &this->res; | 155 | return &this->res; |
155 | } | 156 | } |
156 | 157 | ||
157 | void cfctrl_set_dnlayer(struct cflayer *this, struct cflayer *dn) | ||
158 | { | ||
159 | this->dn = dn; | ||
160 | } | ||
161 | |||
162 | void cfctrl_set_uplayer(struct cflayer *this, struct cflayer *up) | ||
163 | { | ||
164 | this->up = up; | ||
165 | } | ||
166 | |||
167 | static void init_info(struct caif_payload_info *info, struct cfctrl *cfctrl) | 158 | static void init_info(struct caif_payload_info *info, struct cfctrl *cfctrl) |
168 | { | 159 | { |
169 | info->hdr_len = 0; | 160 | info->hdr_len = 0; |
@@ -304,58 +295,6 @@ int cfctrl_linkdown_req(struct cflayer *layer, u8 channelid, | |||
304 | return ret; | 295 | return ret; |
305 | } | 296 | } |
306 | 297 | ||
307 | void cfctrl_sleep_req(struct cflayer *layer) | ||
308 | { | ||
309 | int ret; | ||
310 | struct cfctrl *cfctrl = container_obj(layer); | ||
311 | struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); | ||
312 | if (!pkt) { | ||
313 | pr_warn("Out of memory\n"); | ||
314 | return; | ||
315 | } | ||
316 | cfpkt_addbdy(pkt, CFCTRL_CMD_SLEEP); | ||
317 | init_info(cfpkt_info(pkt), cfctrl); | ||
318 | ret = | ||
319 | cfctrl->serv.layer.dn->transmit(cfctrl->serv.layer.dn, pkt); | ||
320 | if (ret < 0) | ||
321 | cfpkt_destroy(pkt); | ||
322 | } | ||
323 | |||
324 | void cfctrl_wake_req(struct cflayer *layer) | ||
325 | { | ||
326 | int ret; | ||
327 | struct cfctrl *cfctrl = container_obj(layer); | ||
328 | struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); | ||
329 | if (!pkt) { | ||
330 | pr_warn("Out of memory\n"); | ||
331 | return; | ||
332 | } | ||
333 | cfpkt_addbdy(pkt, CFCTRL_CMD_WAKE); | ||
334 | init_info(cfpkt_info(pkt), cfctrl); | ||
335 | ret = | ||
336 | cfctrl->serv.layer.dn->transmit(cfctrl->serv.layer.dn, pkt); | ||
337 | if (ret < 0) | ||
338 | cfpkt_destroy(pkt); | ||
339 | } | ||
340 | |||
341 | void cfctrl_getstartreason_req(struct cflayer *layer) | ||
342 | { | ||
343 | int ret; | ||
344 | struct cfctrl *cfctrl = container_obj(layer); | ||
345 | struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); | ||
346 | if (!pkt) { | ||
347 | pr_warn("Out of memory\n"); | ||
348 | return; | ||
349 | } | ||
350 | cfpkt_addbdy(pkt, CFCTRL_CMD_START_REASON); | ||
351 | init_info(cfpkt_info(pkt), cfctrl); | ||
352 | ret = | ||
353 | cfctrl->serv.layer.dn->transmit(cfctrl->serv.layer.dn, pkt); | ||
354 | if (ret < 0) | ||
355 | cfpkt_destroy(pkt); | ||
356 | } | ||
357 | |||
358 | |||
359 | void cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer) | 298 | void cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer) |
360 | { | 299 | { |
361 | struct cfctrl_request_info *p, *tmp; | 300 | struct cfctrl_request_info *p, *tmp; |
diff --git a/net/caif/cfmuxl.c b/net/caif/cfmuxl.c index 24f1ffa74b06..f8ce0f3d9210 100644 --- a/net/caif/cfmuxl.c +++ b/net/caif/cfmuxl.c | |||
@@ -71,41 +71,6 @@ int cfmuxl_set_uplayer(struct cflayer *layr, struct cflayer *up, u8 linkid) | |||
71 | return 0; | 71 | return 0; |
72 | } | 72 | } |
73 | 73 | ||
74 | bool cfmuxl_is_phy_inuse(struct cflayer *layr, u8 phyid) | ||
75 | { | ||
76 | struct list_head *node; | ||
77 | struct cflayer *layer; | ||
78 | struct cfmuxl *muxl = container_obj(layr); | ||
79 | bool match = false; | ||
80 | spin_lock(&muxl->receive_lock); | ||
81 | |||
82 | list_for_each(node, &muxl->srvl_list) { | ||
83 | layer = list_entry(node, struct cflayer, node); | ||
84 | if (cfsrvl_phyid_match(layer, phyid)) { | ||
85 | match = true; | ||
86 | break; | ||
87 | } | ||
88 | |||
89 | } | ||
90 | spin_unlock(&muxl->receive_lock); | ||
91 | return match; | ||
92 | } | ||
93 | |||
94 | u8 cfmuxl_get_phyid(struct cflayer *layr, u8 channel_id) | ||
95 | { | ||
96 | struct cflayer *up; | ||
97 | int phyid; | ||
98 | struct cfmuxl *muxl = container_obj(layr); | ||
99 | spin_lock(&muxl->receive_lock); | ||
100 | up = get_up(muxl, channel_id); | ||
101 | if (up != NULL) | ||
102 | phyid = cfsrvl_getphyid(up); | ||
103 | else | ||
104 | phyid = 0; | ||
105 | spin_unlock(&muxl->receive_lock); | ||
106 | return phyid; | ||
107 | } | ||
108 | |||
109 | int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *dn, u8 phyid) | 74 | int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *dn, u8 phyid) |
110 | { | 75 | { |
111 | struct cfmuxl *muxl = (struct cfmuxl *) layr; | 76 | struct cfmuxl *muxl = (struct cfmuxl *) layr; |
diff --git a/net/caif/cfpkt_skbuff.c b/net/caif/cfpkt_skbuff.c index d7e865e2ff65..20c6cb3522e0 100644 --- a/net/caif/cfpkt_skbuff.c +++ b/net/caif/cfpkt_skbuff.c | |||
@@ -42,22 +42,22 @@ struct cfpkt_priv_data { | |||
42 | bool erronous; | 42 | bool erronous; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | inline struct cfpkt_priv_data *cfpkt_priv(struct cfpkt *pkt) | 45 | static inline struct cfpkt_priv_data *cfpkt_priv(struct cfpkt *pkt) |
46 | { | 46 | { |
47 | return (struct cfpkt_priv_data *) pkt->skb.cb; | 47 | return (struct cfpkt_priv_data *) pkt->skb.cb; |
48 | } | 48 | } |
49 | 49 | ||
50 | inline bool is_erronous(struct cfpkt *pkt) | 50 | static inline bool is_erronous(struct cfpkt *pkt) |
51 | { | 51 | { |
52 | return cfpkt_priv(pkt)->erronous; | 52 | return cfpkt_priv(pkt)->erronous; |
53 | } | 53 | } |
54 | 54 | ||
55 | inline struct sk_buff *pkt_to_skb(struct cfpkt *pkt) | 55 | static inline struct sk_buff *pkt_to_skb(struct cfpkt *pkt) |
56 | { | 56 | { |
57 | return &pkt->skb; | 57 | return &pkt->skb; |
58 | } | 58 | } |
59 | 59 | ||
60 | inline struct cfpkt *skb_to_pkt(struct sk_buff *skb) | 60 | static inline struct cfpkt *skb_to_pkt(struct sk_buff *skb) |
61 | { | 61 | { |
62 | return (struct cfpkt *) skb; | 62 | return (struct cfpkt *) skb; |
63 | } | 63 | } |
@@ -317,17 +317,6 @@ int cfpkt_setlen(struct cfpkt *pkt, u16 len) | |||
317 | } | 317 | } |
318 | EXPORT_SYMBOL(cfpkt_setlen); | 318 | EXPORT_SYMBOL(cfpkt_setlen); |
319 | 319 | ||
320 | struct cfpkt *cfpkt_create_uplink(const unsigned char *data, unsigned int len) | ||
321 | { | ||
322 | struct cfpkt *pkt = cfpkt_create_pfx(len + PKT_POSTFIX, PKT_PREFIX); | ||
323 | if (!pkt) | ||
324 | return NULL; | ||
325 | if (unlikely(data != NULL)) | ||
326 | cfpkt_add_body(pkt, data, len); | ||
327 | return pkt; | ||
328 | } | ||
329 | EXPORT_SYMBOL(cfpkt_create_uplink); | ||
330 | |||
331 | struct cfpkt *cfpkt_append(struct cfpkt *dstpkt, | 320 | struct cfpkt *cfpkt_append(struct cfpkt *dstpkt, |
332 | struct cfpkt *addpkt, | 321 | struct cfpkt *addpkt, |
333 | u16 expectlen) | 322 | u16 expectlen) |
@@ -408,169 +397,12 @@ struct cfpkt *cfpkt_split(struct cfpkt *pkt, u16 pos) | |||
408 | } | 397 | } |
409 | EXPORT_SYMBOL(cfpkt_split); | 398 | EXPORT_SYMBOL(cfpkt_split); |
410 | 399 | ||
411 | char *cfpkt_log_pkt(struct cfpkt *pkt, char *buf, int buflen) | 400 | bool cfpkt_erroneous(struct cfpkt *pkt) |
412 | { | ||
413 | struct sk_buff *skb = pkt_to_skb(pkt); | ||
414 | char *p = buf; | ||
415 | int i; | ||
416 | |||
417 | /* | ||
418 | * Sanity check buffer length, it needs to be at least as large as | ||
419 | * the header info: ~=50+ bytes | ||
420 | */ | ||
421 | if (buflen < 50) | ||
422 | return NULL; | ||
423 | |||
424 | snprintf(buf, buflen, "%s: pkt:%p len:%ld(%ld+%ld) {%ld,%ld} data: [", | ||
425 | is_erronous(pkt) ? "ERRONOUS-SKB" : | ||
426 | (skb->data_len != 0 ? "COMPLEX-SKB" : "SKB"), | ||
427 | skb, | ||
428 | (long) skb->len, | ||
429 | (long) (skb_tail_pointer(skb) - skb->data), | ||
430 | (long) skb->data_len, | ||
431 | (long) (skb->data - skb->head), | ||
432 | (long) (skb_tail_pointer(skb) - skb->head)); | ||
433 | p = buf + strlen(buf); | ||
434 | |||
435 | for (i = 0; i < skb_tail_pointer(skb) - skb->data && i < 300; i++) { | ||
436 | if (p > buf + buflen - 10) { | ||
437 | sprintf(p, "..."); | ||
438 | p = buf + strlen(buf); | ||
439 | break; | ||
440 | } | ||
441 | sprintf(p, "%02x,", skb->data[i]); | ||
442 | p = buf + strlen(buf); | ||
443 | } | ||
444 | sprintf(p, "]\n"); | ||
445 | return buf; | ||
446 | } | ||
447 | EXPORT_SYMBOL(cfpkt_log_pkt); | ||
448 | |||
449 | int cfpkt_raw_append(struct cfpkt *pkt, void **buf, unsigned int buflen) | ||
450 | { | ||
451 | struct sk_buff *skb = pkt_to_skb(pkt); | ||
452 | struct sk_buff *lastskb; | ||
453 | |||
454 | caif_assert(buf != NULL); | ||
455 | if (unlikely(is_erronous(pkt))) | ||
456 | return -EPROTO; | ||
457 | /* Make sure SKB is writable */ | ||
458 | if (unlikely(skb_cow_data(skb, 0, &lastskb) < 0)) { | ||
459 | PKT_ERROR(pkt, "skb_cow_data failed\n"); | ||
460 | return -EPROTO; | ||
461 | } | ||
462 | |||
463 | if (unlikely(skb_linearize(skb) != 0)) { | ||
464 | PKT_ERROR(pkt, "linearize failed\n"); | ||
465 | return -EPROTO; | ||
466 | } | ||
467 | |||
468 | if (unlikely(skb_tailroom(skb) < buflen)) { | ||
469 | PKT_ERROR(pkt, "buffer too short - failed\n"); | ||
470 | return -EPROTO; | ||
471 | } | ||
472 | |||
473 | *buf = skb_put(skb, buflen); | ||
474 | return 1; | ||
475 | } | ||
476 | EXPORT_SYMBOL(cfpkt_raw_append); | ||
477 | |||
478 | int cfpkt_raw_extract(struct cfpkt *pkt, void **buf, unsigned int buflen) | ||
479 | { | ||
480 | struct sk_buff *skb = pkt_to_skb(pkt); | ||
481 | |||
482 | caif_assert(buf != NULL); | ||
483 | if (unlikely(is_erronous(pkt))) | ||
484 | return -EPROTO; | ||
485 | |||
486 | if (unlikely(buflen > skb->len)) { | ||
487 | PKT_ERROR(pkt, "buflen too large - failed\n"); | ||
488 | return -EPROTO; | ||
489 | } | ||
490 | |||
491 | if (unlikely(buflen > skb_headlen(skb))) { | ||
492 | if (unlikely(skb_linearize(skb) != 0)) { | ||
493 | PKT_ERROR(pkt, "linearize failed\n"); | ||
494 | return -EPROTO; | ||
495 | } | ||
496 | } | ||
497 | |||
498 | *buf = skb->data; | ||
499 | skb_pull(skb, buflen); | ||
500 | |||
501 | return 1; | ||
502 | } | ||
503 | EXPORT_SYMBOL(cfpkt_raw_extract); | ||
504 | |||
505 | inline bool cfpkt_erroneous(struct cfpkt *pkt) | ||
506 | { | 401 | { |
507 | return cfpkt_priv(pkt)->erronous; | 402 | return cfpkt_priv(pkt)->erronous; |
508 | } | 403 | } |
509 | EXPORT_SYMBOL(cfpkt_erroneous); | 404 | EXPORT_SYMBOL(cfpkt_erroneous); |
510 | 405 | ||
511 | struct cfpktq *cfpktq_create(void) | ||
512 | { | ||
513 | struct cfpktq *q = kmalloc(sizeof(struct cfpktq), GFP_ATOMIC); | ||
514 | if (!q) | ||
515 | return NULL; | ||
516 | skb_queue_head_init(&q->head); | ||
517 | atomic_set(&q->count, 0); | ||
518 | spin_lock_init(&q->lock); | ||
519 | return q; | ||
520 | } | ||
521 | EXPORT_SYMBOL(cfpktq_create); | ||
522 | |||
523 | void cfpkt_queue(struct cfpktq *pktq, struct cfpkt *pkt, unsigned short prio) | ||
524 | { | ||
525 | atomic_inc(&pktq->count); | ||
526 | spin_lock(&pktq->lock); | ||
527 | skb_queue_tail(&pktq->head, pkt_to_skb(pkt)); | ||
528 | spin_unlock(&pktq->lock); | ||
529 | |||
530 | } | ||
531 | EXPORT_SYMBOL(cfpkt_queue); | ||
532 | |||
533 | struct cfpkt *cfpkt_qpeek(struct cfpktq *pktq) | ||
534 | { | ||
535 | struct cfpkt *tmp; | ||
536 | spin_lock(&pktq->lock); | ||
537 | tmp = skb_to_pkt(skb_peek(&pktq->head)); | ||
538 | spin_unlock(&pktq->lock); | ||
539 | return tmp; | ||
540 | } | ||
541 | EXPORT_SYMBOL(cfpkt_qpeek); | ||
542 | |||
543 | struct cfpkt *cfpkt_dequeue(struct cfpktq *pktq) | ||
544 | { | ||
545 | struct cfpkt *pkt; | ||
546 | spin_lock(&pktq->lock); | ||
547 | pkt = skb_to_pkt(skb_dequeue(&pktq->head)); | ||
548 | if (pkt) { | ||
549 | atomic_dec(&pktq->count); | ||
550 | caif_assert(atomic_read(&pktq->count) >= 0); | ||
551 | } | ||
552 | spin_unlock(&pktq->lock); | ||
553 | return pkt; | ||
554 | } | ||
555 | EXPORT_SYMBOL(cfpkt_dequeue); | ||
556 | |||
557 | int cfpkt_qcount(struct cfpktq *pktq) | ||
558 | { | ||
559 | return atomic_read(&pktq->count); | ||
560 | } | ||
561 | EXPORT_SYMBOL(cfpkt_qcount); | ||
562 | |||
563 | struct cfpkt *cfpkt_clone_release(struct cfpkt *pkt) | ||
564 | { | ||
565 | struct cfpkt *clone; | ||
566 | clone = skb_to_pkt(skb_clone(pkt_to_skb(pkt), GFP_ATOMIC)); | ||
567 | /* Free original packet. */ | ||
568 | cfpkt_destroy(pkt); | ||
569 | if (!clone) | ||
570 | return NULL; | ||
571 | return clone; | ||
572 | } | ||
573 | EXPORT_SYMBOL(cfpkt_clone_release); | ||
574 | 406 | ||
575 | struct caif_payload_info *cfpkt_info(struct cfpkt *pkt) | 407 | struct caif_payload_info *cfpkt_info(struct cfpkt *pkt) |
576 | { | 408 | { |
diff --git a/net/caif/cfsrvl.c b/net/caif/cfsrvl.c index ab5e542526bf..24ba392f203b 100644 --- a/net/caif/cfsrvl.c +++ b/net/caif/cfsrvl.c | |||
@@ -151,12 +151,7 @@ static int cfservl_modemcmd(struct cflayer *layr, enum caif_modemcmd ctrl) | |||
151 | return -EINVAL; | 151 | return -EINVAL; |
152 | } | 152 | } |
153 | 153 | ||
154 | void cfservl_destroy(struct cflayer *layer) | 154 | static void cfsrvl_release(struct kref *kref) |
155 | { | ||
156 | kfree(layer); | ||
157 | } | ||
158 | |||
159 | void cfsrvl_release(struct kref *kref) | ||
160 | { | 155 | { |
161 | struct cfsrvl *service = container_of(kref, struct cfsrvl, ref); | 156 | struct cfsrvl *service = container_of(kref, struct cfsrvl, ref); |
162 | kfree(service); | 157 | kfree(service); |