Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp705037ybt; Fri, 26 Jun 2020 09:32:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdPlyUzogPMOoqMwVD8tOH/gdG51wceZNVdnBkVYHLcyGexZrUZC2D4jSpM6KJWAwmfa4Q X-Received: by 2002:a05:6402:2212:: with SMTP id cq18mr4412560edb.173.1593189153063; Fri, 26 Jun 2020 09:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593189153; cv=none; d=google.com; s=arc-20160816; b=Y01ph2QcuJf9PzjqAz77seYLQpdRufJUckzPiENiWTSaEUA/ra3nfVZfkdpxSuU7EQ Go1wJbO5qn2AuB+MPas9tEk8MSJ9pypiottdk5fzrP6lTSqWFft8xueXpjSStHQWpezv CIo/oe9HmwGzPzlUDS91wqGjgsvcHVgXsH9oM/nuj7am6xFi0oAZmvlFXomUGcz8omzA 2NLgmFmz/7N9HPV8edT/GDfOR12C9sdEq7cfIy8Qw4aZKa8mZUDHJQrtIyFAyHHzqvX6 12MfJCxbLVCFtexTwkzUv4i3zGO7/Ixf2a7+DEsYR4XksN/I4nygmsKC6LcEJBWO0QuU BrUg== 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=ew7j8axoniZS78Hi+Usc4yjaw6akE2hgX5f0A1DH+q8tXckRSYCeIcZ0NBiafUvzj+ Dc6hS0PE5RyzN5BDghO5rMveZB4Vbp2GHVcDDKjbkseitLcOXCb65CKrhvK9iVA6Xtt+ EscYEthisP1X8yBJX9b4qrpdI5G7ROzprdL8t8nJCJTz9RVVFz8dFrIEf3LurGoiUog3 qL73rovJ4UvM/LN8TS+ZaJ7rSH+/cR8aZ8FuSUmrWluP575EZBo43kLzAHV5eUgvtN6G ZX6AX10NB9+ixVdEREG16aRoKei/BKuSJIPu2ok5lwh4skYokMTwisquZr7LV9iaCNFf yLvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=NZ7B7MTp; 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 op7si10771785ejb.16.2020.06.26.09.32.10; Fri, 26 Jun 2020 09:32:33 -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=NZ7B7MTp; 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 S1729436AbgFZOre (ORCPT + 99 others); Fri, 26 Jun 2020 10:47:34 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:26022 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729374AbgFZOrY (ORCPT ); Fri, 26 Jun 2020 10:47:24 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1593182843; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=PWopmoPYmvBb6c4l4UvCri+PTIKOehyoMRDeBLGjvow=; b=NZ7B7MTp8zX/gzOqqT4JJs6msSeH3RrqIUkAInLNZ8p+Hnv6bdgvVp+KpZe9O0Hu/ZcWvP05 ER4NXaUNiH86XMlLtYTQVNqaO1C7BrZqQ7Op7+PjXE59hqLMGqQ1SEfLL56/hFjKDrS+wmit o6Or+v85MbCuiRaxm1OywdajHRI= X-Mailgun-Sending-Ip: 69.72.43.7 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-n14.prod.us-east-1.postgun.com with SMTP id 5ef60a79356bcc26ab20abab (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 26 Jun 2020 14:47:21 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id E21E4C433C6; Fri, 26 Jun 2020 14:47:20 +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, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from deesin-linux.qualcomm.com (blr-c-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.19.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 BD23FC433C8; Fri, 26 Jun 2020 14:47:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BD23FC433C8 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 Subject: [PATCH V6 3/4] rpmsg: char: Add TIOCMGET/TIOCMSET ioctl support Date: Fri, 26 Jun 2020 20:16:58 +0530 Message-Id: <1593182819-30747-4-git-send-email-deesin@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1593182819-30747-1-git-send-email-deesin@codeaurora.org> References: <1593182819-30747-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