From patchwork Wed Jun 14 14:38:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Hecht X-Patchwork-Id: 775811 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wnq5W73cTz9s65 for ; Thu, 15 Jun 2017 00:39:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="s1SAprQd"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751980AbdFNOjK (ORCPT ); Wed, 14 Jun 2017 10:39:10 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36302 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751869AbdFNOjI (ORCPT ); Wed, 14 Jun 2017 10:39:08 -0400 Received: by mail-lf0-f68.google.com with SMTP id x81so368182lfb.3; Wed, 14 Jun 2017 07:39:06 -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=s1SAprQdHtHTsCcGXit8V38SIWFte39nUhoELUloaOmGaAzSB3bma9gHPc4QgRBPwD XGQnlIgOu0QeCWlVKE9hMb7ZBOZsIf+98k2O9rL8O+iHRtXlRw60tZEweyoxk4cJTFmf XQ8QgIS+Q7SHoT0RRjduR/i5tcObaSbjox9TbPMVbCRMPNvtOSOteytGL9byy0rEDSOf lBlrkOil0lv75B1UqaGackr4qLO1LpCtiYiWtQy4J1jP1zTg/S9hZ5UUE1GgvOt6An0u dkcc5AXUv91CT2Zu53CGLfLSfjRXCj50KG6UCEUGob6X12n3Rj/we1NTYluRrTrsxXhk 8DUw== 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=ae6s7i4jYDR1rtO2UGRYcr8ZJxlwZgt2t+b9maDK7huQYMgcin08JRGBUM3IvWdy+s YHHtWk2ouWqtgd/QMgh9z/EPTqltDVFzvr1KU/GaP73ZnXsR84kCFst3EngEHs1dcTkB K1m4pQMrLmm3GdnGR4YQ4IuwVifOCVwSOPER4BIxHlq5OQwUXhMI/Os1vo/WoaBAm9+M lxsKOcpMGiX9rwFhpQARWpbYDT9hhLNak87ATmzOGqVUh4xZOJvtRld97eSoKFoXH/kl VUiMFjxPOBsC8c8mfeZgY0fQdg0LeFsc1euwPpyqoo9tpy2Jtl9YNZtNFYU0Xp+VW5C6 umfA== X-Gm-Message-State: AKS2vOwuyV91MMtrGnuPSF/JCPU04PzkSIILvvcmdynQg4uDvODWrs50 jLJUyJCRQJVsuv0sCxQ= X-Received: by 10.80.176.102 with SMTP id i93mr314403edd.116.1497451146027; Wed, 14 Jun 2017 07:39:06 -0700 (PDT) Received: from groucho.site (ipbcc28001.dynamic.kabel-deutschland.de. [188.194.128.1]) by smtp.gmail.com with ESMTPSA id t17sm137330edd.69.2017.06.14.07.39.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Jun 2017 07:39:05 -0700 (PDT) From: Ulrich Hecht To: robh@kernel.org, linux-serial@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, magnus.damm@gmail.com, laurent.pinchart@ideasonboard.com, wsa@the-dreams.de, linux-i2c@vger.kernel.org, Ulrich Hecht Subject: [RFC 1/4] serdev: add method to set parity Date: Wed, 14 Jun 2017 16:38:47 +0200 Message-Id: <1497451130-7741-2-git-send-email-ulrich.hecht+renesas@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1497451130-7741-1-git-send-email-ulrich.hecht+renesas@gmail.com> References: <1497451130-7741-1-git-send-email-ulrich.hecht+renesas@gmail.com> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org 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 | 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 */