diff options
author | Bjorn Andersson <bjorn.andersson@linaro.org> | 2017-06-07 17:07:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-06-08 11:34:56 -0400 |
commit | 64f9eca06415dc820ff8a2263f846dc8199adb50 (patch) | |
tree | 0ba50b4a06cc83d2093aed2654760f3e02667775 /net/qrtr | |
parent | 02417f47875c2a22d2a8c140c5b945c741005938 (diff) |
net: qrtr: Refactor packet allocation
Extract the allocation and filling in the control message header fields
to a separate function in order to reuse this in subsequent patches.
Cc: Courtney Cavin <ccavin@gmail.com>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/qrtr')
-rw-r--r-- | net/qrtr/qrtr.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c index a9a8c7d5a4a9..86d35ed50da9 100644 --- a/net/qrtr/qrtr.c +++ b/net/qrtr/qrtr.c | |||
@@ -245,14 +245,11 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) | |||
245 | } | 245 | } |
246 | EXPORT_SYMBOL_GPL(qrtr_endpoint_post); | 246 | EXPORT_SYMBOL_GPL(qrtr_endpoint_post); |
247 | 247 | ||
248 | /* Allocate and construct a resume-tx packet. */ | 248 | static struct sk_buff *qrtr_alloc_ctrl_packet(u32 type, size_t pkt_len, |
249 | static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, | 249 | u32 src_node, u32 dst_node) |
250 | u32 dst_node, u32 port) | ||
251 | { | 250 | { |
252 | const int pkt_len = 20; | ||
253 | struct qrtr_hdr *hdr; | 251 | struct qrtr_hdr *hdr; |
254 | struct sk_buff *skb; | 252 | struct sk_buff *skb; |
255 | __le32 *buf; | ||
256 | 253 | ||
257 | skb = alloc_skb(QRTR_HDR_SIZE + pkt_len, GFP_KERNEL); | 254 | skb = alloc_skb(QRTR_HDR_SIZE + pkt_len, GFP_KERNEL); |
258 | if (!skb) | 255 | if (!skb) |
@@ -261,7 +258,7 @@ static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, | |||
261 | 258 | ||
262 | hdr = (struct qrtr_hdr *)skb_put(skb, QRTR_HDR_SIZE); | 259 | hdr = (struct qrtr_hdr *)skb_put(skb, QRTR_HDR_SIZE); |
263 | hdr->version = cpu_to_le32(QRTR_PROTO_VER); | 260 | hdr->version = cpu_to_le32(QRTR_PROTO_VER); |
264 | hdr->type = cpu_to_le32(QRTR_TYPE_RESUME_TX); | 261 | hdr->type = cpu_to_le32(type); |
265 | hdr->src_node_id = cpu_to_le32(src_node); | 262 | hdr->src_node_id = cpu_to_le32(src_node); |
266 | hdr->src_port_id = cpu_to_le32(QRTR_PORT_CTRL); | 263 | hdr->src_port_id = cpu_to_le32(QRTR_PORT_CTRL); |
267 | hdr->confirm_rx = cpu_to_le32(0); | 264 | hdr->confirm_rx = cpu_to_le32(0); |
@@ -269,6 +266,22 @@ static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, | |||
269 | hdr->dst_node_id = cpu_to_le32(dst_node); | 266 | hdr->dst_node_id = cpu_to_le32(dst_node); |
270 | hdr->dst_port_id = cpu_to_le32(QRTR_PORT_CTRL); | 267 | hdr->dst_port_id = cpu_to_le32(QRTR_PORT_CTRL); |
271 | 268 | ||
269 | return skb; | ||
270 | } | ||
271 | |||
272 | /* Allocate and construct a resume-tx packet. */ | ||
273 | static struct sk_buff *qrtr_alloc_resume_tx(u32 src_node, | ||
274 | u32 dst_node, u32 port) | ||
275 | { | ||
276 | const int pkt_len = 20; | ||
277 | struct sk_buff *skb; | ||
278 | __le32 *buf; | ||
279 | |||
280 | skb = qrtr_alloc_ctrl_packet(QRTR_TYPE_RESUME_TX, pkt_len, | ||
281 | src_node, dst_node); | ||
282 | if (!skb) | ||
283 | return NULL; | ||
284 | |||
272 | buf = (__le32 *)skb_put(skb, pkt_len); | 285 | buf = (__le32 *)skb_put(skb, pkt_len); |
273 | memset(buf, 0, pkt_len); | 286 | memset(buf, 0, pkt_len); |
274 | buf[0] = cpu_to_le32(QRTR_TYPE_RESUME_TX); | 287 | buf[0] = cpu_to_le32(QRTR_TYPE_RESUME_TX); |