drivers/tty/serial/serial_txx9.c

Source file repositories/reference/linux-study-clean/drivers/tty/serial/serial_txx9.c

File Facts

System
Linux kernel
Corpus path
drivers/tty/serial/serial_txx9.c
Extension
.c
Size
30913 bytes
Lines
1269
Domain
Driver Families
Bucket
drivers/tty
Inferred role
Driver Families: operation-table or driver-model contract
Status
pattern implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

static struct pci_driver serial_txx9_pci_driver = {
	.name		= "serial_txx9",
	.probe		= pciserial_txx9_init_one,
	.remove		= pciserial_txx9_remove_one,
#ifdef CONFIG_PM
	.suspend	= pciserial_txx9_suspend_one,
	.resume		= pciserial_txx9_resume_one,
#endif
	.id_table	= serial_txx9_pci_tbl,
};

MODULE_DEVICE_TABLE(pci, serial_txx9_pci_tbl);
#endif /* ENABLE_SERIAL_TXX9_PCI */

static struct platform_device *serial_txx9_plat_devs;

static int __init serial_txx9_init(void)
{
	int ret;

	ret = uart_register_driver(&serial_txx9_reg);
	if (ret)
		goto out;

	serial_txx9_plat_devs = platform_device_alloc("serial_txx9", -1);
	if (!serial_txx9_plat_devs) {
		ret = -ENOMEM;
		goto unreg_uart_drv;
	}

	ret = platform_device_add(serial_txx9_plat_devs);
	if (ret)
		goto put_dev;

	serial_txx9_register_ports(&serial_txx9_reg,
				   &serial_txx9_plat_devs->dev);

	ret = platform_driver_register(&serial_txx9_plat_driver);
	if (ret)
		goto del_dev;

#ifdef ENABLE_SERIAL_TXX9_PCI
	ret = pci_register_driver(&serial_txx9_pci_driver);
	if (ret) {
		platform_driver_unregister(&serial_txx9_plat_driver);
	}
#endif
	if (ret == 0)
		goto out;

 del_dev:
	platform_device_del(serial_txx9_plat_devs);
 put_dev:
	platform_device_put(serial_txx9_plat_devs);
 unreg_uart_drv:
	uart_unregister_driver(&serial_txx9_reg);
 out:
	return ret;
}

static void __exit serial_txx9_exit(void)
{
	int i;

#ifdef ENABLE_SERIAL_TXX9_PCI
	pci_unregister_driver(&serial_txx9_pci_driver);
#endif
	platform_driver_unregister(&serial_txx9_plat_driver);
	platform_device_unregister(serial_txx9_plat_devs);
	for (i = 0; i < UART_NR; i++) {
		struct uart_port *up = &serial_txx9_ports[i];
		if (up->iobase || up->mapbase)
			uart_remove_one_port(&serial_txx9_reg, up);
	}

	uart_unregister_driver(&serial_txx9_reg);
}

module_init(serial_txx9_init);
module_exit(serial_txx9_exit);

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("TX39/49 serial driver");

MODULE_ALIAS_CHARDEV_MAJOR(TXX9_TTY_MAJOR);

Annotation

Implementation Notes