Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230919085156.1578-9-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
3b1a696b 5b4f9cf3

+115 -111
+1
Documentation/driver-api/tty/index.rst
··· 36 36 tty_struct 37 37 tty_ldisc 38 38 tty_buffer 39 + tty_ioctl 39 40 tty_internals 40 41 41 42 Writing TTY Driver
+7
Documentation/driver-api/tty/tty_ioctl.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 2 + 3 + ================= 4 + TTY IOCTL Helpers 5 + ================= 6 + 7 + .. kernel-doc:: drivers/tty/tty_ioctl.c
+107 -111
drivers/tty/tty_ioctl.c
··· 38 38 #define TERMIOS_TERMIO BIT(2) 39 39 #define TERMIOS_OLD BIT(3) 40 40 41 - 42 41 /** 43 - * tty_chars_in_buffer - characters pending 44 - * @tty: terminal 42 + * tty_chars_in_buffer - characters pending 43 + * @tty: terminal 45 44 * 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. 49 47 */ 50 - 51 48 unsigned int tty_chars_in_buffer(struct tty_struct *tty) 52 49 { 53 50 if (tty->ops->chars_in_buffer) ··· 54 57 EXPORT_SYMBOL(tty_chars_in_buffer); 55 58 56 59 /** 57 - * tty_write_room - write queue space 58 - * @tty: terminal 60 + * tty_write_room - write queue space 61 + * @tty: terminal 59 62 * 60 - * Return the number of bytes that can be queued to this device 61 - * at the present time. The result should be treated as a guarantee 62 - * and the driver cannot offer a value it later shrinks by more than 63 - * the number of bytes written. If no method is provided 2K is always 64 - * returned and data may be lost as there will be no flow control. 63 + * Returns: the number of bytes that can be queued to this device at the present 64 + * time. The result should be treated as a guarantee and the driver cannot 65 + * offer a value it later shrinks by more than the number of bytes written. If 66 + * no method is provided, 2K is always returned and data may be lost as there 67 + * will be no flow control. 65 68 */ 66 - 67 69 unsigned int tty_write_room(struct tty_struct *tty) 68 70 { 69 71 if (tty->ops->write_room) ··· 72 76 EXPORT_SYMBOL(tty_write_room); 73 77 74 78 /** 75 - * tty_driver_flush_buffer - discard internal buffer 76 - * @tty: terminal 79 + * tty_driver_flush_buffer - discard internal buffer 80 + * @tty: terminal 77 81 * 78 - * Discard the internal output buffer for this device. If no method 79 - * is provided then either the buffer cannot be hardware flushed or 80 - * there is no buffer driver side. 82 + * Discard the internal output buffer for this device. If no method is provided, 83 + * then either the buffer cannot be hardware flushed or there is no buffer 84 + * driver side. 81 85 */ 82 86 void tty_driver_flush_buffer(struct tty_struct *tty) 83 87 { ··· 87 91 EXPORT_SYMBOL(tty_driver_flush_buffer); 88 92 89 93 /** 90 - * tty_unthrottle - flow control 91 - * @tty: terminal 94 + * tty_unthrottle - flow control 95 + * @tty: terminal 92 96 * 93 - * Indicate that a tty may continue transmitting data down the stack. 94 - * Takes the termios rwsem to protect against parallel throttle/unthrottle 95 - * and also to ensure the driver can consistently reference its own 96 - * termios data at this point when implementing software flow control. 97 + * Indicate that a @tty may continue transmitting data down the stack. Takes 98 + * the &tty_struct->termios_rwsem to protect against parallel 99 + * throttle/unthrottle and also to ensure the driver can consistently reference 100 + * its own termios data at this point when implementing software flow control. 97 101 * 98 - * Drivers should however remember that the stack can issue a throttle, 99 - * then change flow control method, then unthrottle. 102 + * Drivers should however remember that the stack can issue a throttle, then 103 + * change flow control method, then unthrottle. 100 104 */ 101 - 102 105 void tty_unthrottle(struct tty_struct *tty) 103 106 { 104 107 down_write(&tty->termios_rwsem); ··· 110 115 EXPORT_SYMBOL(tty_unthrottle); 111 116 112 117 /** 113 - * tty_throttle_safe - flow control 114 - * @tty: terminal 118 + * tty_throttle_safe - flow control 119 + * @tty: terminal 115 120 * 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 119 - * conditions when throttling is conditional on factors evaluated prior to 120 - * throttling. 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 conditions 124 + * when throttling is conditional on factors evaluated prior to throttling. 121 125 * 122 - * Returns true if tty is throttled (or was already throttled) 126 + * Returns: %true if @tty is throttled (or was already throttled) 123 127 */ 124 128 bool tty_throttle_safe(struct tty_struct *tty) 125 129 { ··· 140 146 } 141 147 142 148 /** 143 - * tty_unthrottle_safe - flow control 144 - * @tty: terminal 149 + * tty_unthrottle_safe - flow control 150 + * @tty: terminal 145 151 * 146 - * Similar to tty_unthrottle() but will only attempt unthrottle 147 - * if tty->flow_change is TTY_UNTHROTTLE_SAFE. Prevents an accidental 148 - * unthrottle due to race conditions when unthrottling is conditional 149 - * on factors evaluated prior to unthrottling. 152 + * Similar to tty_unthrottle() but will only attempt unthrottle if 153 + * @tty->flow_change is %TTY_UNTHROTTLE_SAFE. Prevents an accidental unthrottle 154 + * due to race conditions when unthrottling is conditional on factors evaluated 155 + * prior to unthrottling. 150 156 * 151 - * Returns true if tty is unthrottled (or was already unthrottled) 157 + * Returns: %true if @tty is unthrottled (or was already unthrottled) 152 158 */ 153 159 bool tty_unthrottle_safe(struct tty_struct *tty) 154 160 { ··· 170 176 } 171 177 172 178 /** 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 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 176 182 * 177 - * Wait for characters pending in a tty driver to hit the wire, or 178 - * for a timeout to occur (eg due to flow control) 183 + * Wait for characters pending in a tty driver to hit the wire, or for a 184 + * timeout to occur (eg due to flow control). 179 185 * 180 - * Locking: none 186 + * Locking: none 181 187 */ 182 188 183 189 void tty_wait_until_sent(struct tty_struct *tty, long timeout) ··· 223 229 } 224 230 225 231 /** 226 - * tty_termios_copy_hw - copy hardware settings 227 - * @new: New termios 228 - * @old: Old termios 232 + * tty_termios_copy_hw - copy hardware settings 233 + * @new: new termios 234 + * @old: old termios 229 235 * 230 - * Propagate the hardware specific terminal setting bits from 231 - * the old termios structure to the new one. This is used in cases 232 - * where the hardware does not support reconfiguration or as a helper 233 - * in some cases where only minimal reconfiguration is supported 236 + * Propagate the hardware specific terminal setting bits from the @old termios 237 + * structure to the @new one. This is used in cases where the hardware does not 238 + * support reconfiguration or as a helper in some cases where only minimal 239 + * reconfiguration is supported. 234 240 */ 235 - 236 241 void tty_termios_copy_hw(struct ktermios *new, const struct ktermios *old) 237 242 { 238 243 /* The bits a dumb device handles in software. Smart devices need ··· 244 251 EXPORT_SYMBOL(tty_termios_copy_hw); 245 252 246 253 /** 247 - * tty_termios_hw_change - check for setting change 248 - * @a: termios 249 - * @b: termios to compare 254 + * tty_termios_hw_change - check for setting change 255 + * @a: termios 256 + * @b: termios to compare 250 257 * 251 - * Check if any of the bits that affect a dumb device have changed 252 - * between the two termios structures, or a speed change is needed. 258 + * Check if any of the bits that affect a dumb device have changed between the 259 + * two termios structures, or a speed change is needed. 260 + * 261 + * Returns: %true if change is needed 253 262 */ 254 - 255 263 bool tty_termios_hw_change(const struct ktermios *a, const struct ktermios *b) 256 264 { 257 265 if (a->c_ispeed != b->c_ispeed || a->c_ospeed != b->c_ospeed) ··· 264 270 EXPORT_SYMBOL(tty_termios_hw_change); 265 271 266 272 /** 267 - * tty_get_char_size - get size of a character 268 - * @cflag: termios cflag value 273 + * tty_get_char_size - get size of a character 274 + * @cflag: termios cflag value 269 275 * 270 - * Get the size (in bits) of a character depending on @cflag's %CSIZE 271 - * setting. 276 + * Returns: size (in bits) of a character depending on @cflag's %CSIZE setting 272 277 */ 273 278 unsigned char tty_get_char_size(unsigned int cflag) 274 279 { ··· 286 293 EXPORT_SYMBOL_GPL(tty_get_char_size); 287 294 288 295 /** 289 - * tty_get_frame_size - get size of a frame 290 - * @cflag: termios cflag value 296 + * tty_get_frame_size - get size of a frame 297 + * @cflag: termios cflag value 291 298 * 292 - * Get the size (in bits) of a frame depending on @cflag's %CSIZE, %CSTOPB, 293 - * and %PARENB setting. The result is a sum of character size, start and 294 - * stop bits -- one bit each -- second stop bit (if set), and parity bit 295 - * (if set). 299 + * Get the size (in bits) of a frame depending on @cflag's %CSIZE, %CSTOPB, and 300 + * %PARENB setting. The result is a sum of character size, start and stop bits 301 + * -- one bit each -- second stop bit (if set), and parity bit (if set). 302 + * 303 + * Returns: size (in bits) of a frame depending on @cflag's setting. 296 304 */ 297 305 unsigned char tty_get_frame_size(unsigned int cflag) 298 306 { ··· 311 317 EXPORT_SYMBOL_GPL(tty_get_frame_size); 312 318 313 319 /** 314 - * tty_set_termios - update termios values 315 - * @tty: tty to update 316 - * @new_termios: desired new value 320 + * tty_set_termios - update termios values 321 + * @tty: tty to update 322 + * @new_termios: desired new value 317 323 * 318 - * Perform updates to the termios values set on this terminal. 319 - * A master pty's termios should never be set. 324 + * Perform updates to the termios values set on this @tty. A master pty's 325 + * termios should never be set. 320 326 * 321 - * Locking: termios_rwsem 327 + * Locking: &tty_struct->termios_rwsem 322 328 */ 323 - 324 329 int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios) 325 330 { 326 331 struct ktermios old_termios; ··· 432 439 #endif /* TCGETS2 */ 433 440 434 441 /** 435 - * set_termios - set termios values for a tty 436 - * @tty: terminal device 437 - * @arg: user data 438 - * @opt: option information 442 + * set_termios - set termios values for a tty 443 + * @tty: terminal device 444 + * @arg: user data 445 + * @opt: option information 439 446 * 440 - * Helper function to prepare termios data and run necessary other 441 - * functions before using tty_set_termios to do the actual changes. 447 + * Helper function to prepare termios data and run necessary other functions 448 + * before using tty_set_termios() to do the actual changes. 442 449 * 443 - * Locking: 444 - * Called functions take ldisc and termios_rwsem locks 450 + * Locking: called functions take &tty_struct->ldisc_sem and 451 + * &tty_struct->termios_rwsem locks 452 + * 453 + * Returns: 0 on success, an error otherwise 445 454 */ 446 - 447 455 static int set_termios(struct tty_struct *tty, void __user *arg, int opt) 448 456 { 449 457 struct ktermios tmp_termios; ··· 616 622 } 617 623 618 624 /** 619 - * set_sgttyb - set legacy terminal values 620 - * @tty: tty structure 621 - * @sgttyb: pointer to old style terminal structure 625 + * set_sgttyb - set legacy terminal values 626 + * @tty: tty structure 627 + * @sgttyb: pointer to old style terminal structure 622 628 * 623 - * Updates a terminal from the legacy BSD style terminal information 624 - * structure. 629 + * Updates a terminal from the legacy BSD style terminal information structure. 625 630 * 626 - * Locking: termios_rwsem 631 + * Locking: &tty_struct->termios_rwsem 632 + * 633 + * Returns: 0 on success, an error otherwise 627 634 */ 628 - 629 635 static int set_sgttyb(struct tty_struct *tty, struct sgttyb __user *sgttyb) 630 636 { 631 637 int retval; ··· 727 733 #endif 728 734 729 735 /** 730 - * tty_change_softcar - carrier change ioctl helper 731 - * @tty: tty to update 732 - * @enable: enable/disable CLOCAL 736 + * tty_change_softcar - carrier change ioctl helper 737 + * @tty: tty to update 738 + * @enable: enable/disable %CLOCAL 733 739 * 734 - * Perform a change to the CLOCAL state and call into the driver 735 - * layer to make it visible. All done with the termios rwsem 740 + * Perform a change to the %CLOCAL state and call into the driver layer to make 741 + * it visible. 742 + * 743 + * Locking: &tty_struct->termios_rwsem. 744 + * 745 + * Returns: 0 on success, an error otherwise 736 746 */ 737 - 738 747 static int tty_change_softcar(struct tty_struct *tty, bool enable) 739 748 { 740 749 int ret = 0; ··· 757 760 } 758 761 759 762 /** 760 - * tty_mode_ioctl - mode related ioctls 761 - * @tty: tty for the ioctl 762 - * @cmd: command 763 - * @arg: ioctl argument 763 + * tty_mode_ioctl - mode related ioctls 764 + * @tty: tty for the ioctl 765 + * @cmd: command 766 + * @arg: ioctl argument 764 767 * 765 - * Perform non line discipline specific mode control ioctls. This 766 - * is designed to be called by line disciplines to ensure they provide 767 - * consistent mode setting. 768 + * Perform non-line discipline specific mode control ioctls. This is designed 769 + * to be called by line disciplines to ensure they provide consistent mode 770 + * setting. 768 771 */ 769 - 770 772 int tty_mode_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) 771 773 { 772 774 struct tty_struct *real_tty;