tty: invert return values of tty_{,un}throttle_safe()
If tty_{,un}throttle_safe() returned true on success (similar to *_trylock()), it would make the conditions in callers more obvious. So perform the switch to these inverted values (and fix the callers). Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230919085156.1578-8-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c2a36609da
commit
5b4f9cf3cc
|
@ -253,7 +253,7 @@ static void n_tty_check_throttle(struct tty_struct *tty)
|
||||||
tty_set_flow_change(tty, TTY_THROTTLE_SAFE);
|
tty_set_flow_change(tty, TTY_THROTTLE_SAFE);
|
||||||
if (N_TTY_BUF_SIZE - read_cnt(ldata) >= TTY_THRESHOLD_THROTTLE)
|
if (N_TTY_BUF_SIZE - read_cnt(ldata) >= TTY_THRESHOLD_THROTTLE)
|
||||||
break;
|
break;
|
||||||
} while (tty_throttle_safe(tty));
|
} while (!tty_throttle_safe(tty));
|
||||||
|
|
||||||
__tty_set_flow_change(tty, 0);
|
__tty_set_flow_change(tty, 0);
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ static void n_tty_check_unthrottle(struct tty_struct *tty)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
n_tty_kick_worker(tty);
|
n_tty_kick_worker(tty);
|
||||||
} while (tty_unthrottle_safe(tty));
|
} while (!tty_unthrottle_safe(tty));
|
||||||
|
|
||||||
__tty_set_flow_change(tty, 0);
|
__tty_set_flow_change(tty, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,16 +124,16 @@ EXPORT_SYMBOL(tty_unthrottle);
|
||||||
* conditions when throttling is conditional on factors evaluated prior to
|
* conditions when throttling is conditional on factors evaluated prior to
|
||||||
* throttling.
|
* throttling.
|
||||||
*
|
*
|
||||||
* Returns false if tty is throttled (or was already throttled)
|
* Returns true if tty is throttled (or was already throttled)
|
||||||
*/
|
*/
|
||||||
bool tty_throttle_safe(struct tty_struct *tty)
|
bool tty_throttle_safe(struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = true;
|
||||||
|
|
||||||
mutex_lock(&tty->throttle_mutex);
|
mutex_lock(&tty->throttle_mutex);
|
||||||
if (!tty_throttled(tty)) {
|
if (!tty_throttled(tty)) {
|
||||||
if (tty->flow_change != TTY_THROTTLE_SAFE)
|
if (tty->flow_change != TTY_THROTTLE_SAFE)
|
||||||
ret = true;
|
ret = false;
|
||||||
else {
|
else {
|
||||||
set_bit(TTY_THROTTLED, &tty->flags);
|
set_bit(TTY_THROTTLED, &tty->flags);
|
||||||
if (tty->ops->throttle)
|
if (tty->ops->throttle)
|
||||||
|
@ -154,16 +154,16 @@ bool tty_throttle_safe(struct tty_struct *tty)
|
||||||
* unthrottle due to race conditions when unthrottling is conditional
|
* unthrottle due to race conditions when unthrottling is conditional
|
||||||
* on factors evaluated prior to unthrottling.
|
* on factors evaluated prior to unthrottling.
|
||||||
*
|
*
|
||||||
* Returns false if tty is unthrottled (or was already unthrottled)
|
* Returns true if tty is unthrottled (or was already unthrottled)
|
||||||
*/
|
*/
|
||||||
bool tty_unthrottle_safe(struct tty_struct *tty)
|
bool tty_unthrottle_safe(struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = true;
|
||||||
|
|
||||||
mutex_lock(&tty->throttle_mutex);
|
mutex_lock(&tty->throttle_mutex);
|
||||||
if (tty_throttled(tty)) {
|
if (tty_throttled(tty)) {
|
||||||
if (tty->flow_change != TTY_UNTHROTTLE_SAFE)
|
if (tty->flow_change != TTY_UNTHROTTLE_SAFE)
|
||||||
ret = true;
|
ret = false;
|
||||||
else {
|
else {
|
||||||
clear_bit(TTY_THROTTLED, &tty->flags);
|
clear_bit(TTY_THROTTLED, &tty->flags);
|
||||||
if (tty->ops->unthrottle)
|
if (tty->ops->unthrottle)
|
||||||
|
|
Loading…
Reference in New Issue