Commit 11743c56 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'rpmsg-v4.20' of git://github.com/andersson/remoteproc

Pull rpmsg updates from Bjorn Andersson:
 "This migrates rpmsg_char to use read/write_iter to allow being
  operated using aio, removes the message size alignment requirements
  from glink, closes a potential memory leak in SMD and switches to
  %pOFn for printing device_node names"

* tag 'rpmsg-v4.20' of git://github.com/andersson/remoteproc:
  rpmsg: glink: smem: Support rx peak for size less than 4 bytes
  rpmsg: smd: fix memory leak on channel create
  rpmsg: glink: Remove chunk size word align warning
  rpmsg: Convert to using %pOFn instead of device_node.name
  rpmsg: char: Migrate to iter versions of read and write
parents 929e134c 928002a5
...@@ -792,9 +792,6 @@ static int qcom_glink_rx_data(struct qcom_glink *glink, size_t avail) ...@@ -792,9 +792,6 @@ static int qcom_glink_rx_data(struct qcom_glink *glink, size_t avail)
return -EAGAIN; return -EAGAIN;
} }
if (WARN(chunk_size % 4, "Incoming data must be word aligned\n"))
return -EINVAL;
rcid = le16_to_cpu(hdr.msg.param1); rcid = le16_to_cpu(hdr.msg.param1);
spin_lock_irqsave(&glink->idr_lock, flags); spin_lock_irqsave(&glink->idr_lock, flags);
channel = idr_find(&glink->rcids, rcid); channel = idr_find(&glink->rcids, rcid);
......
...@@ -89,15 +89,11 @@ static void glink_smem_rx_peak(struct qcom_glink_pipe *np, ...@@ -89,15 +89,11 @@ static void glink_smem_rx_peak(struct qcom_glink_pipe *np,
tail -= pipe->native.length; tail -= pipe->native.length;
len = min_t(size_t, count, pipe->native.length - tail); len = min_t(size_t, count, pipe->native.length - tail);
if (len) { if (len)
__ioread32_copy(data, pipe->fifo + tail, memcpy_fromio(data, pipe->fifo + tail, len);
len / sizeof(u32));
}
if (len != count) { if (len != count)
__ioread32_copy(data + len, pipe->fifo, memcpy_fromio(data + len, pipe->fifo, (count - len));
(count - len) / sizeof(u32));
}
} }
static void glink_smem_rx_advance(struct qcom_glink_pipe *np, static void glink_smem_rx_advance(struct qcom_glink_pipe *np,
...@@ -205,7 +201,7 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent, ...@@ -205,7 +201,7 @@ struct qcom_glink *qcom_glink_smem_register(struct device *parent,
dev->parent = parent; dev->parent = parent;
dev->of_node = node; dev->of_node = node;
dev->release = qcom_glink_smem_release; dev->release = qcom_glink_smem_release;
dev_set_name(dev, "%s:%s", node->parent->name, node->name); dev_set_name(dev, "%pOFn:%pOFn", node->parent, node);
ret = device_register(dev); ret = device_register(dev);
if (ret) { if (ret) {
pr_err("failed to register glink edge\n"); pr_err("failed to register glink edge\n");
......
...@@ -1122,8 +1122,10 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed ...@@ -1122,8 +1122,10 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
channel->edge = edge; channel->edge = edge;
channel->name = kstrdup(name, GFP_KERNEL); channel->name = kstrdup(name, GFP_KERNEL);
if (!channel->name) if (!channel->name) {
return ERR_PTR(-ENOMEM); ret = -ENOMEM;
goto free_channel;
}
spin_lock_init(&channel->tx_lock); spin_lock_init(&channel->tx_lock);
spin_lock_init(&channel->recv_lock); spin_lock_init(&channel->recv_lock);
...@@ -1173,6 +1175,7 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed ...@@ -1173,6 +1175,7 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
free_name_and_channel: free_name_and_channel:
kfree(channel->name); kfree(channel->name);
free_channel:
kfree(channel); kfree(channel);
return ERR_PTR(ret); return ERR_PTR(ret);
...@@ -1454,7 +1457,7 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent, ...@@ -1454,7 +1457,7 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,
edge->dev.release = qcom_smd_edge_release; edge->dev.release = qcom_smd_edge_release;
edge->dev.of_node = node; edge->dev.of_node = node;
edge->dev.groups = qcom_smd_edge_groups; edge->dev.groups = qcom_smd_edge_groups;
dev_set_name(&edge->dev, "%s:%s", dev_name(parent), node->name); dev_set_name(&edge->dev, "%s:%pOFn", dev_name(parent), node);
ret = device_register(&edge->dev); ret = device_register(&edge->dev);
if (ret) { if (ret) {
pr_err("failed to register smd edge\n"); pr_err("failed to register smd edge\n");
......
...@@ -167,9 +167,9 @@ static int rpmsg_eptdev_release(struct inode *inode, struct file *filp) ...@@ -167,9 +167,9 @@ static int rpmsg_eptdev_release(struct inode *inode, struct file *filp)
return 0; return 0;
} }
static ssize_t rpmsg_eptdev_read(struct file *filp, char __user *buf, static ssize_t rpmsg_eptdev_read_iter(struct kiocb *iocb, struct iov_iter *to)
size_t len, loff_t *f_pos)
{ {
struct file *filp = iocb->ki_filp;
struct rpmsg_eptdev *eptdev = filp->private_data; struct rpmsg_eptdev *eptdev = filp->private_data;
unsigned long flags; unsigned long flags;
struct sk_buff *skb; struct sk_buff *skb;
...@@ -205,8 +205,8 @@ static ssize_t rpmsg_eptdev_read(struct file *filp, char __user *buf, ...@@ -205,8 +205,8 @@ static ssize_t rpmsg_eptdev_read(struct file *filp, char __user *buf,
if (!skb) if (!skb)
return -EFAULT; return -EFAULT;
use = min_t(size_t, len, skb->len); use = min_t(size_t, iov_iter_count(to), skb->len);
if (copy_to_user(buf, skb->data, use)) if (copy_to_iter(skb->data, use, to) != use)
use = -EFAULT; use = -EFAULT;
kfree_skb(skb); kfree_skb(skb);
...@@ -214,16 +214,21 @@ static ssize_t rpmsg_eptdev_read(struct file *filp, char __user *buf, ...@@ -214,16 +214,21 @@ static ssize_t rpmsg_eptdev_read(struct file *filp, char __user *buf,
return use; return use;
} }
static ssize_t rpmsg_eptdev_write(struct file *filp, const char __user *buf, static ssize_t rpmsg_eptdev_write_iter(struct kiocb *iocb,
size_t len, loff_t *f_pos) struct iov_iter *from)
{ {
struct file *filp = iocb->ki_filp;
struct rpmsg_eptdev *eptdev = filp->private_data; struct rpmsg_eptdev *eptdev = filp->private_data;
size_t len = iov_iter_count(from);
void *kbuf; void *kbuf;
int ret; int ret;
kbuf = memdup_user(buf, len); kbuf = kzalloc(len, GFP_KERNEL);
if (IS_ERR(kbuf)) if (!kbuf)
return PTR_ERR(kbuf); return -ENOMEM;
if (!copy_from_iter_full(kbuf, len, from))
return -EFAULT;
if (mutex_lock_interruptible(&eptdev->ept_lock)) { if (mutex_lock_interruptible(&eptdev->ept_lock)) {
ret = -ERESTARTSYS; ret = -ERESTARTSYS;
...@@ -281,8 +286,8 @@ static const struct file_operations rpmsg_eptdev_fops = { ...@@ -281,8 +286,8 @@ static const struct file_operations rpmsg_eptdev_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = rpmsg_eptdev_open, .open = rpmsg_eptdev_open,
.release = rpmsg_eptdev_release, .release = rpmsg_eptdev_release,
.read = rpmsg_eptdev_read, .read_iter = rpmsg_eptdev_read_iter,
.write = rpmsg_eptdev_write, .write_iter = rpmsg_eptdev_write_iter,
.poll = rpmsg_eptdev_poll, .poll = rpmsg_eptdev_poll,
.unlocked_ioctl = rpmsg_eptdev_ioctl, .unlocked_ioctl = rpmsg_eptdev_ioctl,
.compat_ioctl = rpmsg_eptdev_ioctl, .compat_ioctl = rpmsg_eptdev_ioctl,
......
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