mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 23:58:05 +00:00
Bluetooth: Add support for vectored writes to virtual HCI driver
The Bluetooth virtual HCI driver is using a misc character device to allow emulation of HCI devices from userspace. This change enables the support for vectored writes. Previously this was failing with EINVAL since no complete H:4 packet was written. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
de8b582893
commit
5bc00b5c58
1 changed files with 18 additions and 11 deletions
|
@ -141,22 +141,28 @@ static int vhci_create_device(struct vhci_data *data, __u8 dev_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ssize_t vhci_get_user(struct vhci_data *data,
|
static inline ssize_t vhci_get_user(struct vhci_data *data,
|
||||||
const char __user *buf, size_t count)
|
const struct iovec *iov,
|
||||||
|
unsigned long count)
|
||||||
{
|
{
|
||||||
|
size_t len = iov_length(iov, count);
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
__u8 pkt_type, dev_type;
|
__u8 pkt_type, dev_type;
|
||||||
|
unsigned long i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (count < 2 || count > HCI_MAX_FRAME_SIZE)
|
if (len < 2 || len > HCI_MAX_FRAME_SIZE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
skb = bt_skb_alloc(count, GFP_KERNEL);
|
skb = bt_skb_alloc(len, GFP_KERNEL);
|
||||||
if (!skb)
|
if (!skb)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (copy_from_user(skb_put(skb, count), buf, count)) {
|
for (i = 0; i < count; i++) {
|
||||||
kfree_skb(skb);
|
if (copy_from_user(skb_put(skb, iov[i].iov_len),
|
||||||
return -EFAULT;
|
iov[i].iov_base, iov[i].iov_len)) {
|
||||||
|
kfree_skb(skb);
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt_type = *((__u8 *) skb->data);
|
pkt_type = *((__u8 *) skb->data);
|
||||||
|
@ -205,7 +211,7 @@ static inline ssize_t vhci_get_user(struct vhci_data *data,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (ret < 0) ? ret : count;
|
return (ret < 0) ? ret : len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline ssize_t vhci_put_user(struct vhci_data *data,
|
static inline ssize_t vhci_put_user(struct vhci_data *data,
|
||||||
|
@ -272,12 +278,13 @@ static ssize_t vhci_read(struct file *file,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t vhci_write(struct file *file,
|
static ssize_t vhci_write(struct kiocb *iocb, const struct iovec *iov,
|
||||||
const char __user *buf, size_t count, loff_t *pos)
|
unsigned long count, loff_t pos)
|
||||||
{
|
{
|
||||||
|
struct file *file = iocb->ki_filp;
|
||||||
struct vhci_data *data = file->private_data;
|
struct vhci_data *data = file->private_data;
|
||||||
|
|
||||||
return vhci_get_user(data, buf, count);
|
return vhci_get_user(data, iov, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int vhci_poll(struct file *file, poll_table *wait)
|
static unsigned int vhci_poll(struct file *file, poll_table *wait)
|
||||||
|
@ -342,7 +349,7 @@ static int vhci_release(struct inode *inode, struct file *file)
|
||||||
static const struct file_operations vhci_fops = {
|
static const struct file_operations vhci_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.read = vhci_read,
|
.read = vhci_read,
|
||||||
.write = vhci_write,
|
.aio_write = vhci_write,
|
||||||
.poll = vhci_poll,
|
.poll = vhci_poll,
|
||||||
.open = vhci_open,
|
.open = vhci_open,
|
||||||
.release = vhci_release,
|
.release = vhci_release,
|
||||||
|
|
Loading…
Reference in a new issue