From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
To: gregkh@linuxfoundation.org
Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Subject: [PATCH 02/36] tty: ldisc: document that ldops are optional
Date: Thu, 10 Aug 2023 11:14:36 +0200 [thread overview]
Message-ID: <20230810091510.13006-3-jirislaby@kernel.org> (raw)
In-Reply-To: <20230810091510.13006-1-jirislaby@kernel.org>
There is no need to provide any hook in struct tty_ldisc_ops. Document
that and write down that read/write return EIO in that case. The rest is
simply ignored.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
---
include/linux/tty_ldisc.h | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index 49dc172dedc7..62e089434995 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -71,7 +71,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* call to @receive_buf(). Returning an error will prevent the ldisc from
* being attached.
*
- * Can sleep.
+ * Optional. Can sleep.
*
* @close: [TTY] ``void ()(struct tty_struct *tty)``
*
@@ -80,7 +80,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* changed to use a new line discipline. At the point of execution no
* further users will enter the ldisc code for this tty.
*
- * Can sleep.
+ * Optional. Can sleep.
*
* @flush_buffer: [TTY] ``void ()(struct tty_struct *tty)``
*
@@ -88,6 +88,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* input characters it may have queued to be delivered to the user mode
* process. It may be called at any point between open and close.
*
+ * Optional.
+ *
* @read: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file,
* unsigned char *buf, size_t nr)``
*
@@ -97,7 +99,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* an %EIO error. Multiple read calls may occur in parallel and the ldisc
* must deal with serialization issues.
*
- * Can sleep.
+ * Optional: %EIO unless provided. Can sleep.
*
* @write: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file,
* const unsigned char *buf, size_t nr)``
@@ -108,7 +110,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* characters first. If this function is not defined, the user will
* receive an %EIO error.
*
- * Can sleep.
+ * Optional: %EIO unless provided. Can sleep.
*
* @ioctl: [TTY] ``int ()(struct tty_struct *tty, unsigned int cmd,
* unsigned long arg)``
@@ -120,6 +122,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* discpline. So a low-level driver can "grab" an ioctl request before
* the line discpline has a chance to see it.
*
+ * Optional.
+ *
* @compat_ioctl: [TTY] ``int ()(struct tty_struct *tty, unsigned int cmd,
* unsigned long arg)``
*
@@ -130,11 +134,15 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* a pointer to wordsize-sensitive structure belongs here, but most of
* ldiscs will happily leave it %NULL.
*
+ * Optional.
+ *
* @set_termios: [TTY] ``void ()(struct tty_struct *tty, const struct ktermios *old)``
*
* This function notifies the line discpline that a change has been made
* to the termios structure.
*
+ * Optional.
+ *
* @poll: [TTY] ``int ()(struct tty_struct *tty, struct file *file,
* struct poll_table_struct *wait)``
*
@@ -142,6 +150,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* device. It is solely the responsibility of the line discipline to
* handle poll requests.
*
+ * Optional.
+ *
* @hangup: [TTY] ``void ()(struct tty_struct *tty)``
*
* Called on a hangup. Tells the discipline that it should cease I/O to
@@ -149,7 +159,7 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* but should wait until any pending driver I/O is completed. No further
* calls into the ldisc code will occur.
*
- * Can sleep.
+ * Optional. Can sleep.
*
* @receive_buf: [DRV] ``void ()(struct tty_struct *tty,
* const unsigned char *cp, const char *fp, int count)``
@@ -161,6 +171,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* character was received with a parity error, etc. @fp may be %NULL to
* indicate all data received is %TTY_NORMAL.
*
+ * Optional.
+ *
* @write_wakeup: [DRV] ``void ()(struct tty_struct *tty)``
*
* This function is called by the low-level tty driver to signal that line
@@ -170,11 +182,15 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* send, please arise a tasklet or workqueue to do the real data transfer.
* Do not send data in this hook, it may lead to a deadlock.
*
+ * Optional.
+ *
* @dcd_change: [DRV] ``void ()(struct tty_struct *tty, bool active)``
*
* Tells the discipline that the DCD pin has changed its status. Used
* exclusively by the %N_PPS (Pulse-Per-Second) line discipline.
*
+ * Optional.
+ *
* @receive_buf2: [DRV] ``int ()(struct tty_struct *tty,
* const unsigned char *cp, const char *fp, int count)``
*
@@ -186,6 +202,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* indicate all data received is %TTY_NORMAL. If assigned, prefer this
* function for automatic flow control.
*
+ * Optional.
+ *
* @lookahead_buf: [DRV] ``void ()(struct tty_struct *tty,
* const unsigned char *cp, const char *fp, int count)``
*
@@ -198,6 +216,8 @@ int ldsem_down_write_nested(struct ld_semaphore *sem, int subclass,
* same characters (e.g. by skipping the actions for high-priority
* characters already handled by ->lookahead_buf()).
*
+ * Optional.
+ *
* @owner: module containting this ldisc (for reference counting)
*
* This structure defines the interface between the tty line discipline
--
2.41.0
next prev parent reply other threads:[~2023-08-10 9:15 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-10 9:14 [PATCH 00/36] tty: type unifications -- part I Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 01/36] tty: xtensa/iss: drop unneeded tty_operations hooks Jiri Slaby (SUSE)
2023-08-10 12:37 ` Max Filippov
2023-08-10 9:14 ` Jiri Slaby (SUSE) [this message]
2023-08-10 9:14 ` [PATCH 03/36] tty: remove dummy tty_ldisc_ops::poll() implementations Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 04/36] tty: n_null: remove optional ldops Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 05/36] tty: change tty_write_lock()'s ndelay parameter to bool Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 06/36] tty: tty_port: rename 'disc' to 'ld' Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 07/36] tty: drop tty_debug_wait_until_sent() Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 08/36] tty: make tty_change_softcar() more understandable Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 09/36] tty: make tty_port_client_operations operate with u8 Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 10/36] tty: make counts in tty_port_client_operations hooks size_t Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 11/36] tty: switch receive_buf() counts to size_t Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 12/36] tty: switch count in tty_ldisc_receive_buf() " Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 13/36] tty: can327: unify error paths in can327_ldisc_rx() Jiri Slaby (SUSE)
2023-08-11 21:32 ` Max Staudt
2023-08-10 9:14 ` [PATCH 14/36] tty: can327, move overflow test inside can327_ldisc_rx()'s loop Jiri Slaby (SUSE)
2023-08-11 21:34 ` Max Staudt
2023-08-10 9:14 ` [PATCH 15/36] tty: make tty_ldisc_ops::*buf*() hooks operate on size_t Jiri Slaby (SUSE)
2023-08-10 12:02 ` Mark Brown
2023-08-11 21:34 ` Max Staudt
2023-08-10 9:14 ` [PATCH 16/36] tty: use u8 for chars Jiri Slaby (SUSE)
2023-08-10 12:04 ` Mark Brown
2023-08-11 10:28 ` Ilpo Järvinen
2023-08-14 6:35 ` Jiri Slaby
2023-08-31 18:33 ` Andy Shevchenko
2023-08-11 21:34 ` Max Staudt
2023-08-10 9:14 ` [PATCH 17/36] tty: use u8 for flags Jiri Slaby (SUSE)
2023-08-10 12:05 ` Mark Brown
2023-08-11 21:35 ` Max Staudt
2023-08-10 9:14 ` [PATCH 18/36] misc: ti-st: make st_recv() conforming to tty_ldisc_ops::receive_buf() Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 19/36] tty: make char_buf_ptr()/flag_buf_ptr()'s offset unsigned Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 20/36] tty: tty_buffer: make all offsets unsigned Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 21/36] tty: don't pass write() to do_tty_write() Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 22/36] tty: rename and de-inline do_tty_write() Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 23/36] tty: use min() in iterate_tty_write() Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 24/36] tty: use ssize_t for iterate_tty_read() returned type Jiri Slaby (SUSE)
2023-08-10 9:14 ` [PATCH 25/36] tty: switch size and count types in iterate_tty_read() to size_t Jiri Slaby (SUSE)
2023-08-10 9:15 ` [PATCH 26/36] tty: use min() for size computation in iterate_tty_read() Jiri Slaby (SUSE)
2023-08-10 9:15 ` [PATCH 27/36] tty: propagate u8 data to tty_operations::write() Jiri Slaby (SUSE)
2023-08-11 11:52 ` Alexander Gordeev
2023-08-17 10:42 ` Jiri Slaby
2023-08-14 14:47 ` Geert Uytterhoeven
2023-08-17 10:53 ` Alexander Gordeev
2023-08-10 9:15 ` [PATCH 28/36] tty: propagate u8 data to tty_operations::put_char() Jiri Slaby (SUSE)
2023-08-14 14:44 ` Geert Uytterhoeven
2023-08-17 10:55 ` Alexander Gordeev
2023-08-10 9:15 ` [PATCH 29/36] tty: make tty_operations::write()'s count size_t Jiri Slaby (SUSE)
2023-08-14 17:58 ` Geert Uytterhoeven
2023-08-10 9:15 ` [PATCH 30/36] tty: audit: unify to u8 Jiri Slaby (SUSE)
2023-08-10 9:15 ` [PATCH 31/36] tty: ldops: " Jiri Slaby (SUSE)
2023-08-10 9:15 ` [PATCH 32/36] tty: hvc: convert counts to size_t Jiri Slaby (SUSE)
2023-08-10 9:15 ` [PATCH 33/36] tty: vcc: " Jiri Slaby (SUSE)
2023-08-10 9:15 ` [PATCH 34/36] tty: gdm724x: " Jiri Slaby (SUSE)
2023-08-10 9:42 ` Dan Carpenter
2023-08-10 10:08 ` Jiri Slaby
2023-08-10 10:39 ` [PATCH 34-and-three-quarters/36] tty: gdm724x: simplify gdm_tty_write() Jiri Slaby (SUSE)
2023-08-11 9:11 ` Ilpo Järvinen
2023-08-15 17:22 ` [PATCH 34/36] tty: gdm724x: convert counts to size_t Nathan Chancellor
2023-08-16 6:46 ` Jiri Slaby
2023-08-16 8:40 ` David Laight
2023-08-16 8:58 ` Jiri Slaby
2023-08-16 9:18 ` David Laight
2023-08-10 9:15 ` [PATCH 35/36] tty: hso: simplify hso_serial_write() Jiri Slaby (SUSE)
2023-08-10 9:15 ` [PATCH 36/36] tty: rfcomm: convert counts to size_t Jiri Slaby (SUSE)
2023-08-11 10:26 ` [PATCH 00/36] tty: type unifications -- part I Ilpo Järvinen
2023-08-14 6:59 ` Jiri Slaby
2023-08-14 14:47 ` Ilpo Järvinen
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=20230810091510.13006-3-jirislaby@kernel.org \
--to=jirislaby@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
/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