Commit b300fb26 authored by Ilpo Järvinen's avatar Ilpo Järvinen Committed by Greg Kroah-Hartman

tty: Convert ->carrier_raised() and callchains to bool

Return boolean from ->carrier_raised() instead of 0 and 1. Make the
return type change also to tty_port_carrier_raised() that makes the
->carrier_raised() call (+ cd variable in moxa into which its return
value is stored).

Also cleans up a few unnecessary constructs related to this change:

	return xx ? 1 : 0;
	-> return xx;

	if (xx)
		return 1;
	return 0;
	-> return xx;
Reviewed-by: default avatarJiri Slaby <jirislaby@kernel.org>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org> # For MMC
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20230117090358.4796-7-ilpo.jarvinen@linux.intel.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dcd794c6
...@@ -377,7 +377,7 @@ static void async_mode(MGSLPC_INFO *info); ...@@ -377,7 +377,7 @@ static void async_mode(MGSLPC_INFO *info);
static void tx_timeout(struct timer_list *t); static void tx_timeout(struct timer_list *t);
static int carrier_raised(struct tty_port *port); static bool carrier_raised(struct tty_port *port);
static void dtr_rts(struct tty_port *port, int onoff); static void dtr_rts(struct tty_port *port, int onoff);
#if SYNCLINK_GENERIC_HDLC #if SYNCLINK_GENERIC_HDLC
...@@ -2430,7 +2430,7 @@ static void mgslpc_hangup(struct tty_struct *tty) ...@@ -2430,7 +2430,7 @@ static void mgslpc_hangup(struct tty_struct *tty)
tty_port_hangup(&info->port); tty_port_hangup(&info->port);
} }
static int carrier_raised(struct tty_port *port) static bool carrier_raised(struct tty_port *port)
{ {
MGSLPC_INFO *info = container_of(port, MGSLPC_INFO, port); MGSLPC_INFO *info = container_of(port, MGSLPC_INFO, port);
unsigned long flags; unsigned long flags;
...@@ -2439,9 +2439,7 @@ static int carrier_raised(struct tty_port *port) ...@@ -2439,9 +2439,7 @@ static int carrier_raised(struct tty_port *port)
get_signals(info); get_signals(info);
spin_unlock_irqrestore(&info->lock, flags); spin_unlock_irqrestore(&info->lock, flags);
if (info->serial_signals & SerialSignal_DCD) return info->serial_signals & SerialSignal_DCD;
return 1;
return 0;
} }
static void dtr_rts(struct tty_port *port, int onoff) static void dtr_rts(struct tty_port *port, int onoff)
......
...@@ -526,7 +526,7 @@ static void sdio_uart_irq(struct sdio_func *func) ...@@ -526,7 +526,7 @@ static void sdio_uart_irq(struct sdio_func *func)
port->in_sdio_uart_irq = NULL; port->in_sdio_uart_irq = NULL;
} }
static int uart_carrier_raised(struct tty_port *tport) static bool uart_carrier_raised(struct tty_port *tport)
{ {
struct sdio_uart_port *port = struct sdio_uart_port *port =
container_of(tport, struct sdio_uart_port, port); container_of(tport, struct sdio_uart_port, port);
...@@ -535,9 +535,8 @@ static int uart_carrier_raised(struct tty_port *tport) ...@@ -535,9 +535,8 @@ static int uart_carrier_raised(struct tty_port *tport)
return 1; return 1;
ret = sdio_uart_get_mctrl(port); ret = sdio_uart_get_mctrl(port);
sdio_uart_release_func(port); sdio_uart_release_func(port);
if (ret & TIOCM_CAR)
return 1; return ret & TIOCM_CAR;
return 0;
} }
/** /**
......
...@@ -1454,7 +1454,7 @@ static const struct tty_operations serial_ops = { ...@@ -1454,7 +1454,7 @@ static const struct tty_operations serial_ops = {
.proc_show = rs_proc_show, .proc_show = rs_proc_show,
}; };
static int amiga_carrier_raised(struct tty_port *port) static bool amiga_carrier_raised(struct tty_port *port)
{ {
return !(ciab.pra & SER_DCD); return !(ciab.pra & SER_DCD);
} }
......
...@@ -501,7 +501,7 @@ static int moxa_tiocmset(struct tty_struct *tty, ...@@ -501,7 +501,7 @@ static int moxa_tiocmset(struct tty_struct *tty,
static void moxa_poll(struct timer_list *); static void moxa_poll(struct timer_list *);
static void moxa_set_tty_param(struct tty_struct *, const struct ktermios *); static void moxa_set_tty_param(struct tty_struct *, const struct ktermios *);
static void moxa_shutdown(struct tty_port *); static void moxa_shutdown(struct tty_port *);
static int moxa_carrier_raised(struct tty_port *); static bool moxa_carrier_raised(struct tty_port *);
static void moxa_dtr_rts(struct tty_port *, int); static void moxa_dtr_rts(struct tty_port *, int);
/* /*
* moxa board interface functions: * moxa board interface functions:
...@@ -1432,7 +1432,7 @@ static void moxa_shutdown(struct tty_port *port) ...@@ -1432,7 +1432,7 @@ static void moxa_shutdown(struct tty_port *port)
MoxaPortFlushData(ch, 2); MoxaPortFlushData(ch, 2);
} }
static int moxa_carrier_raised(struct tty_port *port) static bool moxa_carrier_raised(struct tty_port *port)
{ {
struct moxa_port *ch = container_of(port, struct moxa_port, port); struct moxa_port *ch = container_of(port, struct moxa_port, port);
int dcd; int dcd;
......
...@@ -458,10 +458,11 @@ static void __mxser_stop_tx(struct mxser_port *info) ...@@ -458,10 +458,11 @@ static void __mxser_stop_tx(struct mxser_port *info)
outb(info->IER, info->ioaddr + UART_IER); outb(info->IER, info->ioaddr + UART_IER);
} }
static int mxser_carrier_raised(struct tty_port *port) static bool mxser_carrier_raised(struct tty_port *port)
{ {
struct mxser_port *mp = container_of(port, struct mxser_port, port); struct mxser_port *mp = container_of(port, struct mxser_port, port);
return (inb(mp->ioaddr + UART_MSR) & UART_MSR_DCD)?1:0;
return inb(mp->ioaddr + UART_MSR) & UART_MSR_DCD;
} }
static void mxser_dtr_rts(struct tty_port *port, int on) static void mxser_dtr_rts(struct tty_port *port, int on)
......
...@@ -3770,16 +3770,16 @@ static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk) ...@@ -3770,16 +3770,16 @@ static int gsm_modem_update(struct gsm_dlci *dlci, u8 brk)
return -EPROTONOSUPPORT; return -EPROTONOSUPPORT;
} }
static int gsm_carrier_raised(struct tty_port *port) static bool gsm_carrier_raised(struct tty_port *port)
{ {
struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port); struct gsm_dlci *dlci = container_of(port, struct gsm_dlci, port);
struct gsm_mux *gsm = dlci->gsm; struct gsm_mux *gsm = dlci->gsm;
/* Not yet open so no carrier info */ /* Not yet open so no carrier info */
if (dlci->state != DLCI_OPEN) if (dlci->state != DLCI_OPEN)
return 0; return false;
if (debug & DBG_CD_ON) if (debug & DBG_CD_ON)
return 1; return true;
/* /*
* Basic mode with control channel in ADM mode may not respond * Basic mode with control channel in ADM mode may not respond
...@@ -3787,7 +3787,7 @@ static int gsm_carrier_raised(struct tty_port *port) ...@@ -3787,7 +3787,7 @@ static int gsm_carrier_raised(struct tty_port *port)
*/ */
if (gsm->encoding == GSM_BASIC_OPT && if (gsm->encoding == GSM_BASIC_OPT &&
gsm->dlci[0]->mode == DLCI_MODE_ADM && !dlci->modem_rx) gsm->dlci[0]->mode == DLCI_MODE_ADM && !dlci->modem_rx)
return 1; return true;
return dlci->modem_rx & TIOCM_CD; return dlci->modem_rx & TIOCM_CD;
} }
......
...@@ -1861,7 +1861,7 @@ static void uart_port_shutdown(struct tty_port *port) ...@@ -1861,7 +1861,7 @@ static void uart_port_shutdown(struct tty_port *port)
} }
} }
static int uart_carrier_raised(struct tty_port *port) static bool uart_carrier_raised(struct tty_port *port)
{ {
struct uart_state *state = container_of(port, struct uart_state, port); struct uart_state *state = container_of(port, struct uart_state, port);
struct uart_port *uport; struct uart_port *uport;
...@@ -1875,15 +1875,14 @@ static int uart_carrier_raised(struct tty_port *port) ...@@ -1875,15 +1875,14 @@ static int uart_carrier_raised(struct tty_port *port)
* continue and not sleep * continue and not sleep
*/ */
if (WARN_ON(!uport)) if (WARN_ON(!uport))
return 1; return true;
spin_lock_irq(&uport->lock); spin_lock_irq(&uport->lock);
uart_enable_ms(uport); uart_enable_ms(uport);
mctrl = uport->ops->get_mctrl(uport); mctrl = uport->ops->get_mctrl(uport);
spin_unlock_irq(&uport->lock); spin_unlock_irq(&uport->lock);
uart_port_deref(uport); uart_port_deref(uport);
if (mctrl & TIOCM_CAR)
return 1; return mctrl & TIOCM_CAR;
return 0;
} }
static void uart_dtr_rts(struct tty_port *port, int raise) static void uart_dtr_rts(struct tty_port *port, int raise)
......
...@@ -3126,7 +3126,7 @@ static int tiocmset(struct tty_struct *tty, ...@@ -3126,7 +3126,7 @@ static int tiocmset(struct tty_struct *tty,
return 0; return 0;
} }
static int carrier_raised(struct tty_port *port) static bool carrier_raised(struct tty_port *port)
{ {
unsigned long flags; unsigned long flags;
struct slgt_info *info = container_of(port, struct slgt_info, port); struct slgt_info *info = container_of(port, struct slgt_info, port);
...@@ -3134,7 +3134,8 @@ static int carrier_raised(struct tty_port *port) ...@@ -3134,7 +3134,8 @@ static int carrier_raised(struct tty_port *port)
spin_lock_irqsave(&info->lock,flags); spin_lock_irqsave(&info->lock,flags);
get_gtsignals(info); get_gtsignals(info);
spin_unlock_irqrestore(&info->lock,flags); spin_unlock_irqrestore(&info->lock,flags);
return (info->signals & SerialSignal_DCD) ? 1 : 0;
return info->signals & SerialSignal_DCD;
} }
static void dtr_rts(struct tty_port *port, int on) static void dtr_rts(struct tty_port *port, int on)
...@@ -3162,7 +3163,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, ...@@ -3162,7 +3163,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
int retval; int retval;
bool do_clocal = false; bool do_clocal = false;
unsigned long flags; unsigned long flags;
int cd; bool cd;
struct tty_port *port = &info->port; struct tty_port *port = &info->port;
DBGINFO(("%s block_til_ready\n", tty->driver->name)); DBGINFO(("%s block_til_ready\n", tty->driver->name));
......
...@@ -444,10 +444,10 @@ EXPORT_SYMBOL_GPL(tty_port_tty_wakeup); ...@@ -444,10 +444,10 @@ EXPORT_SYMBOL_GPL(tty_port_tty_wakeup);
* to hide some internal details. This will eventually become entirely * to hide some internal details. This will eventually become entirely
* internal to the tty port. * internal to the tty port.
*/ */
int tty_port_carrier_raised(struct tty_port *port) bool tty_port_carrier_raised(struct tty_port *port)
{ {
if (port->ops->carrier_raised == NULL) if (port->ops->carrier_raised == NULL)
return 1; return true;
return port->ops->carrier_raised(port); return port->ops->carrier_raised(port);
} }
EXPORT_SYMBOL(tty_port_carrier_raised); EXPORT_SYMBOL(tty_port_carrier_raised);
......
...@@ -754,7 +754,7 @@ static struct usb_serial_driver *search_serial_device( ...@@ -754,7 +754,7 @@ static struct usb_serial_driver *search_serial_device(
return NULL; return NULL;
} }
static int serial_port_carrier_raised(struct tty_port *port) static bool serial_port_carrier_raised(struct tty_port *port)
{ {
struct usb_serial_port *p = container_of(port, struct usb_serial_port, port); struct usb_serial_port *p = container_of(port, struct usb_serial_port, port);
struct usb_serial_driver *drv = p->serial->type; struct usb_serial_driver *drv = p->serial->type;
...@@ -762,7 +762,7 @@ static int serial_port_carrier_raised(struct tty_port *port) ...@@ -762,7 +762,7 @@ static int serial_port_carrier_raised(struct tty_port *port)
if (drv->carrier_raised) if (drv->carrier_raised)
return drv->carrier_raised(p); return drv->carrier_raised(p);
/* No carrier control - don't block */ /* No carrier control - don't block */
return 1; return true;
} }
static void serial_port_dtr_rts(struct tty_port *port, int on) static void serial_port_dtr_rts(struct tty_port *port, int on)
......
...@@ -15,7 +15,7 @@ struct tty_struct; ...@@ -15,7 +15,7 @@ struct tty_struct;
/** /**
* struct tty_port_operations -- operations on tty_port * struct tty_port_operations -- operations on tty_port
* @carrier_raised: return 1 if the carrier is raised on @port * @carrier_raised: return true if the carrier is raised on @port
* @dtr_rts: raise the DTR line if @raise is nonzero, otherwise lower DTR * @dtr_rts: raise the DTR line if @raise is nonzero, otherwise lower DTR
* @shutdown: called when the last close completes or a hangup finishes IFF the * @shutdown: called when the last close completes or a hangup finishes IFF the
* port was initialized. Do not use to free resources. Turn off the device * port was initialized. Do not use to free resources. Turn off the device
...@@ -31,7 +31,7 @@ struct tty_struct; ...@@ -31,7 +31,7 @@ struct tty_struct;
* the port itself. * the port itself.
*/ */
struct tty_port_operations { struct tty_port_operations {
int (*carrier_raised)(struct tty_port *port); bool (*carrier_raised)(struct tty_port *port);
void (*dtr_rts)(struct tty_port *port, int raise); void (*dtr_rts)(struct tty_port *port, int raise);
void (*shutdown)(struct tty_port *port); void (*shutdown)(struct tty_port *port);
int (*activate)(struct tty_port *port, struct tty_struct *tty); int (*activate)(struct tty_port *port, struct tty_struct *tty);
...@@ -230,7 +230,7 @@ static inline void tty_port_set_kopened(struct tty_port *port, bool val) ...@@ -230,7 +230,7 @@ static inline void tty_port_set_kopened(struct tty_port *port, bool val)
struct tty_struct *tty_port_tty_get(struct tty_port *port); struct tty_struct *tty_port_tty_get(struct tty_port *port);
void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty); void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty);
int tty_port_carrier_raised(struct tty_port *port); bool tty_port_carrier_raised(struct tty_port *port);
void tty_port_raise_dtr_rts(struct tty_port *port); void tty_port_raise_dtr_rts(struct tty_port *port);
void tty_port_lower_dtr_rts(struct tty_port *port); void tty_port_lower_dtr_rts(struct tty_port *port);
void tty_port_hangup(struct tty_port *port); void tty_port_hangup(struct tty_port *port);
......
...@@ -119,7 +119,7 @@ static int rfcomm_dev_activate(struct tty_port *port, struct tty_struct *tty) ...@@ -119,7 +119,7 @@ static int rfcomm_dev_activate(struct tty_port *port, struct tty_struct *tty)
} }
/* we block the open until the dlc->state becomes BT_CONNECTED */ /* we block the open until the dlc->state becomes BT_CONNECTED */
static int rfcomm_dev_carrier_raised(struct tty_port *port) static bool rfcomm_dev_carrier_raised(struct tty_port *port)
{ {
struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port); struct rfcomm_dev *dev = container_of(port, struct rfcomm_dev, port);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment