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


Groups > linux.kernel > #1592476 > unrolled thread

[PATCH 08/10] serdev: add serdev_device_get_cts

Started bySebastian Reichel <sre@kernel.org>
First post2017-03-04 13:10 +0100
Last post2017-03-08 16:20 +0100
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 08/10] serdev: add serdev_device_get_cts Sebastian Reichel <sre@kernel.org> - 2017-03-04 13:10 +0100
    Re: [PATCH 08/10] serdev: add serdev_device_get_cts Rob Herring <robh+dt@kernel.org> - 2017-03-07 17:10 +0100
      Re: [PATCH 08/10] serdev: add serdev_device_get_cts Sebastian Reichel <sre@kernel.org> - 2017-03-07 22:30 +0100
        Re: [PATCH 08/10] serdev: add serdev_device_get_cts Rob Herring <robh+dt@kernel.org> - 2017-03-08 16:20 +0100

#1592476 — [PATCH 08/10] serdev: add serdev_device_get_cts

FromSebastian Reichel <sre@kernel.org>
Date2017-03-04 13:10 +0100
Subject[PATCH 08/10] serdev: add serdev_device_get_cts
Message-ID<thgFz-sD-17@gated-at.bofh.it>
Add method to get current CTS line state.

Signed-off-by: Sebastian Reichel <sre@kernel.org>
---
 drivers/tty/serdev/core.c           | 11 +++++++++++
 drivers/tty/serdev/serdev-ttyport.c | 15 +++++++++++++++
 include/linux/serdev.h              |  6 ++++++
 3 files changed, 32 insertions(+)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index a63b74031e22..36eb3dfb1477 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -184,6 +184,17 @@ void serdev_device_wait_until_sent(struct serdev_device *serdev, long timeout)
 }
 EXPORT_SYMBOL_GPL(serdev_device_wait_until_sent);
 
+bool serdev_device_get_cts(struct serdev_device *serdev)
+{
+	struct serdev_controller *ctrl = serdev->ctrl;
+
+	if (!ctrl || !ctrl->ops->get_cts)
+		return false;
+
+	return ctrl->ops->get_cts(ctrl);
+}
+EXPORT_SYMBOL_GPL(serdev_device_get_cts);
+
 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 db2bc601e554..3eaca7560e2e 100644
--- a/drivers/tty/serdev/serdev-ttyport.c
+++ b/drivers/tty/serdev/serdev-ttyport.c
@@ -179,6 +179,20 @@ static void ttyport_wait_until_sent(struct serdev_controller *ctrl, long timeout
 	tty_wait_until_sent(tty, timeout);
 }
 
