Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp587505pxk; Wed, 2 Sep 2020 09:26:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweNumzejYW3JcDzgzkfzBpeMRfbOmecfBIL07QCyEaTSOajZtT/AlVvd4xxHner7am9/rU X-Received: by 2002:a17:906:d9da:: with SMTP id qk26mr765839ejb.435.1599063964793; Wed, 02 Sep 2020 09:26:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599063964; cv=none; d=google.com; s=arc-20160816; b=dKnqrtnwDiYMHKIRnGMDMQmQsiyBCcEvyLL6AY4TJAA1DfNgDqbrPqGp+1dAhygw0q Qu4zwfiroqV6rvxmOV1iLo6be3MJ5D+rqpxu+XWuyGKlubxG9WypZNG7hHqiFwfXwknK kmLrjzUh38JWVgbCHKCWXYIEKCZGTRoUa5+9FMwOktKUOiOxGP0g4z9685E8GvJLOZzX mPg2/SY5ggvtAasRNExUyG4TLucHK+q+nczObwLLQqwkuUNQBf9wAwQvCwE7hmC27lbF 1aQBNYfm3BF6xr1IB03hccX62DgEqVS/3ZdGDNP0am7XTAkO4AThxaf8NFO/FI58M29k 0liA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dmarc-filter:dkim-signature; bh=PWopmoPYmvBb6c4l4UvCri+PTIKOehyoMRDeBLGjvow=; b=OPUwHBIIaXpUfca4t31T+gT6BX8elMFLliLhX9j+boBF6yzE14EvaNO7FjYcsJDxkr jxSlvAnf0c02hCoHekmnUAsha0FNsHT1dijaWqkgzaotdKn3gC3KJlRBnz/VQ9H7/41N tYwiAGXI6yvO07hUTb8ucFALONZpmHsDqamvslQqoSD2Mx+Mq5uxw1vtbV7LQu4sCtQT dxHFOK1cSln9GQ/uFm2obXTA/YLCSTNrdOPFrftzR9CBAKMSBCNIBiu1Itso4jIbl4sW AKHDO4i1HfS3abQGHyYdk9b7Symqc0oq29wtwYYHOfEejN1DtSVRxscP6WuN3zQOYpGE pEtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b="KG/WQjFp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si2931279edn.432.2020.09.02.09.25.40; Wed, 02 Sep 2020 09:26:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b="KG/WQjFp"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727804AbgIBQYr (ORCPT + 99 others); Wed, 2 Sep 2020 12:24:47 -0400 Received: from mail29.static.mailgun.info ([104.130.122.29]:32420 "EHLO mail29.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727968AbgIBQYn (ORCPT ); Wed, 2 Sep 2020 12:24:43 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1599063882; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=PWopmoPYmvBb6c4l4UvCri+PTIKOehyoMRDeBLGjvow=; b=KG/WQjFp4gkPu57jDBvbhybLTQ2owT6mNgKjt+klZyX0GjHUtT720d9sTi3Yr01MH2JKZdeY G2xctz/9pl37uV3bAKf75HybdYn16yyJlPLthDfCsUtxvXLxgtqCGySqH8Ozqq9TBq9GUe0u pVPfqAqgrU4nXwbIVQ6wmIdeWw8= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n03.prod.us-west-2.postgun.com with SMTP id 5f4fc74025e1ee7586f57303 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 02 Sep 2020 16:24:32 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id A4F05C43391; Wed, 2 Sep 2020 16:24:32 +0000 (UTC) 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 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from deesin-linux.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: deesin) by smtp.codeaurora.org (Postfix) with ESMTPSA id ABF4DC433CA; Wed, 2 Sep 2020 16:24:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org ABF4DC433CA 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=deesin@codeaurora.org From: Deepak Kumar Singh To: bjorn.andersson@linaro.org, clew@codeaurora.org, mathieu.poirier@linaro.org Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Arun Kumar Neelakantam , Deepak Kumar Singh , Ohad Ben-Cohen Subject: [PATCH V7 3/4] rpmsg: char: Add TIOCMGET/TIOCMSET ioctl support Date: Wed, 2 Sep 2020 21:54:06 +0530 Message-Id: <1599063847-2347-4-git-send-email-deesin@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599063847-2347-1-git-send-email-deesin@codeaurora.org> References: <1599063847-2347-1-git-send-email-deesin@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arun Kumar Neelakantam Add TICOMGET and TIOCMSET ioctl support for rpmsg char device nodes to get/set the low level transport signals. Signed-off-by: Deepak Kumar Singh Signed-off-by: Arun Kumar Neelakantam --- drivers/rpmsg/rpmsg_char.c | 54 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 4bbbacd..43ceac0 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 @@ -269,15 +271,61 @@ 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); + break; + default: + ret = -EINVAL; + } - return rpmsg_eptdev_destroy(&eptdev->dev, NULL); + return ret; } static const struct file_operations rpmsg_eptdev_fops = { -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project