summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorArnaud Pouliquen <arnaud.pouliquen@foss.st.com>2021-03-11 15:04:13 +0100
committerBjorn Andersson <bjorn.andersson@linaro.org>2021-03-17 14:16:58 -0500
commit964e8bedd5a13a662e8e418ed763351c07d0dac7 (patch)
tree03a77783305ceb4456dca7f2323dabcc6584ca68 /drivers
parentc486682ae1e2b149add22f44cf413b3103e3ef39 (diff)
downloadlinux-964e8bedd5a13a662e8e418ed763351c07d0dac7.tar.gz
rpmsg: char: Return an error if device already open
The rpmsg_create_ept function is invoked when the device is opened. As only one endpoint must be created per device. It is not possible to open the same device twice. But there is nothing to prevent multi open. Return -EBUSY when device is already opened to have a generic error instead of relying on the back-end to potentially detect the error. Without this patch for instance the GLINK driver return -EBUSY while the virtio bus return -ENOSPC. Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Link: https://lore.kernel.org/r/20210311140413.31725-7-arnaud.pouliquen@foss.st.com Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rpmsg/rpmsg_char.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
index 95a65f7a9d8d..2bebc9b2d163 100644
--- a/drivers/rpmsg/rpmsg_char.c
+++ b/drivers/rpmsg/rpmsg_char.c
@@ -127,6 +127,9 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp)
struct rpmsg_device *rpdev = eptdev->rpdev;
struct device *dev = &eptdev->dev;
+ if (eptdev->ept)
+ return -EBUSY;
+
get_device(dev);
ept = rpmsg_create_ept(rpdev, rpmsg_ept_cb, eptdev, eptdev->chinfo);