aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth/hidp
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2013-04-06 14:28:49 -0400
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>2013-04-17 02:04:03 -0400
commit7350e6cf360d32206cbe4e3d34fb48ab863bdb14 (patch)
tree6ed42830673826c03e918ea8e85c5fc34e47bc0e /net/bluetooth/hidp
parent2df012001d36e56cd92dab0255cf4bce3f5b16bc (diff)
Bluetooth: hidp: merge hidp_process_{ctrl,intr}_transmit()
Both hidp_process_ctrl_transmit() and hidp_process_intr_transmit() are exactly the same apart from the transmit-queue and socket pointers. Therefore, pass them as argument and merge both functions into one so we avoid 25 lines of code-duplication. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Diffstat (limited to 'net/bluetooth/hidp')
-rw-r--r--net/bluetooth/hidp/core.c40
1 files changed, 11 insertions, 29 deletions
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 3f6ef0630a8e..8f81379e9907 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -636,40 +636,20 @@ static int hidp_send_frame(struct socket *sock, unsigned char *data, int len)
636 return kernel_sendmsg(sock, &msg, &iv, 1, len); 636 return kernel_sendmsg(sock, &msg, &iv, 1, len);
637} 637}
638 638
639static void hidp_process_intr_transmit(struct hidp_session *session) 639/* dequeue message from @transmit and send via @sock */
640static void hidp_process_transmit(struct hidp_session *session,
641 struct sk_buff_head *transmit,
642 struct socket *sock)
640{ 643{
641 struct sk_buff *skb; 644 struct sk_buff *skb;
642 int ret; 645 int ret;
643 646
644 BT_DBG("session %p", session); 647 BT_DBG("session %p", session);
645 648
646 while ((skb = skb_dequeue(&session->intr_transmit))) { 649 while ((skb = skb_dequeue(transmit))) {
647 ret = hidp_send_frame(session->intr_sock, skb->data, skb->len); 650 ret = hidp_send_frame(sock, skb->data, skb->len);
648 if (ret == -EAGAIN) { 651 if (ret == -EAGAIN) {
649 skb_queue_head(&session->intr_transmit, skb); 652 skb_queue_head(transmit, skb);
650 break;
651 } else if (ret < 0) {
652 hidp_session_terminate(session);
653 kfree_skb(skb);
654 break;
655 }
656
657 hidp_set_timer(session);
658 kfree_skb(skb);
659 }
660}
661
662static void hidp_process_ctrl_transmit(struct hidp_session *session)
663{
664 struct sk_buff *skb;
665 int ret;
666
667 BT_DBG("session %p", session);
668
669 while ((skb = skb_dequeue(&session->ctrl_transmit))) {
670 ret = hidp_send_frame(session->ctrl_sock, skb->data, skb->len);
671 if (ret == -EAGAIN) {
672 skb_queue_head(&session->ctrl_transmit, skb);
673 break; 653 break;
674 } else if (ret < 0) { 654 } else if (ret < 0) {
675 hidp_session_terminate(session); 655 hidp_session_terminate(session);
@@ -1224,7 +1204,8 @@ static void hidp_session_run(struct hidp_session *session)
1224 } 1204 }
1225 1205
1226 /* send pending intr-skbs */ 1206 /* send pending intr-skbs */
1227 hidp_process_intr_transmit(session); 1207 hidp_process_transmit(session, &session->intr_transmit,
1208 session->intr_sock);
1228 1209
1229 /* parse incoming ctrl-skbs */ 1210 /* parse incoming ctrl-skbs */
1230 while ((skb = skb_dequeue(&ctrl_sk->sk_receive_queue))) { 1211 while ((skb = skb_dequeue(&ctrl_sk->sk_receive_queue))) {
@@ -1236,7 +1217,8 @@ static void hidp_session_run(struct hidp_session *session)
1236 } 1217 }
1237 1218
1238 /* send pending ctrl-skbs */ 1219 /* send pending ctrl-skbs */
1239 hidp_process_ctrl_transmit(session); 1220 hidp_process_transmit(session, &session->ctrl_transmit,
1221 session->ctrl_sock);
1240 1222
1241 schedule(); 1223 schedule();
1242 } 1224 }