Skip to content

Commit c2a3660

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: switch tty_{,un}throttle_safe() to return a bool
They return 0 or 1 -- a boolean value, so make it clear than noone should expect negative or other values. 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 043c8a7 commit c2a3660

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

drivers/tty/tty_ioctl.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,16 @@ EXPORT_SYMBOL(tty_unthrottle);
124124
* conditions when throttling is conditional on factors evaluated prior to
125125
* throttling.
126126
*
127-
* Returns 0 if tty is throttled (or was already throttled)
127+
* Returns false if tty is throttled (or was already throttled)
128128
*/
129-
130-
int tty_throttle_safe(struct tty_struct *tty)
129+
bool tty_throttle_safe(struct tty_struct *tty)
131130
{
132-
int ret = 0;
131+
bool ret = false;
133132

134133
mutex_lock(&tty->throttle_mutex);
135134
if (!tty_throttled(tty)) {
136135
if (tty->flow_change != TTY_THROTTLE_SAFE)
137-
ret = 1;
136+
ret = true;
138137
else {
139138
set_bit(TTY_THROTTLED, &tty->flags);
140139
if (tty->ops->throttle)
@@ -155,17 +154,16 @@ int tty_throttle_safe(struct tty_struct *tty)
155154
* unthrottle due to race conditions when unthrottling is conditional
156155
* on factors evaluated prior to unthrottling.
157156
*
158-
* Returns 0 if tty is unthrottled (or was already unthrottled)
157+
* Returns false if tty is unthrottled (or was already unthrottled)
159158
*/
160-
161-
int tty_unthrottle_safe(struct tty_struct *tty)
159+
bool tty_unthrottle_safe(struct tty_struct *tty)
162160
{
163-
int ret = 0;
161+
bool ret = false;
164162

165163
mutex_lock(&tty->throttle_mutex);
166164
if (tty_throttled(tty)) {
167165
if (tty->flow_change != TTY_UNTHROTTLE_SAFE)
168-
ret = 1;
166+
ret = true;
169167
else {
170168
clear_bit(TTY_THROTTLED, &tty->flags);
171169
if (tty->ops->unthrottle)

include/linux/tty.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,8 @@ unsigned int tty_chars_in_buffer(struct tty_struct *tty);
416416
unsigned int tty_write_room(struct tty_struct *tty);
417417
void tty_driver_flush_buffer(struct tty_struct *tty);
418418
void tty_unthrottle(struct tty_struct *tty);
419-
int tty_throttle_safe(struct tty_struct *tty);
420-
int tty_unthrottle_safe(struct tty_struct *tty);
419+
bool tty_throttle_safe(struct tty_struct *tty);
420+
bool tty_unthrottle_safe(struct tty_struct *tty);
421421
int tty_do_resize(struct tty_struct *tty, struct winsize *ws);
422422
int tty_get_icount(struct tty_struct *tty,
423423
struct serial_icounter_struct *icount);

0 commit comments

Comments
 (0)