From patchwork Mon Jul 17 15:24:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 9845487 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 5A8446037F for ; Mon, 17 Jul 2017 15:25:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D82627480 for ; Mon, 17 Jul 2017 15:25:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 423D128464; Mon, 17 Jul 2017 15:25:25 +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 E02AF27480 for ; Mon, 17 Jul 2017 15:25:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751358AbdGQPZX (ORCPT ); Mon, 17 Jul 2017 11:25:23 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35017 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751335AbdGQPYw (ORCPT ); Mon, 17 Jul 2017 11:24:52 -0400 Received: by mail-wm0-f65.google.com with SMTP id u23so23732207wma.2; Mon, 17 Jul 2017 08:24:51 -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=Rp8otTFpHL53qyynJwMdVxpRcVGD6ewWk+pnyfYTu9c=; b=nTM8TPKlLcNBkR3g2EdSBUdo62UzjzJVxb90IZ2iPZEnm6Qs1tTVgrCXuVesccBpYo oJQRoV2a0NLs1Jx0NehquxG+uT1VP5Ny8/pr2Bjk1M6CCxjj2qoI/JwVIN2FX3jKvEcH dpD04CXB6BRMFCJmhcXdYRErLPPbnu7Z0QDtKBdfG8r3ryEWFTmFM59k+5IdezG2PqFu XIZWgjI3fg9vQeaTfMIi0U3Iax9tYI3ZplLBxqDKllWiPE8FrkS/PJvmuJL62LJW2ZAi lQ+Hp8aBMeXVM62G/5NujHh8/H0Ig6FTuqU2cewwqFkMvqiRhm7NsCO2vp2+TK205lve uswQ== 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=Rp8otTFpHL53qyynJwMdVxpRcVGD6ewWk+pnyfYTu9c=; b=V5ep6gaGK22Z0VybO+e7GKE7sN5krm4Gv0JtLs3RXTZudXSVvIpIO4jWPObvTOIrNn YpoI4uMaEkYlWxLJ0K4Z4GRuQLr2Q5NwIplM1JZaII8NinUalTkVe+b+LpkAKcX+iQtQ I3yXF1ERdY34J53p1V6PhFsJRxhRyo6PVWiOwJDPw7ZVWEOYo5BfBc079QpDjNtIMopo mvT2+ggvbdqouU0uzId3d4vXobKfKYdZ4/BV72WAmEzdPQxVmd2E8psdqCjFqqfTOHef QS2PsR36i/wOspY4yqTaKDAKoin6NKqyfmvXoplTaI2Yk0PwURUAoaH5xPm7hqpE/AXa rsSg== X-Gm-Message-State: AIVw1128nwJdZgCWjOH93hVj3gClw+XN2MhLBVlarRov2o+O582khj6C YnjL+3SEyKwv6/Ve4Rw= X-Received: by 10.28.69.201 with SMTP id l70mr4670133wmi.53.1500305090400; Mon, 17 Jul 2017 08:24:50 -0700 (PDT) Received: from groucho.site (ipbcc169a0.dynamic.kabel-deutschland.de. [188.193.105.160]) by smtp.gmail.com with ESMTPSA id 13sm10802102wrl.57.2017.07.17.08.24.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 08:24:49 -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: [RFC v2 2/6] serdev: add method to set parity Date: Mon, 17 Jul 2017 17:24:32 +0200 Message-Id: <1500305076-15570-3-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500305076-15570-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1500305076-15570-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 Reviewed-by: Rob Herring --- drivers/tty/serdev/core.c | 12 ++++++++++++ drivers/tty/serdev/serdev-ttyport.c | 17 +++++++++++++++++ include/linux/serdev.h | 4 ++++ 3 files changed, 33 insertions(+) diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index f71b473..1fbaa4c 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, + bool enable, bool odd) +{ + struct serdev_controller *ctrl = serdev->ctrl; + + if (!ctrl || !ctrl->ops->set_parity) + return -ENOTSUPP; + + return ctrl->ops->set_parity(ctrl, enable, odd); +} +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..9114956 100644 --- a/drivers/tty/serdev/serdev-ttyport.c +++ b/drivers/tty/serdev/serdev-ttyport.c @@ -195,6 +195,22 @@ 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, + bool enable, bool odd) +{ + 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 (enable) + ktermios.c_cflag |= PARENB; + if (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 +222,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..8b67fcd 100644 --- a/include/linux/serdev.h +++ b/include/linux/serdev.h @@ -90,6 +90,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 *, bool, bool); }; /** @@ -298,6 +299,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, + bool enable, bool odd); + /* * serdev hooks into TTY core */