linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
Cc: linux-serial@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	magnus.damm@gmail.com, wsa@the-dreams.de, robh@kernel.org,
	peda@axentia.se, geert@linux-m68k.org, linux-i2c@vger.kernel.org
Subject: Re: [RFC v2 2/6] serdev: add method to set parity
Date: Mon, 31 Jul 2017 13:55:12 +0300	[thread overview]
Message-ID: <3171716.rxI4aCGIDo@avalon> (raw)
In-Reply-To: <1500305076-15570-3-git-send-email-ulrich.hecht+renesas@gmail.com>

Hi Ulrich,

Thank you for the patch.

On Monday 17 Jul 2017 17:24:32 Ulrich Hecht wrote:
> Adds serdev_device_set_parity() and an implementation for ttyport.
> 
> Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
> ---
>  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)

Code calling this function will be difficult to read:

	serdev_device_set_partity(dev, true, false);

Without looking up the function definition, the last two arguments are not 
very explicit. How about replacing them with a disabled, odd, even enum ?

> +{
> +	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
>   */

-- 
Regards,

Laurent Pinchart

  parent reply	other threads:[~2017-07-31 10:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-17 15:24 [RFC v2 0/6] serdev multiplexing support Ulrich Hecht
2017-07-17 15:24 ` [RFC v2 1/6] mux: include compiler.h from mux/consumer.h Ulrich Hecht
2017-07-31  9:02   ` Peter Rosin
2017-07-31  9:56     ` Ulrich Hecht
2017-07-31 11:22   ` Laurent Pinchart
2017-07-17 15:24 ` [RFC v2 2/6] serdev: add method to set parity Ulrich Hecht
2017-07-18 23:08   ` Rob Herring
2017-07-31 10:55   ` Laurent Pinchart [this message]
2017-07-17 15:24 ` [RFC v2 3/6] serdev: add multiplexer support Ulrich Hecht
2017-07-18 23:06   ` Rob Herring
2017-08-16 13:23     ` Ulrich Hecht
2017-07-19  7:22   ` Peter Rosin
2017-07-17 15:24 ` [RFC v2 4/6] serial: core: support deferring serdev controller registration Ulrich Hecht
2017-07-19  3:24   ` Rob Herring
2017-07-17 15:24 ` [RFC v2 5/6] max9260: add driver for i2c over GMSL passthrough Ulrich Hecht
2017-07-18  6:51   ` Geert Uytterhoeven
2017-07-19 15:00   ` Wolfram Sang
2017-08-16 13:23     ` Ulrich Hecht
2017-08-16 13:32       ` Laurent Pinchart
2017-07-31 11:13   ` Laurent Pinchart
2017-08-16 13:23     ` Ulrich Hecht
2017-08-16 13:30       ` Laurent Pinchart
2017-07-17 15:24 ` [RFC v2 6/6] ARM: dts: blanche: add SCIF1 and MAX9260 deserializer Ulrich Hecht
2017-07-18  6:52   ` Geert Uytterhoeven
2017-07-31 11:20   ` Laurent Pinchart
2017-07-18 23:14 ` [RFC v2 0/6] serdev multiplexing support Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3171716.rxI4aCGIDo@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=peda@axentia.se \
    --cc=robh@kernel.org \
    --cc=ulrich.hecht+renesas@gmail.com \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).