Commit 17836394 authored by Al Viro's avatar Al Viro

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: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent c0371da6
...@@ -606,10 +606,6 @@ struct l2cap_ops { ...@@ -606,10 +606,6 @@ struct l2cap_ops {
struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
unsigned long hdr_len, unsigned long hdr_len,
unsigned long len, int nb); unsigned long len, int nb);
int (*memcpy_fromiovec) (struct l2cap_chan *chan,
unsigned char *kdata,
struct msghdr *msg,
int len);
}; };
struct l2cap_conn { struct l2cap_conn {
...@@ -903,31 +899,6 @@ static inline long l2cap_chan_no_get_sndtimeo(struct l2cap_chan *chan) ...@@ -903,31 +899,6 @@ static inline long l2cap_chan_no_get_sndtimeo(struct l2cap_chan *chan)
return 0; return 0;
} }
static inline int l2cap_chan_no_memcpy_fromiovec(struct l2cap_chan *chan,
unsigned char *kdata,
struct msghdr *msg,
int len)
{
/* Following is safe since for compiler definitions of kvec and
* iovec are identical, yielding the same in-core layout and alignment
*/
struct kvec *vec = (struct kvec *)msg->msg_iter.iov;
while (len > 0) {
if (vec->iov_len) {
int copy = min_t(unsigned int, len, vec->iov_len);
memcpy(kdata, vec->iov_base, copy);
len -= copy;
kdata += copy;
vec->iov_base += copy;
vec->iov_len -= copy;
}
vec++;
}
return 0;
}
extern bool disable_ertm; extern bool disable_ertm;
int l2cap_init_sockets(void); int l2cap_init_sockets(void);
......
...@@ -541,7 +541,7 @@ static int send_pkt(struct l2cap_chan *chan, struct sk_buff *skb, ...@@ -541,7 +541,7 @@ static int send_pkt(struct l2cap_chan *chan, struct sk_buff *skb,
iv.iov_len = skb->len; iv.iov_len = skb->len;
memset(&msg, 0, sizeof(msg)); memset(&msg, 0, sizeof(msg));
iov_iter_init(&msg.msg_iter, WRITE, (struct iovec *) &iv, 1, skb->len); iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iv, 1, skb->len);
err = l2cap_chan_send(chan, &msg, skb->len); err = l2cap_chan_send(chan, &msg, skb->len);
if (err > 0) { if (err > 0) {
...@@ -1050,7 +1050,6 @@ static const struct l2cap_ops bt_6lowpan_chan_ops = { ...@@ -1050,7 +1050,6 @@ static const struct l2cap_ops bt_6lowpan_chan_ops = {
.suspend = chan_suspend_cb, .suspend = chan_suspend_cb,
.get_sndtimeo = chan_get_sndtimeo_cb, .get_sndtimeo = chan_get_sndtimeo_cb,
.alloc_skb = chan_alloc_skb_cb, .alloc_skb = chan_alloc_skb_cb,
.memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
.teardown = l2cap_chan_no_teardown, .teardown = l2cap_chan_no_teardown,
.defer = l2cap_chan_no_defer, .defer = l2cap_chan_no_defer,
......
...@@ -60,7 +60,7 @@ void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data) ...@@ -60,7 +60,7 @@ void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data)
memset(&msg, 0, sizeof(msg)); memset(&msg, 0, sizeof(msg));
iov_iter_init(&msg.msg_iter, WRITE, (struct iovec *)&iv, 1, total_len); iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iv, 1, total_len);
l2cap_chan_send(chan, &msg, total_len); l2cap_chan_send(chan, &msg, total_len);
...@@ -719,7 +719,6 @@ static const struct l2cap_ops a2mp_chan_ops = { ...@@ -719,7 +719,6 @@ static const struct l2cap_ops a2mp_chan_ops = {
.resume = l2cap_chan_no_resume, .resume = l2cap_chan_no_resume,
.set_shutdown = l2cap_chan_no_set_shutdown, .set_shutdown = l2cap_chan_no_set_shutdown,
.get_sndtimeo = l2cap_chan_no_get_sndtimeo, .get_sndtimeo = l2cap_chan_no_get_sndtimeo,
.memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
}; };
static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked) static struct l2cap_chan *a2mp_chan_open(struct l2cap_conn *conn, bool locked)
......
...@@ -2096,8 +2096,7 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, ...@@ -2096,8 +2096,7 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan,
struct sk_buff **frag; struct sk_buff **frag;
int sent = 0; int sent = 0;
if (chan->ops->memcpy_fromiovec(chan, skb_put(skb, count), if (copy_from_iter(skb_put(skb, count), count, &msg->msg_iter) != count)
msg, count))
return -EFAULT; return -EFAULT;
sent += count; sent += count;
...@@ -2117,8 +2116,8 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan, ...@@ -2117,8 +2116,8 @@ static inline int l2cap_skbuff_fromiovec(struct l2cap_chan *chan,
*frag = tmp; *frag = tmp;
if (chan->ops->memcpy_fromiovec(chan, skb_put(*frag, count), if (copy_from_iter(skb_put(*frag, count), count,
msg, count)) &msg->msg_iter) != count)
return -EFAULT; return -EFAULT;
sent += count; sent += count;
......
...@@ -1336,13 +1336,6 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan, ...@@ -1336,13 +1336,6 @@ static struct sk_buff *l2cap_sock_alloc_skb_cb(struct l2cap_chan *chan,
return skb; return skb;
} }
static int l2cap_sock_memcpy_fromiovec_cb(struct l2cap_chan *chan,
unsigned char *kdata,
struct msghdr *msg, int len)
{
return memcpy_from_msg(kdata, msg, len);
}
static void l2cap_sock_ready_cb(struct l2cap_chan *chan) static void l2cap_sock_ready_cb(struct l2cap_chan *chan)
{ {
struct sock *sk = chan->data; struct sock *sk = chan->data;
...@@ -1427,7 +1420,6 @@ static const struct l2cap_ops l2cap_chan_ops = { ...@@ -1427,7 +1420,6 @@ static const struct l2cap_ops l2cap_chan_ops = {
.set_shutdown = l2cap_sock_set_shutdown_cb, .set_shutdown = l2cap_sock_set_shutdown_cb,
.get_sndtimeo = l2cap_sock_get_sndtimeo_cb, .get_sndtimeo = l2cap_sock_get_sndtimeo_cb,
.alloc_skb = l2cap_sock_alloc_skb_cb, .alloc_skb = l2cap_sock_alloc_skb_cb,
.memcpy_fromiovec = l2cap_sock_memcpy_fromiovec_cb,
}; };
static void l2cap_sock_destruct(struct sock *sk) static void l2cap_sock_destruct(struct sock *sk)
......
...@@ -268,7 +268,7 @@ static void smp_send_cmd(struct l2cap_conn *conn, u8 code, u16 len, void *data) ...@@ -268,7 +268,7 @@ static void smp_send_cmd(struct l2cap_conn *conn, u8 code, u16 len, void *data)
memset(&msg, 0, sizeof(msg)); memset(&msg, 0, sizeof(msg));
iov_iter_init(&msg.msg_iter, WRITE, (struct iovec *)iv, 2, 1 + len); iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, iv, 2, 1 + len);
l2cap_chan_send(chan, &msg, 1 + len); l2cap_chan_send(chan, &msg, 1 + len);
...@@ -1629,7 +1629,6 @@ static const struct l2cap_ops smp_chan_ops = { ...@@ -1629,7 +1629,6 @@ static const struct l2cap_ops smp_chan_ops = {
.suspend = l2cap_chan_no_suspend, .suspend = l2cap_chan_no_suspend,
.set_shutdown = l2cap_chan_no_set_shutdown, .set_shutdown = l2cap_chan_no_set_shutdown,
.get_sndtimeo = l2cap_chan_no_get_sndtimeo, .get_sndtimeo = l2cap_chan_no_get_sndtimeo,
.memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
}; };
static inline struct l2cap_chan *smp_new_conn_cb(struct l2cap_chan *pchan) 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,7 +1677,6 @@ static const struct l2cap_ops smp_root_chan_ops = {
.resume = l2cap_chan_no_resume, .resume = l2cap_chan_no_resume,
.set_shutdown = l2cap_chan_no_set_shutdown, .set_shutdown = l2cap_chan_no_set_shutdown,
.get_sndtimeo = l2cap_chan_no_get_sndtimeo, .get_sndtimeo = l2cap_chan_no_get_sndtimeo,
.memcpy_fromiovec = l2cap_chan_no_memcpy_fromiovec,
}; };
int smp_register(struct hci_dev *hdev) int smp_register(struct hci_dev *hdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment