Skip to content

Commit c74e50e

Browse files
agugliestappersg
authored andcommitted
feat: added get_serial to tty_operations
Expose the existing serial info retrieval functionality through the get_serial operation in tty_operations instead of only through ioctl. This allows tools like setserial to properly query the device information.
1 parent 9452a60 commit c74e50e

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

module/tty0tty.c

+25
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,30 @@ static int tty0tty_ioctl(struct tty_struct *tty,
647647
return -ENOIOCTLCMD;
648648
}
649649

650+
static int tty0tty_get_serial(struct tty_struct *tty, struct serial_struct *p)
651+
{
652+
DEBUG_PRINTK(KERN_DEBUG "%s - \n", __FUNCTION__);
653+
struct tty0tty_serial *tty0tty = tty->driver_data;
654+
655+
if (!tty0tty)
656+
return -ENODEV;
657+
658+
p->type = tty0tty->serial.type;
659+
p->line = tty0tty->serial.line;
660+
p->port = tty0tty->serial.port;
661+
p->irq = tty0tty->serial.irq;
662+
p->flags = ASYNC_SKIP_TEST | ASYNC_AUTO_IRQ;
663+
p->xmit_fifo_size = tty0tty->serial.xmit_fifo_size;
664+
p->baud_base = tty0tty->serial.baud_base;
665+
p->close_delay = 5 * HZ;
666+
p->closing_wait = 30 * HZ;
667+
p->custom_divisor = tty0tty->serial.custom_divisor;
668+
p->hub6 = tty0tty->serial.hub6;
669+
p->io_type = tty0tty->serial.io_type;
670+
671+
return 0;
672+
}
673+
650674
static struct tty_operations serial_ops = {
651675
.open = tty0tty_open,
652676
.close = tty0tty_close,
@@ -656,6 +680,7 @@ static struct tty_operations serial_ops = {
656680
.tiocmget = tty0tty_tiocmget,
657681
.tiocmset = tty0tty_tiocmset,
658682
.ioctl = tty0tty_ioctl,
683+
.get_serial = tty0tty_get_serial,
659684
};
660685

661686
static struct tty_driver *tty0tty_tty_driver;

0 commit comments

Comments
 (0)