tty_port: Add a port level carrier detect operation
This is the first step to generalising the various pieces of waiting logic duplicated in all sorts of serial drivers. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
@@ -69,7 +69,7 @@ static void scc_disable_tx_interrupts(void * ptr);
|
||||
static void scc_enable_tx_interrupts(void * ptr);
|
||||
static void scc_disable_rx_interrupts(void * ptr);
|
||||
static void scc_enable_rx_interrupts(void * ptr);
|
||||
static int scc_get_CD(void * ptr);
|
||||
static int scc_carrier_raised(struct tty_port *port);
|
||||
static void scc_shutdown_port(void * ptr);
|
||||
static int scc_set_real_termios(void *ptr);
|
||||
static void scc_hungup(void *ptr);
|
||||
@@ -100,7 +100,6 @@ static struct real_driver scc_real_driver = {
|
||||
scc_enable_tx_interrupts,
|
||||
scc_disable_rx_interrupts,
|
||||
scc_enable_rx_interrupts,
|
||||
scc_get_CD,
|
||||
scc_shutdown_port,
|
||||
scc_set_real_termios,
|
||||
scc_chars_in_buffer,
|
||||
@@ -129,6 +128,10 @@ static const struct tty_operations scc_ops = {
|
||||
.break_ctl = scc_break_ctl,
|
||||
};
|
||||
|
||||
static const struct tty_port_operations scc_port_ops = {
|
||||
.carrier_raised = scc_carrier_raised,
|
||||
};
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* vme_scc_init() and support functions
|
||||
*---------------------------------------------------------------------------*/
|
||||
@@ -176,6 +179,8 @@ static void scc_init_portstructs(void)
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
port = scc_ports + i;
|
||||
tty_port_init(&port->gs.port);
|
||||
port->gs.port.ops = &scc_port_ops;
|
||||
port->gs.magic = SCC_MAGIC;
|
||||
port->gs.close_delay = HZ/2;
|
||||
port->gs.closing_wait = 30 * HZ;
|
||||
@@ -624,9 +629,9 @@ static void scc_enable_rx_interrupts(void *ptr)
|
||||
}
|
||||
|
||||
|
||||
static int scc_get_CD(void *ptr)
|
||||
static int scc_carrier_raised(struct tty_port *port)
|
||||
{
|
||||
struct scc_port *port = ptr;
|
||||
struct scc_port *scc = container_of(port, struct scc_port, gs.port);
|
||||
unsigned channel = port->channel;
|
||||
|
||||
return !!(scc_last_status_reg[channel] & SR_DCD);
|
||||
@@ -896,7 +901,7 @@ static int scc_open (struct tty_struct * tty, struct file * filp)
|
||||
return retval;
|
||||
}
|
||||
|
||||
port->c_dcd = scc_get_CD (port);
|
||||
port->c_dcd = tty_port_carrier_raised(&port->gs.port);
|
||||
|
||||
scc_enable_rx_interrupts(port);
|
||||
|
||||
|
Reference in New Issue
Block a user