Re: [PATCH v1 1/3] serdev: Add method to assert break

Luiz Augusto von Dentz
2023-01-24T22:17:18Z

Hi Neeraj,

On Tue, Jan 24, 2023 at 9:48 AM Neeraj Sanjay Kale
<neeraj.sanjaykale@nxp.com> wrote:
>
> Adds serdev_device_break_ctl() and an implementation for ttyport.
>
> Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> ---
> drivers/tty/serdev/core.c | 11 +++++++++++
> drivers/tty/serdev/serdev-ttyport.c | 12 ++++++++++++
> include/linux/serdev.h | 6 ++++++
> 3 files changed, 29 insertions(+)
>
> diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
> index 0180e1e4e75d..26321ad7e71d 100644
> --- a/drivers/tty/serdev/core.c
> +++ b/drivers/tty/serdev/core.c
> @@ -405,6 +405,17 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear)
> }
> EXPORT_SYMBOL_GPL(serdev_device_set_tiocm);
>
> +int serdev_device_break_ctl(struct serdev_device *serdev, int break_state)
> +{
> + struct serdev_controller *ctrl = serdev->ctrl;
> +
> + if (!ctrl || !ctrl->ops->break_ctl)
> + return -ENOTSUPP;
> +
> + return ctrl->ops->break_ctl(ctrl, break_state);
> +}
> +EXPORT_SYMBOL_GPL(serdev_device_break_ctl);
> +
> 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 d367803e2044..847b1f71ab73 100644
> --- a/drivers/tty/serdev/serdev-ttyport.c
> +++ b/drivers/tty/serdev/serdev-ttyport.c
> @@ -247,6 +247,17 @@ static int ttyport_set_tiocm(struct serdev_controller *ctrl, unsigned int set, u
> return tty->ops->tiocmset(tty, set, clear);
> }
>
> +static int ttyport_break_ctl(struct serdev_controller *ctrl, unsigned int break_state)
> +{
> + struct serport *serport = serdev_controller_get_drvdata(ctrl);
> + struct tty_struct *tty = serport->tty;
> +
> + if (!tty->ops->break_ctl)
> + return -ENOTSUPP;
> +
> + return tty->ops->break_ctl(tty, break_state);
> +}
> +
> static const struct serdev_controller_ops ctrl_ops = {
> .write_buf = ttyport_write_buf,
> .write_flush = ttyport_write_flush,
> @@ -259,6 +270,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,
> + .break_ctl = ttyport_break_ctl,
> };
>
> struct device *serdev_tty_port_register(struct tty_port *port,
> diff --git a/include/linux/serdev.h b/include/linux/serdev.h
> index 66f624fc618c..01b5b8f308cb 100644
> --- a/include/linux/serdev.h
> +++ b/include/linux/serdev.h
> @@ -92,6 +92,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 (*break_ctl)(struct serdev_controller *, unsigned int);

Looks like these callbacks don't have any documentation, not sure if
that is because the operation itself is self explanatory, anyway I
hope someone can review this from serdev before it can be merged into
bluetooth-next.

> };
>
> /**
> @@ -202,6 +203,7 @@ int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_
> void serdev_device_wait_until_sent(struct serdev_device *, long);
> int serdev_device_get_tiocm(struct serdev_device *);
> int serdev_device_set_tiocm(struct serdev_device *, int, int);
> +int serdev_device_break_ctl(struct serdev_device *, int);
> void serdev_device_write_wakeup(struct serdev_device *);
> int serdev_device_write(struct serdev_device *, const unsigned char *, size_t, long);
> void serdev_device_write_flush(struct serdev_device *);
> @@ -255,6 +257,10 @@ static inline int serdev_device_set_tiocm(struct serdev_device *serdev, int set,
> {
> return -ENOTSUPP;
> }
> +static inline int serdev_device_break_ctl(struct serdev_device *serdev, int break_state)
> +{
> + return -ENOTSUPP;
> +}
> static inline int serdev_device_write(struct serdev_device *sdev, const unsigned char *buf,
> size_t count, unsigned long timeout)
> {
> --
> 2.34.1
>

--
Luiz Augusto von Dentz