Re: [PATCH v7 6/8] i3c: target: func: add tty driver

Ilpo Järvinen
2024-02-19T20:21:29Z

On Mon, 5 Feb 2024, Frank Li wrote:

> Add tty over I3C target function driver.
>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
>
> Notes:
> Change from v4 to v5
> - remove void*
> - include bitfield.h
> - remove extra ()
> - oneline for struct ttyi3c_port *sport
>
> drivers/i3c/Kconfig | 3 +
> drivers/i3c/Makefile | 1 +
> drivers/i3c/func/Kconfig | 9 +
> drivers/i3c/func/Makefile | 3 +
> drivers/i3c/func/tty.c | 474 ++++++++++++++++++++++++++++++++++++++
> 5 files changed, 490 insertions(+)
> create mode 100644 drivers/i3c/func/Kconfig
> create mode 100644 drivers/i3c/func/Makefile
> create mode 100644 drivers/i3c/func/tty.c
>
> diff --git a/drivers/i3c/Kconfig b/drivers/i3c/Kconfig
> index d59a7eb83d13a..fca808cda87b3 100644
> --- a/drivers/i3c/Kconfig
> +++ b/drivers/i3c/Kconfig
> @@ -48,3 +48,6 @@ config I3C_TARGET_CONFIGFS
> the target function and used to bind the function with a target
> controller.
>
> +if I3C_TARGET
> +source "drivers/i3c/func/Kconfig"
> +endif # I3C_TARGET
> diff --git a/drivers/i3c/Makefile b/drivers/i3c/Makefile
> index c275aeae8970c..11f026d6876fe 100644
> --- a/drivers/i3c/Makefile
> +++ b/drivers/i3c/Makefile
> @@ -4,3 +4,4 @@ obj-$(CONFIG_I3C) += i3c.o
> obj-$(CONFIG_I3C_TARGET) += target.o
> obj-$(CONFIG_I3C_TARGET_CONFIGFS) += i3c-cfs.o
> obj-$(CONFIG_I3C) += master/
> +obj-$(CONFIG_I3C_TARGET) += func/
> diff --git a/drivers/i3c/func/Kconfig b/drivers/i3c/func/Kconfig
> new file mode 100644
> index 0000000000000..7115129eb7d5a
> --- /dev/null
> +++ b/drivers/i3c/func/Kconfig
> @@ -0,0 +1,9 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +config I3C_TARGET_FUNC_TTY
> + tristate "I3C target tty driver"
> + depends on I3C_TARGET
> + help
> + I3C Target TTY Function Driver.
> +
> + General TTY over I3C target controller function drivers.
> diff --git a/drivers/i3c/func/Makefile b/drivers/i3c/func/Makefile
> new file mode 100644
> index 0000000000000..16b3b9301496b
> --- /dev/null
> +++ b/drivers/i3c/func/Makefile
> @@ -0,0 +1,3 @@
> +# SPDX-License-Identifier: GPL-2.0
> +
> +obj-$(CONFIG_I3C_TARGET_FUNC_TTY) += tty.o
> diff --git a/drivers/i3c/func/tty.c b/drivers/i3c/func/tty.c
> new file mode 100644
> index 0000000000000..50673bfb6a003
> --- /dev/null
> +++ b/drivers/i3c/func/tty.c
> @@ -0,0 +1,474 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2023 NXP
> + * Author: Frank Li <Frank.Li@nxp.com>
> + */
> +
> +#include <linux/bitfield.h>
> +#include <linux/iopoll.h>
> +#include <linux/i3c/target.h>
> +#include <linux/serial_core.h>
> +#include <linux/slab.h>
> +#include <linux/tty_flip.h>
> +
> +static DEFINE_IDR(i3c_tty_minors);
> +
> +static struct tty_driver *i3c_tty_driver;
> +
> +#define I3C_TTY_MINORS 8
> +
> +#define I3C_TX_NOEMPTY BIT(0)
> +#define I3C_TTY_TRANS_SIZE 16
> +#define I3C_TTY_IBI_TX BIT(0)

This is #include <linux/bits.h>

...which will include <vdso/bits.h> that contains the actual definition.

#include <bitfield.h> is for FIELD_GET/PREP(), etc.

> +struct ttyi3c_port {
> + struct tty_port port;
> + int minor;
> + struct i3c_target_func *i3cdev;
> + struct completion txcomplete;
> + spinlock_t xlock;
> + void *buffer;
> + struct work_struct work;

This file seems to also lack some includes. Please go through your
#include in the series and add those you use.

--
i.