Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp251235ybk; Tue, 12 May 2020 22:14:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznemiHEru8VqpJXs423K64rKx9N4Q5/58FWEh2RllZBqjK+1JbRcGGhYq/6SqqbkrQrg97 X-Received: by 2002:a17:907:1106:: with SMTP id qu6mr2828651ejb.321.1589346886679; Tue, 12 May 2020 22:14:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589346886; cv=none; d=google.com; s=arc-20160816; b=ZwqoeO91bkMEZpo4MlbVshNBQBbT2vBrINzmB+InjThJxaN33KkJBBOwPE7jviuLT1 6VJa5Upr2jvedvJOnjov51xovzC0Qv8iH0TpmXv1PMxigCWCwKCdufuN3M1ldbBLc4W6 O5jinH7epW7yNEFToNNyufQX7mR4vZ+DI5QO/emtcZi8xJDoAICM9wmP9fIlW2Jr3XPq lXU1VcKEBHFLqWRfq1ZNpLGH4J1eEwKU7kbPWFWE0Z8xCAxUAc4m3K8VoT84SwLdx4Bn eVapHTG/t0rHxPv3TsNdz9002poWzymwhZPn02ez2jfBxtyKp1rDPzrXkhTUHq+wyLHM U/cA== 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=XHvH4/A1njFNZl1Mafe1tqfSctwnLuF3Eo8a9pJVw78=; b=bPOybg1P3AyGmmGGpPDSXGT6B+r2i6vQ3QXzkCojaOIje5aZZZkWeraJYpQCKRH1rE Uo6CH+7vHh00I3S4bFu/Moqe1kZrfm9GHZPjPyD8Dt5Ll8z7L0WyFmCD6JVvlMLJuub8 6HU1rtaSGBKkErOCd7ZiKXjQ43Ej5VAwjKoo6AZN1U9e6Elv4SW6tYRng96BUiiskYXN 6Z8ro/+PFATAb/oTXdRZd9EnB3L3IQxKu6b3V4TGQ13z9t5g6RMq7eg7IMxzZVwoWtMX 8oQwuunle5DoWywKsKn4B73IfmUsI0kDVbh+1j6xSeGVGAX6PCh2LMy91YYwvEhkyAFk lZNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=lYp2V5XH; 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 l11si8692014eja.20.2020.05.12.22.14.24; Tue, 12 May 2020 22:14:46 -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=lYp2V5XH; 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 S1729092AbgEMFLv (ORCPT + 99 others); Wed, 13 May 2020 01:11:51 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:57244 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726220AbgEMFLv (ORCPT ); Wed, 13 May 2020 01:11:51 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1589346710; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=XHvH4/A1njFNZl1Mafe1tqfSctwnLuF3Eo8a9pJVw78=; b=lYp2V5XHlhriYHGycHBpJnS4uvrvJ/h8AgSiSJFcQ7WLwELXyUOg76LinVF00o6Lcx1OhTyB zt2SiTgApP3IeJzzYq32wFBsNgCQOH626BvR4Un/fkR4xHjbiPmqFxrZRYQbo6OIRIn0YEZO +4DyO0RFwk4Ua2TKzivGZorDGnQ= X-Mailgun-Sending-Ip: 104.130.122.27 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 mxa.mailgun.org with ESMTP id 5ebb8188.7f012f4cbf80-smtp-out-n01; Wed, 13 May 2020 05:11:36 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id EA92BC433CB; Wed, 13 May 2020 05:11:35 +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=unavailable autolearn_force=no version=3.4.0 Received: from aneelaka-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: aneela) by smtp.codeaurora.org (Postfix) with ESMTPSA id 8C6E2C433BA; Wed, 13 May 2020 05:11:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 8C6E2C433BA 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: [PATCH V4 3/4] rpmsg: char: Add TIOCMGET/TIOCMSET ioctl support Date: Wed, 13 May 2020 10:41:10 +0530 Message-Id: <1589346671-15226-4-git-send-email-aneela@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589346671-15226-1-git-send-email-aneela@codeaurora.org> References: <1589346671-15226-1-git-send-email-aneela@codeaurora.org> 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 4bbbacd..e2f92f3 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,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 = { -- 2.7.4