Module_init (s3c24xx_serial_modinit );

Source: Internet
Author: User

Static struct uart_driver s3c24xx_uart_drv = {
. Owner = this_module,
. Driver_name = "s3c2410_serial ",
. Nr = config_serial_samsung_uarts,
. Cons = s3c24xx_serial_console,
. Dev_name = s3c24xx_serial_name,
. Major = s3c24xx_serial_major,
. Minor = s3c24xx_serial_minor,
};

/**

* Uart_register_driver-register a driver with the UART core layer
* @ DRV: low level driver structure
*
* Register a UART driver with the core driver. We in turn register
* With the TTY layer, and initialise the core driver per-port State.
*
* We have a proc file in/proc/tty/driver which is named after
* Normal driver.
*
* DRV-> port shocould be null, and the per-port structures shocould be
* Registered using uart_add_one_port after this call has succeeded.
*/
Int uart_register_driver (struct uart_driver * DRV)
{
Struct tty_driver * normal;
Int I, retval;

Bug_on (DRV-> State );

/*
* Maybe we shoshould be using a slab cache for this, especially if
* We have a large number of ports to handle.
*/
DRV-> state = kzarloc (sizeof (struct uart_state) * DRV-> NR, gfp_kernel );
If (! DRV-> state)
Goto out;

Normal = alloc_tty_driver (DRV-> nr );
If (! Normal)
Goto out_kfree;

DRV-> tty_driver = normal;

Normal-> owner = DRV-> owner;
Normal-> driver_name = DRV-> driver_name;
Normal-> name = DRV-> dev_name;
Normal-> major = DRV-> Major;
Normal-> minor_start = DRV-> minor;
Normal-> type = tty_driver_type_serial;
Normal-> subtype = serial_type_normal;
Normal-> init_termios = tty_std_termios;
Normal-> init_termios.c_cflag = b9600 | cs8 | cread | hupcl | clocal;
Normal-> init_termios.c_ispeed = normal-> init_termios.c_ospeed= 9600;
Normal-> flags = tty_driver_real_raw | tty_driver_dynamic_dev;
Normal-> driver_state = DRV;
Tty_set_operations (normal, & uart_ops );

/*
* Initialise the UART State (s ).
*/
For (I = 0; I <DRV-> NR; I ++ ){
Struct uart_state * State = DRV-> state + I;
Struct tty_port * Port = & State-> port;

Tty_port_init (port );
Port-> Ops = & uart_port_ops;
Port-> close_delay = 500;/*. 5 seconds */
Port-> closing_wait = 30000;/* 30 seconds */
Tasklet_init (& State-> tlet, uart_tasklet_action,
(Unsigned long) State );
}

Retval = tty_register_driver (normal );
If (retval> = 0)
Return retval;

Put_tty_driver (normal );
Out_kfree:
Kfree (DRV-> State );
Out:
Return-enomem;

}

Static int _ init s3c24xx_serial_modinit (void)
{
Int ret;

Ret = uart_register_driver (& s3c24xx_uart_drv );
If (Ret <0 ){
Printk (kern_err "failed to register UART driver \ n ");
Return-1;
}

Return 0;
}

Module_init (s3c24xx_serial_modinit );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.