Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2756799pxb; Mon, 1 Nov 2021 00:52:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgMdO3rm91tLsD2iiFFS0FkfK2AD69eOjfVlVlpipn9FJW1rzt0qy0BLwzTWt7oXY4ODsc X-Received: by 2002:a5d:8242:: with SMTP id n2mr19441548ioo.170.1635753141550; Mon, 01 Nov 2021 00:52:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635753141; cv=none; d=google.com; s=arc-20160816; b=PsqVTIcYbew2fPEPD9EhIaRCFAUNNakoJO7Mb/pTbY8nz2zU/ZoCdf1PyQuB1f7o4F 93MBXQ3aa4fFJN9lL39I6bh5D4N0IkuyoWu24cYnjRzvOJ495ryd4JAzhIDeK5T1obwb ogCc8Ft4N35rXFHQVpatR9RIHYcWq8VBsOO2F1U0BUIrZt9Nff3Dp90XRVq3BOAgPIIG x6aspQbch40mLBoeEKz1uMWJYuyMGBII/iazf2bR1ZQCa8Rcbu4j2PxXwBvh3k+l9P2e B1M4IKoOIUTxs2kQ3s9t48EGzU+phg5niaTgrqtgeNzeQrYtNYK36j+Ka9Q4MokKIbp7 I2pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from:dmarc-filter :sender:dkim-signature; bh=GmzcMYsd0e4TNLGroTL3Y93GiSpZvjUfFRe6uyJXVgE=; b=uBGVE9XnkoVsmTDZfwsi6uNtNf/BhsOmOteeIivce1HBj7ltz4djkaPO5MSv/QT2lG L3I1WajuKUb5R9DQ+c1GDr1clv4clCQHekmptXntUl8VxIQRt/GDH75pN0QrYzjftOkO 3gJW0dz9M0VCMaVbyQ5n8wv7Wy4HH5J4yLZDPgpVCa+xdpaAQs1XBbm9nctf5u7kbEEc hP1KNerg1ivX2k2ur910juEqKSJGCkV+tHZ4IRgHygVI7dGmYzY4xXm82DAkePyncnM+ pvCLycww/pMAWbGYIaOr6tRh/UpGqAtdd0SzZhz072IS6AviFT70v9tFMEVefa+FQD38 a+hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=mXnEMf7s; 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 h5si17197910ila.103.2021.11.01.00.52.10; Mon, 01 Nov 2021 00:52:21 -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=pass header.i=@mg.codeaurora.org header.s=smtp header.b=mXnEMf7s; 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 S231271AbhKAHxm (ORCPT + 99 others); Mon, 1 Nov 2021 03:53:42 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:60024 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231133AbhKAHxi (ORCPT ); Mon, 1 Nov 2021 03:53:38 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1635753065; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=GmzcMYsd0e4TNLGroTL3Y93GiSpZvjUfFRe6uyJXVgE=; b=mXnEMf7sPqWKRgGN8SF1zzg01v15M+hTlshZWQw0S3B5Rcvtbu6ynf0xLvG+duHbv8LZTkRq V+5wpp26HdcQ2FjYoKlPzIaFonUKOO4Lra7eKRsXeajhve3Tn0mIYmj/r5RRC+OfBTHmXNnF PikQm9KT//wsME8nvmxPOX+3Y4I= 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-n03.prod.us-east-1.postgun.com with SMTP id 617f9c62900d71ea1ec63265 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 01 Nov 2021 07:50:58 GMT Sender: zijuhu=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 748FDC4360C; Mon, 1 Nov 2021 07:50:57 +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=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from zijuhu-gv.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zijuhu) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7BFBDC4338F; Mon, 1 Nov 2021 07:50:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 7BFBDC4338F 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=fail smtp.mailfrom=codeaurora.org From: Zijun Hu To: robh@kernel.org, gregkh@linuxfoundation.org, jirislaby@kernel.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, zijuhu@codeaurora.org, Zijun Hu Subject: [PATCH v1] serdev: Add interface serdev_device_ioctl Date: Mon, 1 Nov 2021 15:50:48 +0800 Message-Id: <1635753048-5289-1-git-send-email-zijuhu@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zijun Hu For serdev_device which is mounted at virtual tty port, tty ioctl() maybe be used to make serdev_device ready to talk with tty port, so add interface serdev_device_ioctl(). Signed-off-by: Zijun Hu --- drivers/tty/serdev/core.c | 11 +++++++++++ drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++ include/linux/serdev.h | 9 +++++++++ 3 files changed, 32 insertions(+) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index f1324fe99378..c0f6cd64716b 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -405,6 +405,17 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) } EXPORT_SYMBOL_GPL(serdev_device_set_tiocm); +int serdev_device_ioctl(struct serdev_device *serdev, unsigned int cmd, unsigned long arg) +{ + struct serdev_controller *ctrl = serdev->ctrl; + + if (!ctrl || !ctrl->ops->ioctl) + return -EOPNOTSUPP; + + return ctrl->ops->ioctl(ctrl, cmd, arg); +} +EXPORT_SYMBOL_GPL(serdev_device_ioctl); + static int serdev_drv_probe(struct device *dev) { const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver); diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c index d367803e2044..fc6797b26b30 100644 --- a/drivers/tty/serdev/serdev-ttyport.c +++ b/drivers/tty/serdev/serdev-ttyport.c @@ -247,6 +247,17 @@ static int ttyport_set_tiocm(struct serdev_controller *ctrl, unsigned int set, u return tty->ops->tiocmset(tty, set, clear); } +static int ttyport_ioctl(struct serdev_controller *ctrl, unsigned int cmd, unsigned long arg) +{ + struct serport *serport = serdev_controller_get_drvdata(ctrl); + struct tty_struct *tty = serport->tty; + + if (!tty->ops->ioctl) + return -EOPNOTSUPP; + + return tty->ops->ioctl(tty, cmd, arg); +} + static const struct serdev_controller_ops ctrl_ops = { .write_buf = ttyport_write_buf, .write_flush = ttyport_write_flush, @@ -259,6 +270,7 @@ static const struct serdev_controller_ops ctrl_ops = { .wait_until_sent = ttyport_wait_until_sent, .get_tiocm = ttyport_get_tiocm, .set_tiocm = ttyport_set_tiocm, + .ioctl = ttyport_ioctl, }; struct device *serdev_tty_port_register(struct tty_port *port, diff --git a/include/linux/serdev.h b/include/linux/serdev.h index 3368c261ab62..3b37bbb187c2 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -91,6 +91,7 @@ struct serdev_controller_ops { void (*wait_until_sent)(struct serdev_controller *, long); int (*get_tiocm)(struct serdev_controller *); int (*set_tiocm)(struct serdev_controller *, unsigned int, unsigned int); + int (*ioctl)(struct serdev_controller *ctrl, unsigned int cmd, unsigned long arg); }; /** @@ -201,6 +202,7 @@ int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_ void serdev_device_wait_until_sent(struct serdev_device *, long); int serdev_device_get_tiocm(struct serdev_device *); int serdev_device_set_tiocm(struct serdev_device *, int, int); +int serdev_device_ioctl(struct serdev_device *serdev, unsigned int cmd, unsigned long arg); void serdev_device_write_wakeup(struct serdev_device *); int serdev_device_write(struct serdev_device *, const unsigned char *, size_t, long); void serdev_device_write_flush(struct serdev_device *); @@ -254,6 +256,13 @@ static inline int serdev_device_set_tiocm(struct serdev_device *serdev, int set, { return -ENOTSUPP; } + +static inline int serdev_device_ioctl(struct serdev_device *serdev, + unsigned int cmd, unsigned long arg) +{ + return -EOPNOTSUPP; +} + static inline int serdev_device_write(struct serdev_device *sdev, const unsigned char *buf, size_t count, unsigned long timeout) { -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project