TTY: add tty_port_tty_hangup helper
It allows for cleaning up on a considerable amount of places. They did port_get, hangup, kref_put. Now the only thing needed is to call tty_port_tty_hangup which does exactly that. And they can also decide whether to consider CLOCAL or completely ignore that. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
e4408ce3c2
commit
aa27a094e2
@@ -269,23 +269,6 @@ static void mrdy_assert(struct ifx_spi_device *ifx_dev)
|
||||
mrdy_set_high(ifx_dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* ifx_spi_hangup - hang up an IFX device
|
||||
* @ifx_dev: our SPI device
|
||||
*
|
||||
* Hang up the tty attached to the IFX device if one is currently
|
||||
* open. If not take no action
|
||||
*/
|
||||
static void ifx_spi_ttyhangup(struct ifx_spi_device *ifx_dev)
|
||||
{
|
||||
struct tty_port *pport = &ifx_dev->tty_port;
|
||||
struct tty_struct *tty = tty_port_tty_get(pport);
|
||||
if (tty) {
|
||||
tty_hangup(tty);
|
||||
tty_kref_put(tty);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ifx_spi_timeout - SPI timeout
|
||||
* @arg: our SPI device
|
||||
@@ -298,7 +281,7 @@ static void ifx_spi_timeout(unsigned long arg)
|
||||
struct ifx_spi_device *ifx_dev = (struct ifx_spi_device *)arg;
|
||||
|
||||
dev_warn(&ifx_dev->spi_dev->dev, "*** SPI Timeout ***");
|
||||
ifx_spi_ttyhangup(ifx_dev);
|
||||
tty_port_tty_hangup(&ifx_dev->tty_port, false);
|
||||
mrdy_set_low(ifx_dev);
|
||||
clear_bit(IFX_SPI_STATE_TIMER_PENDING, &ifx_dev->flags);
|
||||
}
|
||||
@@ -933,7 +916,7 @@ static irqreturn_t ifx_spi_reset_interrupt(int irq, void *dev)
|
||||
set_bit(MR_INPROGRESS, &ifx_dev->mdm_reset_state);
|
||||
if (!solreset) {
|
||||
/* unsolicited reset */
|
||||
ifx_spi_ttyhangup(ifx_dev);
|
||||
tty_port_tty_hangup(&ifx_dev->tty_port, false);
|
||||
}
|
||||
} else {
|
||||
/* exited reset */
|
||||
|
Reference in New Issue
Block a user