From: Bjorn Andersson <andersson@kernel.org>
To: Deepak Kumar Singh <quic_deesin@quicinc.com>
Cc: bjorn.andersson@linaro.org, arnaud.pouliquen@foss.st.com,
swboyd@chromium.org, quic_clew@quicinc.com,
mathieu.poirier@linaro.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org
Subject: Re: [PATCH V3 3/3] rpmsg: char: Add TIOCMGET/TIOCMSET ioctl support
Date: Tue, 1 Nov 2022 22:30:45 -0500 [thread overview]
Message-ID: <20221102033045.awxn5zlafdkatmta@builder.lan> (raw)
In-Reply-To: <1663133102-10671-4-git-send-email-quic_deesin@quicinc.com>
On Wed, Sep 14, 2022 at 10:55:02AM +0530, Deepak Kumar Singh wrote:
> Add TICOMGET and TIOCMSET ioctl support for rpmsg char device nodes
> to get/set the low level transport signals.
>
> Signed-off-by: Chris Lew <quic_clew@quicinc.com>
> Signed-off-by: Deepak Kumar Singh <quic_deesin@quicinc.com>
> ---
> drivers/rpmsg/rpmsg_char.c | 60 +++++++++++++++++++++++++++++++++++++++-------
> 1 file changed, 52 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c
> index 4f21891..1eb6e9d 100644
> --- a/drivers/rpmsg/rpmsg_char.c
> +++ b/drivers/rpmsg/rpmsg_char.c
> @@ -23,6 +23,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>
>
> @@ -68,6 +69,8 @@ struct rpmsg_eptdev {
> struct sk_buff_head queue;
> wait_queue_head_t readq;
>
> + u32 rsigs;
Please spell out remote_signals, or something like that.
> + bool sig_pending;
signals_pending
And please update the kernel-doc.
> };
>
> int rpmsg_chrdev_eptdev_destroy(struct device *dev, void *data)
> @@ -107,7 +110,22 @@ static int rpmsg_ept_cb(struct rpmsg_device *rpdev, void *buf, int len,
> skb_queue_tail(&eptdev->queue, skb);
> spin_unlock(&eptdev->queue_lock);
>
> - /* wake up any blocking processes, waiting for new data */
> + wake_up_interruptible(&eptdev->readq);
> +
> + return 0;
> +}
> +
> +static int rpmsg_flow_cb(struct rpmsg_device *rpdev, void *priv, bool enable)
Please add "ept" to the function name.
Regards,
Bjorn
> +{
> + struct rpmsg_eptdev *eptdev = priv;
> +
> + if (enable)
> + eptdev->rsigs = TIOCM_DSR | TIOCM_CTS;
> + else
> + eptdev->rsigs = 0;
> +
> + eptdev->sig_pending = true;
> +
> wake_up_interruptible(&eptdev->readq);
>
> return 0;
> @@ -144,6 +162,7 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp)
> return -EINVAL;
> }
>
> + ept->flow_cb = rpmsg_flow_cb;
> eptdev->ept = ept;
> filp->private_data = eptdev;
> mutex_unlock(&eptdev->ept_lock);
> @@ -164,6 +183,7 @@ static int rpmsg_eptdev_release(struct inode *inode, struct file *filp)
> eptdev->ept = NULL;
> }
> mutex_unlock(&eptdev->ept_lock);
> + eptdev->sig_pending = false;
>
> /* Discard all SKBs */
> skb_queue_purge(&eptdev->queue);
> @@ -277,6 +297,9 @@ static __poll_t rpmsg_eptdev_poll(struct file *filp, poll_table *wait)
> if (!skb_queue_empty(&eptdev->queue))
> mask |= EPOLLIN | EPOLLRDNORM;
>
> + if (eptdev->sig_pending)
> + mask |= EPOLLPRI;
> +
> mask |= rpmsg_poll(eptdev->ept, filp, wait);
>
> return mask;
> @@ -287,14 +310,35 @@ static long rpmsg_eptdev_ioctl(struct file *fp, unsigned int cmd,
> {
> struct rpmsg_eptdev *eptdev = fp->private_data;
>
> - if (cmd != RPMSG_DESTROY_EPT_IOCTL)
> - return -EINVAL;
> -
> - /* Don't allow to destroy a default endpoint. */
> - if (eptdev->default_ept)
> - return -EINVAL;
> + bool set;
> + u32 val;
> + int ret;
> +
> + switch (cmd) {
> + case TIOCMGET:
> + eptdev->sig_pending = false;
> + ret = put_user(eptdev->rsigs, (int __user *)arg);
> + break;
> + case TIOCMSET:
> + ret = get_user(val, (int __user *)arg);
> + if (ret)
> + break;
> + set = (val & (TIOCM_DTR | TIOCM_RTS)) ? true : false;
> + ret = rpmsg_set_flow_control(eptdev->ept, set);
> + break;
> + case RPMSG_DESTROY_EPT_IOCTL:
> + /* Don't allow to destroy a default endpoint. */
> + if (eptdev->default_ept) {
> + ret = -EINVAL;
> + break;
> + }
> + ret = rpmsg_chrdev_eptdev_destroy(&eptdev->dev, NULL);
> + break;
> + default:
> + ret = -EINVAL;
> + }
>
> - return rpmsg_chrdev_eptdev_destroy(&eptdev->dev, NULL);
> + return ret;
> }
>
> static const struct file_operations rpmsg_eptdev_fops = {
> --
> 2.7.4
>
next prev parent reply other threads:[~2022-11-02 3:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 5:24 [PATCH V3 0/3] rpmsg signaling/flowcontrol patches Deepak Kumar Singh
2022-09-14 5:25 ` [PATCH V3 1/3] rpmsg: core: Add signal API support Deepak Kumar Singh
2022-09-14 5:25 ` [PATCH V3 2/3] rpmsg: glink: Add support to handle signals command Deepak Kumar Singh
2022-11-02 3:25 ` Bjorn Andersson
2022-09-14 5:25 ` [PATCH V3 3/3] rpmsg: char: Add TIOCMGET/TIOCMSET ioctl support Deepak Kumar Singh
2022-11-02 3:30 ` Bjorn Andersson [this message]
2022-09-14 7:50 ` [PATCH V3 0/3] rpmsg signaling/flowcontrol patches Arnaud POULIQUEN
2022-09-19 20:15 ` Mathieu Poirier
2022-11-02 3:32 ` Bjorn Andersson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221102033045.awxn5zlafdkatmta@builder.lan \
--to=andersson@kernel.org \
--cc=arnaud.pouliquen@foss.st.com \
--cc=bjorn.andersson@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=quic_clew@quicinc.com \
--cc=quic_deesin@quicinc.com \
--cc=swboyd@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox