From patchwork Fri Oct 5 06:59:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arun Kumar Neelakantam X-Patchwork-Id: 10627413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9D681515 for ; Fri, 5 Oct 2018 07:00:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1FA3292F4 for ; Fri, 5 Oct 2018 07:00:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5C7A292FF; Fri, 5 Oct 2018 07:00:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4AFB292F4 for ; Fri, 5 Oct 2018 07:00:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728099AbeJEN5T (ORCPT ); Fri, 5 Oct 2018 09:57:19 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:58492 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727133AbeJEN5S (ORCPT ); Fri, 5 Oct 2018 09:57:18 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 84D8C607DC; Fri, 5 Oct 2018 06:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1538722799; bh=LM0Z912UnjzQdkrerq8VV1RLFn9LRrNlDEKL+aykm30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOIxhK6c0XLpmoGGgue0qQcsDZ/oHCG/lPrXKrR8X9TBO9PQVJDaDwNgTPUC0xCHQ uoFKgkHxt25wKfkR0Hb6fidG5SBs4R6SUBcT3v2qp4hOQnsvJ9WQcfGoWJs6pTDqF7 Kt3ennh/DlKmjDwGL6B/d14po6+C7f5M2xLDAFgM= 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@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 86F3A60C1B; Fri, 5 Oct 2018 06:59:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1538722799; bh=LM0Z912UnjzQdkrerq8VV1RLFn9LRrNlDEKL+aykm30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YOIxhK6c0XLpmoGGgue0qQcsDZ/oHCG/lPrXKrR8X9TBO9PQVJDaDwNgTPUC0xCHQ uoFKgkHxt25wKfkR0Hb6fidG5SBs4R6SUBcT3v2qp4hOQnsvJ9WQcfGoWJs6pTDqF7 Kt3ennh/DlKmjDwGL6B/d14po6+C7f5M2xLDAFgM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 86F3A60C1B Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.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 V3 3/4] rpmsg: char: Add TIOCMGET/TIOCMSET ioctl support Date: Fri, 5 Oct 2018 12:29:35 +0530 Message-Id: <1538722776-13648-4-git-send-email-aneela@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1538722776-13648-1-git-send-email-aneela@codeaurora.org> References: <1538722776-13648-1-git-send-email-aneela@codeaurora.org> Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 a76b963..16978f7b 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 @@ -266,15 +268,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) + 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 = {