Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp66117ybc; Fri, 22 Nov 2019 02:08:52 -0800 (PST) X-Google-Smtp-Source: APXvYqwZeGwbIEuIbhISC8R8zuuTv//wV76z3SSkoRwfClJd7Ewb7qU7X7+tO+2YOAOEk6/clQr1 X-Received: by 2002:a17:906:158f:: with SMTP id k15mr20603211ejd.226.1574417332496; Fri, 22 Nov 2019 02:08:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574417332; cv=none; d=google.com; s=arc-20160816; b=do+gMRPLr2wLJ6+mDbWcvg4BO8yQ5l3Ktn6GnQZO6lzRkdoc8/JwPuEBdzPZkLuVvh k0bpooJEmRVctDQjczFYg1k6bmaLEdMAIxeb05YMrG9QeQmjpwQRrZEkzMQFZmGToiGI hmhmO7RrZR4wgHJlWzF5vNIs3r3MFLrzX+3t00umGUSUVuVa0JRH6jSlQeSwph41QPYW QwTlSrrmaKmhsSholfJzy+V9d8EN7sLhb1fP1Sn/lgYiPI1Y4KmfhLC0m9j51lysX4wy GUGXOLyiZqwH+rRFKwPPUXMIxgWNCTdf0WLxhLKd8NAvWEzL7iINUaUtHWTuMXDUBGo9 fhbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:references:in-reply-to :message-id:date:subject:cc:to:from:dmarc-filter:dkim-signature :dkim-signature; bh=C6eDV9qKwzKm1+KZmUDSoYh01HfLQYJ7c1La0IApW4A=; b=KYGN0j/umF80V+4PSLDVsLjE2OI80t87Qot460wq0U6WN6S9H4in1b6KXZ+yxqN40B eHLEt6Gjm73+CUTXrNxFZR+O+iI1b0F+NwmOdI2ckk0BA/7K5lMmNkoN+wmqyZVQmPW5 P/oOTmcLU1P5K3ao1ZfHrNfHRkMGaTpwQbzYyH0MpNq19DuIRqsJpHaC8yqdhHf0gplh wDwyxTAb/Su0fpklZlViDPzL9aCbPG/8Z3euHksesYAVUzW3KfRK74K++nGb5kJDZ0ZO sCTiuc4fvvD/ukSbnrqCXh3uYlhTjyRcpJ76qAY264n5vdXQl2hc2GiXdj6j6iy1zPZs jVsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=zsmsymrwgfyinv5wlfyidntwsjeeldzt header.b="TUM/C1+U"; dkim=pass header.i=@amazonses.com header.s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx header.b=W1tRHPCP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si3654050ejk.66.2019.11.22.02.08.28; Fri, 22 Nov 2019 02:08:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=zsmsymrwgfyinv5wlfyidntwsjeeldzt header.b="TUM/C1+U"; dkim=pass header.i=@amazonses.com header.s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx header.b=W1tRHPCP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727236AbfKVKHE (ORCPT + 99 others); Fri, 22 Nov 2019 05:07:04 -0500 Received: from a27-188.smtp-out.us-west-2.amazonses.com ([54.240.27.188]:59618 "EHLO a27-188.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726568AbfKVKHC (ORCPT ); Fri, 22 Nov 2019 05:07:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1574417221; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; bh=ZSU4qhbMLCVW9Iayxgvc4RagwbtPPwu8ndEibWAZEOk=; b=TUM/C1+UBZT3F2o3vw1TKwH/Ur7SD6tVrdjm1JuY0aeKUIh+2K8eki2O3fR787kI BShe47HzhxLSxQtoOFRjK1Km9OaTwMmb5ekzUll3zPOynO/m7OFuYZAOUYCLuRMPevv G2sD/67D+JRj/Do8X/Gv19aqh7Sqwhla8YeWAL5c= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=gdwg2y3kokkkj5a55z2ilkup5wp5hhxx; d=amazonses.com; t=1574417221; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Feedback-ID; bh=ZSU4qhbMLCVW9Iayxgvc4RagwbtPPwu8ndEibWAZEOk=; b=W1tRHPCPsRAxEf7cDEnn/MCaUHmWGh1Mo5NA5d8DkrCCih2A8VA0AgPfyFsTALF6 kFJrrCp04BgRO5dmBtJ6jzVlPjLUFmTf5spJ/QMXjTTCHoA6kwZce7cmadDxQrddMW7 EiaWDR8zPBew1UWpQ+aIbqfe8DQ3liRwttH7d8XU= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4E3A0C3275E Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=aneela@codeaurora.org From: Arun Kumar Neelakantam To: ohad@wizery.com, bjorn.andersson@linaro.org, clew@codeaurora.org, sricharan@codeaurora.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Arun Kumar Neelakantam Subject: [RESEND PATCH V4 3/4] rpmsg: char: Add TIOCMGET/TIOCMSET ioctl support Date: Fri, 22 Nov 2019 10:07:01 +0000 Message-ID: <0101016e929447ec-0bd67225-9152-4bcd-945e-ebd39a0110d5-000000@us-west-2.amazonses.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1574417197-27817-1-git-send-email-aneela@codeaurora.org> References: <1574417197-27817-1-git-send-email-aneela@codeaurora.org> X-SES-Outgoing: 2019.11.22-54.240.27.188 Feedback-ID: 1.us-west-2.CZuq2qbDmUIuT3qdvXlRHZZCpfZqZ4GtG9v3VKgRyF0=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 * Copyright (c) 2012, PetaLogix @@ -19,6 +20,7 @@ #include #include #include +#include #include #include @@ -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