diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2014-11-24 17:07:38 -0500 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-12-09 16:29:10 -0500 |
| commit | 17836394e578b8d6475ecdb309ad1356bbcf37a2 (patch) | |
| tree | 0a96321812719cff97012d161bcdf4d47b4740ea | |
| parent | c0371da6047abd261bc483c744dbc7d81a116172 (diff) | |
first fruits - kill l2cap ->memcpy_fromiovec()
Just use copy_from_iter(). That's what this method is trying to do
in all cases, in a very convoluted fashion.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| -rw-r--r-- | include/net/bluetooth/l2cap.h | 29 | ||||
| -rw-r--r-- | net/bluetooth/6lowpan.c | 3 | ||||
| -rw-r--r-- | net/bluetooth/a2mp.c | 3 | ||||
| -rw-r--r-- | net/bluetooth/l2cap_core.c | 7 | ||||
| -rw-r--r-- | net/bluetooth/l2cap_sock.c | 8 | ||||
| -rw-r--r-- | net/bluetooth/smp.c | 4 |
6 files changed, 6 insertions, 48 deletions
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index bca6fc0a3196..692f786bebe2 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
| @@ -606,10 +606,6 @@ struct l2cap_ops { | |||
| 606 | struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, | 606 | struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, |
| 607 | unsigned long hdr_len, | 607 | unsigned long hdr_len, |
| 608 | unsigned long len, int nb); | 608 | unsigned long len, int nb); |
| 609 | int (*memcpy_fromiovec) (struct l2cap_chan *chan, | ||
| 610 | unsigned char *kdata, | ||
| 611 | struct msghdr *msg, | ||
| 612 | int len); | ||
| 613 | }; | 609 | }; |
| 614 | 610 | ||
| 615 | struct l2cap_conn { | 611 | struct l2cap_conn { |
| @@ -903,31 +899,6 @@ static inline long l2cap_chan_no_get_sndtimeo(struct l2cap_chan *chan) | |||
| 903 | return 0; | 899 | return 0; |
| 904 | } | 900 | } |
| 905 | 901 | ||
| 906 | static inline int l2cap_chan_no_memcpy_fromiovec(struct l2cap_chan *chan, | ||
| 907 | unsigned char *kdata, | ||
| 908 | struct msghdr *msg, | ||
| 909 | int len) | ||
| 910 | { | ||
| 911 | /* Following is safe since for compiler definitions of kvec and | ||
| 912 | * iovec are identical, yielding the same in-core layout and alignment | ||
| 913 | */ | ||
| 914 | struct kvec *vec = (struct kvec *)msg->msg_iter.iov; | ||
| 915 | |||
| 916 | while (len > 0) { | ||
| 917 | if (vec->iov_len) { | ||
| 918 | int copy = min_t(unsigned int, len, vec->iov_len); | ||
| 919 | memcpy(kdata, vec->iov_base, copy); | ||
| 920 | len -= copy; | ||
| 921 | kdata += copy; | ||
| 922 | vec->iov_base += copy; | ||
| 923 | vec->iov_len -= copy; | ||
| 924 | } | ||
| 925 | vec++; | ||
| 926 | } | ||
| 927 | |||
| 928 | return 0; | ||
| 929 | } | ||
| 930 | |||
| 931 | extern bool disable_ertm; | 902 | extern bool disable_ertm; |
| 932 | 903 | ||
| 933 | int l2cap_init_sockets(void); | 904 | int l2cap_init_sockets(void); |
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index d8c67a5e7a02..76617be1e797 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c | |||
| @@ -541,7 +541,7 @@ static int send_pkt(struct l2cap_chan *chan, struct sk_buff *skb, | |||
| 541 | iv.iov_len = skb->len; | 541 | iv.iov_len = skb->len; |
| 542 | 542 | ||
| 543 | memset(&msg, 0, sizeof(msg)); | 543 | memset(&msg, 0, sizeof(msg)); |
| 544 | iov_iter_init(&msg.msg_iter, WRITE, (struct iovec *) &iv, 1, skb->len); | 544 | iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iv, 1, skb->len); |
| 545 | 545 | ||
| 546 | err = l2cap_chan_send(chan, &msg, skb->len); | 546 | err = l2cap_chan_send(chan, &msg, skb->len); |
| 547 | if (err > 0) { | 547 | if (err > 0) { |
| @@ -1050,7 +1050,6 @@ static const struct l2cap_ops bt_6lowpan_chan_ops = { | |||
| 1050 | .suspend = chan_suspend_cb, | 1050 | .suspend = chan_suspend_cb, |
| 1051 | .get_sndtimeo = chan_get_sndtimeo_cb, | 1051 | .get_sndtimeo = chan_get_sndtimeo_cb, |
| 1052 | .alloc_skb = chan_alloc_skb_cb, | 1052 | .alloc_skb = chan_alloc_skb_cb, |
| 1053 | .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec, | ||
| 1054 | 1053 | ||
| 1055 | .teardown = l2cap_chan_no_teardown, | 1054 | .teardown = l2cap_chan_no_teardown, |
| 1056 | .defer = l2cap_chan_no_defer, | 1055 | .defer = l2cap_chan_no_defer, |
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c index 716d2a388858..cedfbda15dad 100644 --- a/net/bluetooth/a2mp.c +++ b/net/bluetooth/a2mp.c | |||
| @@ -60,7 +60,7 @@ void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data) | |||
| 60 | 60 | ||
| 61 | memset(&msg, 0, sizeof(msg)); | 61 | memset(&msg, 0, sizeof(msg)); |
| 62 | 62 | ||
| 63 | iov_iter_init(&msg.msg_iter, WRITE, (struct iovec *)&iv, 1, total_len); | 63 | iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iv, 1, total_len); |
| 64 | 64 | ||
| 65 | l2cap_chan_send(chan, &msg, total_len); | 65 | l2cap_chan_send(chan, &msg, total_len); |
| 66 | 66 | ||
| @@ -719,7 +719,6 @@ static const struct l2cap_ops a2mp_chan_ops = { | |||
| 719 | .resume = l2cap_chan_no_resume, | 719 | .resume = l2cap_chan_no_resume, |
| 720 | .set_shutdown = l2cap_chan_no_set_shutdown, | 720 | .set_shutdown = l2cap_chan_no_set_shutdown, |
| 721 | .get_sndtimeo = l2cap_chan_no_get_sndtimeo, | 721 | .get_sndtimeo = l2cap_chan_no_get_sndtimeo, |
| 722 | .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec, | ||
| 723 | }; | 722 | }; |
| 724 | 723 | ||
| 725 | static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked) | 724 | static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked) |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 5201d6167acb..1754040d00a8 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
| @@ -2096,8 +2096,7 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, | |||
| 2096 | struct sk_buff **frag; | 2096 | struct sk_buff **frag; |
| 2097 | int sent = 0; | 2097 | int sent = 0; |
| 2098 | 2098 | ||
| 2099 | if (chan->ops->memcpy_fromiovec(chan, skb_put(skb, count), | 2099 | if (copy_from_iter(skb_put(skb, count), count, &msg->msg_iter) != count) |
| 2100 | msg, count)) | ||
| 2101 | return -EFAULT; | 2100 | return -EFAULT; |
| 2102 | 2101 | ||
| 2103 | sent += count; | 2102 | sent += count; |
| @@ -2117,8 +2116,8 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, | |||
| 2117 | 2116 | ||
| 2118 | *frag = tmp; | 2117 | *frag = tmp; |
| 2119 | 2118 | ||
| 2120 | if (chan->ops->memcpy_fromiovec(chan, skb_put(*frag, count), | 2119 | if (copy_from_iter(skb_put(*frag, count), count, |
| 2121 | msg, count)) | 2120 | &msg->msg_iter) != count) |
| 2122 | return -EFAULT; | 2121 | return -EFAULT; |
| 2123 | 2122 | ||
| 2124 | sent += count; | 2123 | sent += count; |
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 205b298d9efb..f65caf41953f 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c | |||
| @@ -1336,13 +1336,6 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan, | |||
| 1336 | return skb; | 1336 | return skb; |
| 1337 | } | 1337 | } |
| 1338 | 1338 | ||
| 1339 | static int l2cap_sock_memcpy_fromiovec_cb(struct l2cap_chan *chan, | ||
| 1340 | unsigned char *kdata, | ||
| 1341 | struct msghdr *msg, int len) | ||
| 1342 | { | ||
| 1343 | return memcpy_from_msg(kdata, msg, len); | ||
| 1344 | } | ||
| 1345 | |||
| 1346 | static void l2cap_sock_ready_cb(struct l2cap_chan *chan) | 1339 | static void l2cap_sock_ready_cb(struct l2cap_chan *chan) |
| 1347 | { | 1340 | { |
| 1348 | struct sock *sk = chan->data; | 1341 | struct sock *sk = chan->data; |
| @@ -1427,7 +1420,6 @@ static const struct l2cap_ops l2cap_chan_ops = { | |||
| 1427 | .set_shutdown = l2cap_sock_set_shutdown_cb, | 1420 | .set_shutdown = l2cap_sock_set_shutdown_cb, |
| 1428 | .get_sndtimeo = l2cap_sock_get_sndtimeo_cb, | 1421 | .get_sndtimeo = l2cap_sock_get_sndtimeo_cb, |
| 1429 | .alloc_skb = l2cap_sock_alloc_skb_cb, | 1422 | .alloc_skb = l2cap_sock_alloc_skb_cb, |
| 1430 | .memcpy_fromiovec = l2cap_sock_memcpy_fromiovec_cb, | ||
| 1431 | }; | 1423 | }; |
| 1432 | 1424 | ||
| 1433 | static void l2cap_sock_destruct(struct sock *sk) | 1425 | static void l2cap_sock_destruct(struct sock *sk) |
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index 21f555b4df17..de7dc7581ff0 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
| @@ -268,7 +268,7 @@ static void smp_send_cmd(struct l2cap_conn *conn, u8 code, u16 len, void *data) | |||
| 268 | 268 | ||
| 269 | memset(&msg, 0, sizeof(msg)); | 269 | memset(&msg, 0, sizeof(msg)); |
| 270 | 270 | ||
| 271 | iov_iter_init(&msg.msg_iter, WRITE, (struct iovec *)iv, 2, 1 + len); | 271 | iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, iv, 2, 1 + len); |
| 272 | 272 | ||
| 273 | l2cap_chan_send(chan, &msg, 1 + len); | 273 | l2cap_chan_send(chan, &msg, 1 + len); |
| 274 | 274 | ||
| @@ -1629,7 +1629,6 @@ static const struct l2cap_ops smp_chan_ops = { | |||
| 1629 | .suspend = l2cap_chan_no_suspend, | 1629 | .suspend = l2cap_chan_no_suspend, |
| 1630 | .set_shutdown = l2cap_chan_no_set_shutdown, | 1630 | .set_shutdown = l2cap_chan_no_set_shutdown, |
| 1631 | .get_sndtimeo = l2cap_chan_no_get_sndtimeo, | 1631 | .get_sndtimeo = l2cap_chan_no_get_sndtimeo, |
| 1632 | .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec, | ||
| 1633 | }; | 1632 | }; |
| 1634 | 1633 | ||
| 1635 | static inline struct l2cap_chan *smp_new_conn_cb(struct l2cap_chan *pchan) | 1634 | static inline struct l2cap_chan *smp_new_conn_cb(struct l2cap_chan *pchan) |
| @@ -1678,7 +1677,6 @@ static const struct l2cap_ops smp_root_chan_ops = { | |||
| 1678 | .resume = l2cap_chan_no_resume, | 1677 | .resume = l2cap_chan_no_resume, |
| 1679 | .set_shutdown = l2cap_chan_no_set_shutdown, | 1678 | .set_shutdown = l2cap_chan_no_set_shutdown, |
| 1680 | .get_sndtimeo = l2cap_chan_no_get_sndtimeo, | 1679 | .get_sndtimeo = l2cap_chan_no_get_sndtimeo, |
| 1681 | .memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec, | ||
| 1682 | }; | 1680 | }; |
| 1683 | 1681 | ||
| 1684 | int smp_register(struct hci_dev *hdev) | 1682 | int smp_register(struct hci_dev *hdev) |
