Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1607018

Re: [PATCHv2 07/11] serdev: add helpers for cts and rts handling

From Rob Herring <robh+dt@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCHv2 07/11] serdev: add helpers for cts and rts handling
Date 2017-03-22 22:10 +0100
Message-ID <tnVG1-hD-3@gated-at.bofh.it> (permalink)
References <tnABA-1iQ-3@gated-at.bofh.it> <tnABA-1iQ-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Mar 21, 2017 at 5:32 PM, Sebastian Reichel <sre@kernel.org> wrote:
> Add serdev helper functions for handling of cts and rts
> lines using the serdev's tiocm functions.
>
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>  include/linux/serdev.h | 31 +++++++++++++++++++++++++++++++
>  1 file changed, 31 insertions(+)
>
> diff --git a/include/linux/serdev.h b/include/linux/serdev.h
> index 3ad1d695f947..8cdce2ea0d51 100644
> --- a/include/linux/serdev.h
> +++ b/include/linux/serdev.h
> @@ -16,6 +16,7 @@
>  #include <linux/types.h>
>  #include <linux/device.h>
>  #include <asm-generic/termios.h>
> +#include <linux/delay.h>
>
>  struct serdev_controller;
>  struct serdev_device;
> @@ -254,6 +255,36 @@ static inline int serdev_device_write_room(struct serdev_device *sdev)
>
>  #endif /* CONFIG_SERIAL_DEV_BUS */
>
> +static inline bool serdev_device_get_cts(struct serdev_device *serdev)
> +{
> +       int status = serdev_device_get_tiocm(serdev);
> +       return !!(status & TIOCM_CTS);
> +}
> +
> +static inline int serdev_device_wait_for_cts(struct serdev_device *serdev, bool state, int timeout_ms)
> +{
> +       unsigned long timeout;
> +       bool signal;
> +
> +       timeout = jiffies + msecs_to_jiffies(timeout_ms);
> +       while (!time_after(jiffies, timeout)) {

You can use time_is_after_jiffies(timeout) instead of !time_after.

> +               signal = serdev_device_get_cts(serdev);
> +               if (signal == state)
> +                       return 0;
> +               usleep_range(1000, 2000);
> +       }
> +
> +       return -ETIMEDOUT;
> +}
> +
> +static inline int serdev_device_set_rts(struct serdev_device *serdev, bool enable)
> +{
> +       if (enable)
> +               return serdev_device_set_tiocm(serdev, TIOCM_OUT2 | TIOCM_RTS, 0);

Perhaps a comment why we're messing with OUT2.

With those,

Acked-by: Rob Herring <robh@kernel.org>

> +       else
> +               return serdev_device_set_tiocm(serdev, 0, TIOCM_OUT2 | TIOCM_RTS);
> +}
> +
>  /*
>   * serdev hooks into TTY core
>   */
> --
> 2.11.0
>

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCHv2 00/11] Nokia H4+ support Sebastian Reichel <sre@kernel.org> - 2017-03-21 23:40 +0100
  [PATCHv2 09/11] Bluetooth: add nokia driver Sebastian Reichel <sre@kernel.org> - 2017-03-21 23:40 +0100
    Re: [PATCHv2 09/11] Bluetooth: add nokia driver Rob Herring <robh+dt@kernel.org> - 2017-03-22 22:30 +0100
      Re: [PATCHv2 09/11] Bluetooth: add nokia driver Sebastian Reichel <sre@kernel.org> - 2017-03-22 23:50 +0100
    Re: [PATCHv2 09/11] Bluetooth: add nokia driver Frédéric Danis <frederic.danis.oss@gmail.com> - 2017-03-23 09:00 +0100
      Re: [PATCHv2 09/11] Bluetooth: add nokia driver Sebastian Reichel <sre@kernel.org> - 2017-03-23 10:10 +0100
  [PATCHv2 07/11] serdev: add helpers for cts and rts handling Sebastian Reichel <sre@kernel.org> - 2017-03-21 23:40 +0100
    Re: [PATCHv2 07/11] serdev: add helpers for cts and rts handling Rob Herring <robh+dt@kernel.org> - 2017-03-22 22:10 +0100
  [PATCHv2 06/11] serdev: implement get/set tiocm Sebastian Reichel <sre@kernel.org> - 2017-03-21 23:40 +0100
    [PATCHv2.1] serdev: implement get/set tiocm Sebastian Reichel <sre@kernel.org> - 2017-03-22 02:10 +0100
      Re: [PATCHv2.1] serdev: implement get/set tiocm Pavel Machek <pavel@ucw.cz> - 2017-03-22 10:50 +0100
      Re: [PATCHv2.1] serdev: implement get/set tiocm Rob Herring <robh+dt@kernel.org> - 2017-03-22 22:20 +0100
  [PATCHv2 03/11] Bluetooth: hci_serdev: do not open device in hci open Sebastian Reichel <sre@kernel.org> - 2017-03-21 23:40 +0100
  [PATCHv2 08/11] dt-bindings: net: bluetooth: Add nokia-bluetooth Sebastian Reichel <sre@kernel.org> - 2017-03-21 23:40 +0100
    Re: [PATCHv2 08/11] dt-bindings: net: bluetooth: Add nokia-bluetooth Rob Herring <robh+dt@kernel.org> - 2017-03-22 22:10 +0100
  [PATCHv2 01/11] Bluetooth: hci_uart: add support for word alignment Sebastian Reichel <sre@kernel.org> - 2017-03-21 23:40 +0100
  [PATCHv2 05/11] serdev: add serdev_device_wait_until_sent Sebastian Reichel <sre@kernel.org> - 2017-03-21 23:40 +0100
    Re: [PATCHv2 05/11] serdev: add serdev_device_wait_until_sent Pavel Machek <pavel@ucw.cz> - 2017-03-22 10:50 +0100
  [PATCHv2 10/11] ARM: dts: N900: Add bluetooth Sebastian Reichel <sre@kernel.org> - 2017-03-21 23:40 +0100
    Re: [PATCHv2 10/11] ARM: dts: N900: Add bluetooth Rob Herring <robh+dt@kernel.org> - 2017-03-22 22:10 +0100
      Re: [PATCHv2 10/11] ARM: dts: N900: Add bluetooth Tony Lindgren <tony@atomide.com> - 2017-03-23 01:00 +0100
  [PATCHv2 11/11] ARM: dts: N9/N950: add bluetooth Sebastian Reichel <sre@kernel.org> - 2017-03-21 23:40 +0100
    Re: [PATCHv2 11/11] ARM: dts: N9/N950: add bluetooth Rob Herring <robh+dt@kernel.org> - 2017-03-22 22:10 +0100

csiph-web