Add TICOMGET and TIOCMSET ioctl support for rpmsg char device nodes
to get/set the low level transport signals.
Signed-off-by: Arun Kumar Neelakantam <[email protected]>
---
drivers/rpmsg/rpmsg_char.c | 53 +++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 50 insertions(+), 3 deletions(-)
diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
index eea5ebb..07bce51 100644
--- a/drivers/rpmsg/rpmsg_char.c
+++ b/drivers/rpmsg/rpmsg_char.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
/*
+ * Copyright (c) 2018, The Linux Foundation.
* Copyright (c) 2016, Linaro Ltd.
* Copyright (c) 2012, Michal Simek <[email protected]>
* Copyright (c) 2012, PetaLogix
@@ -19,6 +20,7 @@
#include <linux/rpmsg.h>
#include <linux/skbuff.h>
#include <linux/slab.h>
+#include <linux/termios.h>
#include <linux/uaccess.h>
#include <uapi/linux/rpmsg.h>
@@ -271,15 +273,60 @@ static __poll_t rpmsg_eptdev_poll(struct file *filp, poll_table *wait)
return mask;
}
+static int rpmsg_eptdev_tiocmset(struct file *fp, unsigned int cmd,
+ int __user *arg)
+{
+ struct rpmsg_eptdev *eptdev = fp->private_data;
+ u32 set, clear, val;
+ int ret;
+
+ ret = get_user(val, arg);
+ if (ret)
+ return ret;
+ set = clear = 0;
+ switch (cmd) {
+ case TIOCMBIS:
+ set = val;
+ break;
+ case TIOCMBIC:
+ clear = val;
+ break;
+ case TIOCMSET:
+ set = val;
+ clear = ~val;
+ break;
+ }
+
+ set &= TIOCM_DTR | TIOCM_RTS | TIOCM_CD | TIOCM_RI;
+ clear &= TIOCM_DTR | TIOCM_RTS | TIOCM_CD | TIOCM_RI;
+
+ return rpmsg_set_signals(eptdev->ept, set, clear);
+}
+
static long rpmsg_eptdev_ioctl(struct file *fp, unsigned int cmd,
unsigned long arg)
{
struct rpmsg_eptdev *eptdev = fp->private_data;
+ int ret;
- if (cmd != RPMSG_DESTROY_EPT_IOCTL)
- return -EINVAL;
+ switch (cmd) {
+ case TIOCMGET:
+ ret = rpmsg_get_signals(eptdev->ept);
+ if (ret >= 0)
+ ret = put_user(ret, (int __user *)arg);
+ break;
+ case TIOCMSET:
+ case TIOCMBIS:
+ case TIOCMBIC:
+ ret = rpmsg_eptdev_tiocmset(fp, cmd, (int __user *)arg);
+ break;
+ case RPMSG_DESTROY_EPT_IOCTL:
+ ret = rpmsg_eptdev_destroy(&eptdev->dev, NULL);
+ default:
+ ret = -EINVAL;
+ }
- return rpmsg_eptdev_destroy(&eptdev->dev, NULL);
+ return ret;
}
static const struct file_operations rpmsg_eptdev_fops = {
--
1.9.1
Hi Arun,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on linus/master]
[also build test WARNING on v5.4-rc8 next-20191122]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Arun-Kumar-Neelakantam/rpmsg-core-Add-signal-API-support/20191124-174653
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 6b8a794678763130b7e7d049985008641dc494e8
config: riscv-defconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=riscv
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <[email protected]>
All warnings (new ones prefixed by >>):
drivers/rpmsg/rpmsg_char.c: In function 'rpmsg_eptdev_ioctl':
>> drivers/rpmsg/rpmsg_char.c:324:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
ret = rpmsg_eptdev_destroy(&eptdev->dev, NULL);
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/rpmsg/rpmsg_char.c:325:2: note: here
default:
^~~~~~~
vim +324 drivers/rpmsg/rpmsg_char.c
305
306 static long rpmsg_eptdev_ioctl(struct file *fp, unsigned int cmd,
307 unsigned long arg)
308 {
309 struct rpmsg_eptdev *eptdev = fp->private_data;
310 int ret;
311
312 switch (cmd) {
313 case TIOCMGET:
314 ret = rpmsg_get_signals(eptdev->ept);
315 if (ret >= 0)
316 ret = put_user(ret, (int __user *)arg);
317 break;
318 case TIOCMSET:
319 case TIOCMBIS:
320 case TIOCMBIC:
321 ret = rpmsg_eptdev_tiocmset(fp, cmd, (int __user *)arg);
322 break;
323 case RPMSG_DESTROY_EPT_IOCTL:
> 324 ret = rpmsg_eptdev_destroy(&eptdev->dev, NULL);
325 default:
326 ret = -EINVAL;
327 }
328
329 return ret;
330 }
331
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email protected] Intel Corporation