From patchwork Wed Aug 16 13:22:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 9903787 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF7D060231 for ; Wed, 16 Aug 2017 13:22:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E21F7289E7 for ; Wed, 16 Aug 2017 13:22:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6F2D289EE; Wed, 16 Aug 2017 13:22:43 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 7E15D289E7 for ; Wed, 16 Aug 2017 13:22:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751642AbdHPNWm (ORCPT ); Wed, 16 Aug 2017 09:22:42 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:38049 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751461AbdHPNWl (ORCPT ); Wed, 16 Aug 2017 09:22:41 -0400 Received: by mail-wr0-f193.google.com with SMTP id g32so3045920wrd.5; Wed, 16 Aug 2017 06:22:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=+wDq1ar/HKFgm2h7Ak0SNhVUHeD4TWqQCnLihQNgSSE=; b=Cr4jVldjOOoqiZnoAR/MvKPy1c7R4+jFJpkz8r667Re2oQQ5D69AY7K6aWO7JQO8if PMBZw0mt+yu7AA4CXoYYO4WFPURzSBieUuyOyEWnxi+nqkEuG1HUvROh8KVdfeoUGnsx 0s4K7mE7L95Yqq4hsaC+kTFZyDS8BXKT6ikHkGFWKqZ27NSFc7hC7dAg5olinPYztIxT 0mOStF2Vs/+uGeytr6HPtcgh5AbP51hkRPPcjMSEpz24SzAGyzYdOBFKtXjCZvRcj9a5 piszQ6TRXv1svEv1Z4EYLalUR7jWp56qPz5uaC78lYvL141n8DMPWTq6V9WjkI92l9Xq O8gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=+wDq1ar/HKFgm2h7Ak0SNhVUHeD4TWqQCnLihQNgSSE=; b=Q8OwdIoCdg7NpPqsIQHJ9c/I/oszLvYwYrT+Ox/yBTGvXAwpVxRFfqusp2VdbEnKZe EY3z28hsshQXlsKJUMmzzTYkgck+AfSuYgNpYX+00/j0b2R0svAyltqtMKXo3x9Q0HBs 2cmtq1mWa1fgSt5wh/JFRaddmY5jf99WbFXVLb7o64xsbBbLZf3vSYe9H5ar5kM7tWoD Av74OQDQ4hH2U7d1R2KcGmrEM8ZnV2m009qssDrJj4C0bc9cHNoMM9zqDnDIvJuSHy8a GL8Y5aRScDblBF5On/v1usScq2bDa9vVvOWDHPOo3SKPI03YsCqNcBpvU9HzdkP+KC3z CVOA== X-Gm-Message-State: AHYfb5gEXxSWsZXPzHcdq/2reaW6I6bhyQIYkgtr7pzARXYgglhn1kiS tqACBFw3kGj3c4fHxy0= X-Received: by 10.28.228.84 with SMTP id b81mr1322795wmh.133.1502889759844; Wed, 16 Aug 2017 06:22:39 -0700 (PDT) Received: from groucho.site (ipbcc2817c.dynamic.kabel-deutschland.de. [188.194.129.124]) by smtp.gmail.com with ESMTPSA id m130sm1054894wma.27.2017.08.16.06.22.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Aug 2017 06:22:39 -0700 (PDT) From: Ulrich Hecht To: linux-serial@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, magnus.damm@gmail.com, laurent.pinchart@ideasonboard.com, wsa@the-dreams.de, robh@kernel.org, peda@axentia.se, geert@linux-m68k.org, linux-i2c@vger.kernel.org, Ulrich Hecht Subject: [PATCH 1/6] serdev: add method to set parity Date: Wed, 16 Aug 2017 15:22:23 +0200 Message-Id: <1502889748-31499-2-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502889748-31499-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1502889748-31499-1-git-send-email-ulrich.hecht+renesas@gmail.com> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adds serdev_device_set_parity() and an implementation for ttyport. Signed-off-by: Ulrich Hecht --- drivers/tty/serdev/core.c | 12 ++++++++++++ drivers/tty/serdev/serdev-ttyport.c | 18 ++++++++++++++++++ include/linux/serdev.h | 10 ++++++++++ 3 files changed, 40 insertions(+) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index ae1aaa0..8491056 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c @@ -242,6 +242,18 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear) } EXPORT_SYMBOL_GPL(serdev_device_set_tiocm); +int serdev_device_set_parity(struct serdev_device *serdev, + enum serdev_parity parity) +{ + struct serdev_controller *ctrl = serdev->ctrl; + + if (!ctrl || !ctrl->ops->set_parity) + return -ENOTSUPP; + + return ctrl->ops->set_parity(ctrl, parity); +} +EXPORT_SYMBOL_GPL(serdev_device_set_parity); + 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 302018d..2883f12 100644 --- a/drivers/tty/serdev/serdev-ttyport.c +++ b/drivers/tty/serdev/serdev-ttyport.c @@ -195,6 +195,23 @@ static int ttyport_set_tiocm(struct serdev_controller *ctrl, unsigned int set, u return tty->driver->ops->tiocmset(tty, set, clear); } +static int ttyport_set_parity(struct serdev_controller *ctrl, + enum serdev_parity parity) +{ + struct serport *serport = serdev_controller_get_drvdata(ctrl); + struct tty_struct *tty = serport->tty; + struct ktermios ktermios = tty->termios; + + ktermios.c_cflag &= ~(PARENB | PARODD); + if (parity != SERDEV_PARITY_NONE) { + ktermios.c_cflag |= PARENB; + if (parity == SERDEV_PARITY_ODD) + ktermios.c_cflag |= PARODD; + } + + return tty_set_termios(tty, &ktermios); +} + static const struct serdev_controller_ops ctrl_ops = { .write_buf = ttyport_write_buf, .write_flush = ttyport_write_flush, @@ -206,6 +223,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, + .set_parity = ttyport_set_parity, }; struct device *serdev_tty_port_register(struct tty_port *port, diff --git a/include/linux/serdev.h b/include/linux/serdev.h index e69402d..8f60f11 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -76,6 +76,12 @@ static inline struct serdev_device_driver *to_serdev_device_driver(struct device return container_of(d, struct serdev_device_driver, driver); } +enum serdev_parity { + SERDEV_PARITY_NONE, + SERDEV_PARITY_EVEN, + SERDEV_PARITY_ODD, +}; + /* * serdev controller structures */ @@ -90,6 +96,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 (*set_parity)(struct serdev_controller *, enum serdev_parity); }; /** @@ -298,6 +305,9 @@ static inline int serdev_device_set_rts(struct serdev_device *serdev, bool enabl return serdev_device_set_tiocm(serdev, 0, TIOCM_RTS); } +int serdev_device_set_parity(struct serdev_device *serdev, + enum serdev_parity parity); + /* * serdev hooks into TTY core */