summaryrefslogtreecommitdiff
path: root/drivers/tty/mxser.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2021-06-18 08:14:48 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-06-18 13:10:01 +0200
commitb441eb0f69d19cddf2018ded38a5f3ea7e392836 (patch)
tree4a9dfa5882a758fc307ffa978043a7ec6907cdab /drivers/tty/mxser.c
parentb286484b3bb1d01dfd6095f01c8ad04b78f1a625 (diff)
mxser: clean up the rest of MUST helpers
Clean up the rest of MUST helpers. They all can use the newly added mxser_must_set_EFR. And passing a bool instead of having two functions (_enable+_disable) simplifies the code a lot too. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20210618061516.662-43-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/mxser.c')
-rw-r--r--drivers/tty/mxser.c97
1 files changed, 12 insertions, 85 deletions
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index 392aee47c803..ff85a6e15d9d 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -391,81 +391,21 @@ static void mxser_must_set_enhance_mode(unsigned long baseio, bool enable)
enable ? MOXA_MUST_EFR_EFRB_ENABLE : 0);
}
-static void SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(unsigned long baseio)
+static void mxser_must_no_sw_flow_control(unsigned long baseio)
{
- u8 oldlcr;
- u8 efr;
-
- oldlcr = inb(baseio + UART_LCR);
- outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
- efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
- efr &= ~MOXA_MUST_EFR_SF_MASK;
-
- outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
- outb(oldlcr, baseio + UART_LCR);
-}
-
-static void mxser_enable_must_tx_software_flow_control(unsigned long baseio)
-{
- u8 oldlcr;
- u8 efr;
-
- oldlcr = inb(baseio + UART_LCR);
- outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
- efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
- efr &= ~MOXA_MUST_EFR_SF_TX_MASK;
- efr |= MOXA_MUST_EFR_SF_TX1;
-
- outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
- outb(oldlcr, baseio + UART_LCR);
-}
-
-static void mxser_disable_must_tx_software_flow_control(unsigned long baseio)
-{
- u8 oldlcr;
- u8 efr;
-
- oldlcr = inb(baseio + UART_LCR);
- outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
- efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
- efr &= ~MOXA_MUST_EFR_SF_TX_MASK;
-
- outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
- outb(oldlcr, baseio + UART_LCR);
+ mxser_must_set_EFR(baseio, MOXA_MUST_EFR_SF_MASK, 0);
}
-static void mxser_enable_must_rx_software_flow_control(unsigned long baseio)
+static void mxser_must_set_tx_sw_flow_control(unsigned long baseio, bool enable)
{
- u8 oldlcr;
- u8 efr;
-
- oldlcr = inb(baseio + UART_LCR);
- outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
- efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
- efr &= ~MOXA_MUST_EFR_SF_RX_MASK;
- efr |= MOXA_MUST_EFR_SF_RX1;
-
- outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
- outb(oldlcr, baseio + UART_LCR);
+ mxser_must_set_EFR(baseio, MOXA_MUST_EFR_SF_TX_MASK,
+ enable ? MOXA_MUST_EFR_SF_TX1 : 0);
}
-static void mxser_disable_must_rx_software_flow_control(unsigned long baseio)
+static void mxser_must_set_rx_sw_flow_control(unsigned long baseio, bool enable)
{
- u8 oldlcr;
- u8 efr;
-
- oldlcr = inb(baseio + UART_LCR);
- outb(MOXA_MUST_ENTER_ENCHANCE, baseio + UART_LCR);
-
- efr = inb(baseio + MOXA_MUST_EFR_REGISTER);
- efr &= ~MOXA_MUST_EFR_SF_RX_MASK;
-
- outb(efr, baseio + MOXA_MUST_EFR_REGISTER);
- outb(oldlcr, baseio + UART_LCR);
+ mxser_must_set_EFR(baseio, MOXA_MUST_EFR_SF_RX_MASK,
+ enable ? MOXA_MUST_EFR_SF_RX1 : 0);
}
static enum mxser_must_hwid mxser_must_get_hwid(unsigned long io)
@@ -746,20 +686,8 @@ static void mxser_change_speed(struct tty_struct *tty)
if (info->board->must_hwid) {
mxser_set_must_xon1_value(info->ioaddr, START_CHAR(tty));
mxser_set_must_xoff1_value(info->ioaddr, STOP_CHAR(tty));
- if (I_IXON(tty)) {
- mxser_enable_must_rx_software_flow_control(
- info->ioaddr);
- } else {
- mxser_disable_must_rx_software_flow_control(
- info->ioaddr);
- }
- if (I_IXOFF(tty)) {
- mxser_enable_must_tx_software_flow_control(
- info->ioaddr);
- } else {
- mxser_disable_must_tx_software_flow_control(
- info->ioaddr);
- }
+ mxser_must_set_rx_sw_flow_control(info->ioaddr, I_IXON(tty));
+ mxser_must_set_tx_sw_flow_control(info->ioaddr, I_IXOFF(tty));
}
@@ -946,7 +874,7 @@ static void mxser_shutdown_port(struct tty_port *port)
if (info->board->must_hwid)
- SET_MOXA_MUST_NO_SOFTWARE_FLOW_CONTROL(info->ioaddr);
+ mxser_must_no_sw_flow_control(info->ioaddr);
spin_unlock_irqrestore(&info->slock, flags);
}
@@ -1585,8 +1513,7 @@ static void mxser_set_termios(struct tty_struct *tty, struct ktermios *old_termi
if (info->board->must_hwid) {
spin_lock_irqsave(&info->slock, flags);
- mxser_disable_must_rx_software_flow_control(
- info->ioaddr);
+ mxser_must_set_rx_sw_flow_control(info->ioaddr, false);
spin_unlock_irqrestore(&info->slock, flags);
}