+static bool ttyport_get_cts(struct serdev_controller *ctrl)
+{
+	struct serport *serport = serdev_controller_get_drvdata(ctrl);
+	struct tty_struct *tty = serport->tty;
+	int status;
+
+	if (!tty->ops->tiocmget)
+		return false;
+
+	status = tty->ops->tiocmget(tty);
+
+	return !!(status & TIOCM_CTS);
+}
+
 static const struct serdev_controller_ops ctrl_ops = {
 	.write_buf = ttyport_write_buf,
 	.write_flush = ttyport_write_flush,
@@ -188,6 +202,7 @@ static const struct serdev_controller_ops ctrl_ops = {
 	.set_flow_control = ttyport_set_flow_control,
 	.set_baudrate = ttyport_set_baudrate,
 	.wait_until_sent = ttyport_wait_until_sent,
+	.get_cts = ttyport_get_cts,
 };
 
 struct device *serdev_tty_port_register(struct tty_port *port,
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
index a308b206d204..b0c47402d84a 100644
--- a/include/linux/serdev.h
+++ b/include/linux/serdev.h
@@ -82,6 +82,7 @@ struct serdev_controller_ops {
 	void (*set_flow_control)(struct serdev_controller *, bool);
 	unsigned int (*set_baudrate)(struct serdev_controller *, unsigned int);
 	void (*wait_until_sent)(struct serdev_controller *, long);
+	bool (*get_cts)(struct serdev_controller *);
 };
 
 /**
@@ -188,6 +189,7 @@ void serdev_device_close(struct serdev_device *);
 unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int);
 void serdev_device_set_flow_control(struct serdev_device *, bool);
 void serdev_device_wait_until_sent(struct serdev_device *, long);
+bool serdev_device_get_cts(struct serdev_device *);
 int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t);
 void serdev_device_write_flush(struct serdev_device *);
 int serdev_device_write_room(struct serdev_device *);
@@ -226,6 +228,10 @@ static inline unsigned int serdev_device_set_baudrate(struct serdev_device *sdev
 }
 static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {}
 static inline void serdev_device_wait_until_sent(struct serdev_device *sdev, long timeout) {}
+static inline bool serdev_device_get_cts(struct serdev_device *serdev)
+{
+	return false;
+}
 static inline int serdev_device_write_buf(struct serdev_device *sdev, const unsigned char *buf, size_t count)
 {
 	return -ENODEV;
-- 
2.11.0

[toc] | [next] | [standalone]


#1594395

FromRob Herring <robh+dt@kernel.org>
Date2017-03-07 17:10 +0100
Message-ID<tipQv-1uF-49@gated-at.bofh.it>
In reply to#1592476
On Sat, Mar 4, 2017 at 5:58 AM, Sebastian Reichel <sre@kernel.org> wrote:
> Add method to get current CTS line state.
>
> Signed-off-by: Sebastian Reichel <sre@kernel.org>
> ---
>  drivers/tty/serdev/core.c           | 11 +++++++++++
>  drivers/tty/serdev/serdev-ttyport.c | 15 +++++++++++++++
>  include/linux/serdev.h              |  6 ++++++
>  3 files changed, 32 insertions(+)
>
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index a63b74031e22..36eb3dfb1477 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -184,6 +184,17 @@ void serdev_device_wait_until_sent(struct serdev_device *serdev, long timeout)
>  }
>  EXPORT_SYMBOL_GPL(serdev_device_wait_until_sent);
>
> +bool serdev_device_get_cts(struct serdev_device *serdev)

I wonder if this should just be the wait for cts in the core. I think
that would be the common use for reading the CTS state. IIRC, I saw
some other device needing the same thing.

Rob

[toc] | [prev] | [next] | [standalone]


#1594667

FromSebastian Reichel <sre@kernel.org>
Date2017-03-07 22:30 +0100
Message-ID<tiuQa-52G-23@gated-at.bofh.it>
In reply to#1594395

[Multipart message — attachments visible in raw view] — view raw

Hi Rob,

On Tue, Mar 07, 2017 at 10:03:37AM -0600, Rob Herring wrote:
> On Sat, Mar 4, 2017 at 5:58 AM, Sebastian Reichel <sre@kernel.org> wrote:
> > Add method to get current CTS line state.
> >
> > Signed-off-by: Sebastian Reichel <sre@kernel.org>
> > ---
> >  drivers/tty/serdev/core.c           | 11 +++++++++++
> >  drivers/tty/serdev/serdev-ttyport.c | 15 +++++++++++++++
> >  include/linux/serdev.h              |  6 ++++++
> >  3 files changed, 32 insertions(+)
> >
> > diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> > index a63b74031e22..36eb3dfb1477 100644
> > --- a/drivers/tty/serdev/core.c
> > +++ b/drivers/tty/serdev/core.c
> > @@ -184,6 +184,17 @@ void serdev_device_wait_until_sent(struct serdev_device *serdev, long timeout)
> >  }
> >  EXPORT_SYMBOL_GPL(serdev_device_wait_until_sent);
> >
> > +bool serdev_device_get_cts(struct serdev_device *serdev)
> 
> I wonder if this should just be the wait for cts in the core. I think
> that would be the common use for reading the CTS state. IIRC, I saw
> some other device needing the same thing.

mh. I think it fits nicely to serdev_device_set_rts(). But I guess
it makes sense to have the wait feature directly in serdev. So I
suggest to add the function in addition to the simple get_cts
function. Does that make sense to you?

-- Sebastian

[toc] | [prev] | [next] | [standalone]


#1595255

FromRob Herring <robh+dt@kernel.org>
Date2017-03-08 16:20 +0100
Message-ID<tiLxE-8ng-21@gated-at.bofh.it>
In reply to#1594667
On Tue, Mar 7, 2017 at 3:12 PM, Sebastian Reichel <sre@kernel.org> wrote:
> Hi Rob,
>
> On Tue, Mar 07, 2017 at 10:03:37AM -0600, Rob Herring wrote:
>> On Sat, Mar 4, 2017 at 5:58 AM, Sebastian Reichel <sre@kernel.org> wrote:
>> > Add method to get current CTS line state.
>> >
>> > Signed-off-by: Sebastian Reichel <sre@kernel.org>
>> > ---
>> >  drivers/tty/serdev/core.c           | 11 +++++++++++
>> >  drivers/tty/serdev/serdev-ttyport.c | 15 +++++++++++++++
>> >  include/linux/serdev.h              |  6 ++++++
>> >  3 files changed, 32 insertions(+)
>> >
>> > diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
>> > index a63b74031e22..36eb3dfb1477 100644
>> > --- a/drivers/tty/serdev/core.c
>> > +++ b/drivers/tty/serdev/core.c
>> > @@ -184,6 +184,17 @@ void serdev_device_wait_until_sent(struct serdev_device *serdev, long timeout)
>> >  }
>> >  EXPORT_SYMBOL_GPL(serdev_device_wait_until_sent);
>> >
>> > +bool serdev_device_get_cts(struct serdev_device *serdev)
>>
>> I wonder if this should just be the wait for cts in the core. I think
>> that would be the common use for reading the CTS state. IIRC, I saw
>> some other device needing the same thing.
>
> mh. I think it fits nicely to serdev_device_set_rts(). But I guess
> it makes sense to have the wait feature directly in serdev. So I
> suggest to add the function in addition to the simple get_cts
> function. Does that make sense to you?

Sure. You should be able to implement that just in the core. Then the
host driver stays simple and we're not duplicating the wait in host
drivers (not that we expect to have lots of host drivers).

Rob

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web