Skip to content

Commit 3b1a696

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: fix up and plug in tty_ioctl kernel-doc
The ioctl helpers are well documented, except they are not plugged in the Documentation. So fix up the minor issues in the kernel-doc and plug it in. The minor issues include: * bad \t on every line (sphinx misinterprets the description otherwise) * missing colon after Return * superfluous \n after the comment * make some struct members and constants a hyperlink * and so on Perhaps better to use --word-diff if one wants to see the "real" changes. Signed-off-by: "Jiri Slaby (SUSE)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5b4f9cf commit 3b1a696

File tree

3 files changed

+115
-111
lines changed

3 files changed

+115
-111
lines changed

Documentation/driver-api/tty/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ In-detail description of the named TTY structures is in separate documents:
3636
tty_struct
3737
tty_ldisc
3838
tty_buffer
39+
tty_ioctl
3940
tty_internals
4041

4142
Writing TTY Driver
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
=================
4+
TTY IOCTL Helpers
5+
=================
6+
7+
.. kernel-doc:: drivers/tty/tty_ioctl.c

drivers/tty/tty_ioctl.c

Lines changed: 107 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,13 @@
3838
#define TERMIOS_TERMIO BIT(2)
3939
#define TERMIOS_OLD BIT(3)
4040

41-
4241
/**
43-
* tty_chars_in_buffer - characters pending
44-
* @tty: terminal
42+
* tty_chars_in_buffer - characters pending
43+
* @tty: terminal
4544
*
46-
* Return the number of bytes of data in the device private
47-
* output queue. If no private method is supplied there is assumed
48-
* to be no queue on the device.
45+
* Returns: the number of bytes of data in the device private output queue. If
46+
* no private method is supplied there is assumed to be no queue on the device.
4947
*/
50-
5148
unsigned int tty_chars_in_buffer(struct tty_struct *tty)
5249
{
5350
if (tty->ops->chars_in_buffer)
@@ -57,16 +54,15 @@ unsigned int tty_chars_in_buffer(struct tty_struct *tty)
5754
EXPORT_SYMBOL(tty_chars_in_buffer);
5855

5956
/**
60-
* tty_write_room - write queue space
61-
* @tty: terminal
57+
* tty_write_room - write queue space
58+
* @tty: terminal
6259
*
63-
* Return the number of bytes that can be queued to this device
64-
* at the present time. The result should be treated as a guarantee
65-
* and the driver cannot offer a value it later shrinks by more than
66-
* the number of bytes written. If no method is provided 2K is always
67-
* returned and data may be lost as there will be no flow control.
60+
* Returns: the number of bytes that can be queued to this device at the present
61+
* time. The result should be treated as a guarantee and the driver cannot
62+
* offer a value it later shrinks by more than the number of bytes written. If
63+
* no method is provided, 2K is always returned and data may be lost as there
64+
* will be no flow control.
6865
*/
69-
7066
unsigned int tty_write_room(struct tty_struct *tty)
7167
{
7268
if (tty->ops->write_room)
@@ -76,12 +72,12 @@ unsigned int tty_write_room(struct tty_struct *tty)
7672
EXPORT_SYMBOL(tty_write_room);
7773

7874
/**
79-
* tty_driver_flush_buffer - discard internal buffer
80-
* @tty: terminal
75+
* tty_driver_flush_buffer - discard internal buffer
76+
* @tty: terminal
8177
*
82-
* Discard the internal output buffer for this device. If no method
83-
* is provided then either the buffer cannot be hardware flushed or
84-
* there is no buffer driver side.
78+
* Discard the internal output buffer for this device. If no method is provided,
79+
* then either the buffer cannot be hardware flushed or there is no buffer
80+
* driver side.
8581
*/
8682
void tty_driver_flush_buffer(struct tty_struct *tty)
8783
{
@@ -91,18 +87,17 @@ void tty_driver_flush_buffer(struct tty_struct *tty)
9187
EXPORT_SYMBOL(tty_driver_flush_buffer);
9288

9389
/**
94-
* tty_unthrottle - flow control
95-
* @tty: terminal
90+
* tty_unthrottle - flow control
91+
* @tty: terminal
9692
*
97-
* Indicate that a tty may continue transmitting data down the stack.
98-
* Takes the termios rwsem to protect against parallel throttle/unthrottle
99-
* and also to ensure the driver can consistently reference its own
100-
* termios data at this point when implementing software flow control.
93+
* Indicate that a @tty may continue transmitting data down the stack. Takes
94+
* the &tty_struct->termios_rwsem to protect against parallel
95+
* throttle/unthrottle and also to ensure the driver can consistently reference
96+
* its own termios data at this point when implementing software flow control.
10197
*
102-
* Drivers should however remember that the stack can issue a throttle,
103-
* then change flow control method, then unthrottle.
98+
* Drivers should however remember that the stack can issue a throttle, then
99+
* change flow control method, then unthrottle.
104100
*/
105-
106101
void tty_unthrottle(struct tty_struct *tty)
107102
{
108103
down_write(&tty->termios_rwsem);
@@ -115,16 +110,15 @@ void tty_unthrottle(struct tty_struct *tty)
115110
EXPORT_SYMBOL(tty_unthrottle);
116111

117112
/**
118-
* tty_throttle_safe - flow control
119-
* @tty: terminal
113+
* tty_throttle_safe - flow control
114+
* @tty: terminal
120115
*
121-
* Indicate that a tty should stop transmitting data down the stack.
122-
* tty_throttle_safe will only attempt throttle if tty->flow_change is
123-
* TTY_THROTTLE_SAFE. Prevents an accidental throttle due to race
124-
* conditions when throttling is conditional on factors evaluated prior to
125-
* throttling.
116+
* Indicate that a @tty should stop transmitting data down the stack.
117+
* tty_throttle_safe() will only attempt throttle if @tty->flow_change is
118+
* %TTY_THROTTLE_SAFE. Prevents an accidental throttle due to race conditions
119+
* when throttling is conditional on factors evaluated prior to throttling.
126120
*
127-
* Returns true if tty is throttled (or was already throttled)
121+
* Returns: %true if @tty is throttled (or was already throttled)
128122
*/
129123
bool tty_throttle_safe(struct tty_struct *tty)
130124
{
@@ -146,15 +140,15 @@ bool tty_throttle_safe(struct tty_struct *tty)
146140
}
147141

148142
/**
149-
* tty_unthrottle_safe - flow control
150-
* @tty: terminal
143+
* tty_unthrottle_safe - flow control
144+
* @tty: terminal
151145
*
152-
* Similar to tty_unthrottle() but will only attempt unthrottle
153-
* if tty->flow_change is TTY_UNTHROTTLE_SAFE. Prevents an accidental
154-
* unthrottle due to race conditions when unthrottling is conditional
155-
* on factors evaluated prior to unthrottling.
146+
* Similar to tty_unthrottle() but will only attempt unthrottle if
147+
* @tty->flow_change is %TTY_UNTHROTTLE_SAFE. Prevents an accidental unthrottle
148+
* due to race conditions when unthrottling is conditional on factors evaluated
149+
* prior to unthrottling.
156150
*
157-
* Returns true if tty is unthrottled (or was already unthrottled)
151+
* Returns: %true if @tty is unthrottled (or was already unthrottled)
158152
*/
159153
bool tty_unthrottle_safe(struct tty_struct *tty)
160154
{
@@ -176,14 +170,14 @@ bool tty_unthrottle_safe(struct tty_struct *tty)
176170
}
177171

178172
/**
179-
* tty_wait_until_sent - wait for I/O to finish
180-
* @tty: tty we are waiting for
181-
* @timeout: how long we will wait
173+
* tty_wait_until_sent - wait for I/O to finish
174+
* @tty: tty we are waiting for
175+
* @timeout: how long we will wait
182176
*
183-
* Wait for characters pending in a tty driver to hit the wire, or
184-
* for a timeout to occur (eg due to flow control)
177+
* Wait for characters pending in a tty driver to hit the wire, or for a
178+
* timeout to occur (eg due to flow control).
185179
*
186-
* Locking: none
180+
* Locking: none
187181
*/
188182

189183
void tty_wait_until_sent(struct tty_struct *tty, long timeout)
@@ -229,16 +223,15 @@ static void unset_locked_termios(struct tty_struct *tty, const struct ktermios *
229223
}
230224

231225
/**
232-
* tty_termios_copy_hw - copy hardware settings
233-
* @new: New termios
234-
* @old: Old termios
226+
* tty_termios_copy_hw - copy hardware settings
227+
* @new: new termios
228+
* @old: old termios
235229
*
236-
* Propagate the hardware specific terminal setting bits from
237-
* the old termios structure to the new one. This is used in cases
238-
* where the hardware does not support reconfiguration or as a helper
239-
* in some cases where only minimal reconfiguration is supported
230+
* Propagate the hardware specific terminal setting bits from the @old termios
231+
* structure to the @new one. This is used in cases where the hardware does not
232+
* support reconfiguration or as a helper in some cases where only minimal
233+
* reconfiguration is supported.
240234
*/
241-
242235
void tty_termios_copy_hw(struct ktermios *new, const struct ktermios *old)
243236
{
244237
/* The bits a dumb device handles in software. Smart devices need
@@ -251,14 +244,15 @@ void tty_termios_copy_hw(struct ktermios *new, const struct ktermios *old)
251244
EXPORT_SYMBOL(tty_termios_copy_hw);
252245

253246
/**
254-
* tty_termios_hw_change - check for setting change
255-
* @a: termios
256-
* @b: termios to compare
247+
* tty_termios_hw_change - check for setting change
248+
* @a: termios
249+
* @b: termios to compare
257250
*
258-
* Check if any of the bits that affect a dumb device have changed
259-
* between the two termios structures, or a speed change is needed.
251+
* Check if any of the bits that affect a dumb device have changed between the
252+
* two termios structures, or a speed change is needed.
253+
*
254+
* Returns: %true if change is needed
260255
*/
261-
262256
bool tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b)
263257
{
264258
if (a->c_ispeed != b->c_ispeed || a->c_ospeed != b->c_ospeed)
@@ -270,11 +264,10 @@ bool tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b)
270264
EXPORT_SYMBOL(tty_termios_hw_change);
271265

272266
/**
273-
* tty_get_char_size - get size of a character
274-
* @cflag: termios cflag value
267+
* tty_get_char_size - get size of a character
268+
* @cflag: termios cflag value
275269
*
276-
* Get the size (in bits) of a character depending on @cflag's %CSIZE
277-
* setting.
270+
* Returns: size (in bits) of a character depending on @cflag's %CSIZE setting
278271
*/
279272
unsigned char tty_get_char_size(unsigned int cflag)
280273
{
@@ -293,13 +286,14 @@ unsigned char tty_get_char_size(unsigned int cflag)
293286
EXPORT_SYMBOL_GPL(tty_get_char_size);
294287

295288
/**
296-
* tty_get_frame_size - get size of a frame
297-
* @cflag: termios cflag value
289+
* tty_get_frame_size - get size of a frame
290+
* @cflag: termios cflag value
298291
*
299-
* Get the size (in bits) of a frame depending on @cflag's %CSIZE, %CSTOPB,
300-
* and %PARENB setting. The result is a sum of character size, start and
301-
* stop bits -- one bit each -- second stop bit (if set), and parity bit
302-
* (if set).
292+
* Get the size (in bits) of a frame depending on @cflag's %CSIZE, %CSTOPB, and
293+
* %PARENB setting. The result is a sum of character size, start and stop bits
294+
* -- one bit each -- second stop bit (if set), and parity bit (if set).
295+
*
296+
* Returns: size (in bits) of a frame depending on @cflag's setting.
303297
*/
304298
unsigned char tty_get_frame_size(unsigned int cflag)
305299
{
@@ -317,16 +311,15 @@ unsigned char tty_get_frame_size(unsigned int cflag)
317311
EXPORT_SYMBOL_GPL(tty_get_frame_size);
318312

319313
/**
320-
* tty_set_termios - update termios values
321-
* @tty: tty to update
322-
* @new_termios: desired new value
314+
* tty_set_termios - update termios values
315+
* @tty: tty to update
316+
* @new_termios: desired new value
323317
*
324-
* Perform updates to the termios values set on this terminal.
325-
* A master pty's termios should never be set.
318+
* Perform updates to the termios values set on this @tty. A master pty's
319+
* termios should never be set.
326320
*
327-
* Locking: termios_rwsem
321+
* Locking: &tty_struct->termios_rwsem
328322
*/
329-
330323
int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios)
331324
{
332325
struct ktermios old_termios;
@@ -439,18 +432,19 @@ __weak int kernel_termios_to_user_termios(struct termios __user *u,
439432
#endif /* TCGETS2 */
440433

441434
/**
442-
* set_termios - set termios values for a tty
443-
* @tty: terminal device
444-
* @arg: user data
445-
* @opt: option information
435+
* set_termios - set termios values for a tty
436+
* @tty: terminal device
437+
* @arg: user data
438+
* @opt: option information
446439
*
447-
* Helper function to prepare termios data and run necessary other
448-
* functions before using tty_set_termios to do the actual changes.
440+
* Helper function to prepare termios data and run necessary other functions
441+
* before using tty_set_termios() to do the actual changes.
449442
*
450-
* Locking:
451-
* Called functions take ldisc and termios_rwsem locks
443+
* Locking: called functions take &tty_struct->ldisc_sem and
444+
* &tty_struct->termios_rwsem locks
445+
*
446+
* Returns: 0 on success, an error otherwise
452447
*/
453-
454448
static int set_termios(struct tty_struct *tty, void __user *arg, int opt)
455449
{
456450
struct ktermios tmp_termios;
@@ -622,16 +616,16 @@ static void set_sgflags(struct ktermios *termios, int flags)
622616
}
623617

624618
/**
625-
* set_sgttyb - set legacy terminal values
626-
* @tty: tty structure
627-
* @sgttyb: pointer to old style terminal structure
619+
* set_sgttyb - set legacy terminal values
620+
* @tty: tty structure
621+
* @sgttyb: pointer to old style terminal structure
628622
*
629-
* Updates a terminal from the legacy BSD style terminal information
630-
* structure.
623+
* Updates a terminal from the legacy BSD style terminal information structure.
631624
*
632-
* Locking: termios_rwsem
625+
* Locking: &tty_struct->termios_rwsem
626+
*
627+
* Returns: 0 on success, an error otherwise
633628
*/
634-
635629
static int set_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb)
636630
{
637631
int retval;
@@ -733,14 +727,17 @@ static int set_ltchars(struct tty_struct *tty, struct ltchars __user *ltchars)
733727
#endif
734728

735729
/**
736-
* tty_change_softcar - carrier change ioctl helper
737-
* @tty: tty to update
738-
* @enable: enable/disable CLOCAL
730+
* tty_change_softcar - carrier change ioctl helper
731+
* @tty: tty to update
732+
* @enable: enable/disable %CLOCAL
739733
*
740-
* Perform a change to the CLOCAL state and call into the driver
741-
* layer to make it visible. All done with the termios rwsem
734+
* Perform a change to the %CLOCAL state and call into the driver layer to make
735+
* it visible.
736+
*
737+
* Locking: &tty_struct->termios_rwsem.
738+
*
739+
* Returns: 0 on success, an error otherwise
742740
*/
743-
744741
static int tty_change_softcar(struct tty_struct *tty, bool enable)
745742
{
746743
int ret = 0;
@@ -760,16 +757,15 @@ static int tty_change_softcar(struct tty_struct *tty, bool enable)
760757
}
761758

762759
/**
763-
* tty_mode_ioctl - mode related ioctls
764-
* @tty: tty for the ioctl
765-
* @cmd: command
766-
* @arg: ioctl argument
760+
* tty_mode_ioctl - mode related ioctls
761+
* @tty: tty for the ioctl
762+
* @cmd: command
763+
* @arg: ioctl argument
767764
*
768-
* Perform non line discipline specific mode control ioctls. This
769-
* is designed to be called by line disciplines to ensure they provide
770-
* consistent mode setting.
765+
* Perform non-line discipline specific mode control ioctls. This is designed
766+
* to be called by line disciplines to ensure they provide consistent mode
767+
* setting.
771768
*/
772-
773769
int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
774770
{
775771
struct tty_struct *real_tty;

0 commit comments

Comments
 (0)