UART驱动层是在tty驱动层上对常用的异步通信串口做了封装,简化了串口驱动的编写。从测试结果来看,在2.6.32和3.12.74内核下编译和运行遇到的问题基本相同,相比tty驱动容易移植得多,这就是封装的好处。
编译
error: ‘struct uart_port’ has no member named ‘info’
info 信息已改成使用 "struct uart_state *state":
struct circ_buf *xmit = &port->state->xmit;
warning: passing argument 1 of ‘tty_insert_flip_char’ from incompatible pointer type
note: expected ‘struct tty_port *’ but argument is of type ‘struct tty_struct *’
flip buffer接口改成 tty_port, 可以从 state 信息得到:
static void tiny_timer(unsigned long data)
{
struct uart_port *port;
struct tty_port *tport;
...
tport = &port->state->port;
...
tty_insert_flip_char(tport, TINY_DATA_CHARACTER, 0);
tty_flip_buffer_push(tport);
...
}
2.6.32内核则使用
tty = port->state->port.tty
warning: passing argument 2 of ‘uart_get_baud_rate’ from incompatible pointer type
note: expected ‘struct ktermios *’ but argument is of type ‘struct termios *’
set_termios 函数参数改为 struct ktermios *:
static void tiny_set_termios(struct uart_port *port,
struct ktermios *new, struct ktermios *old)
warning: initialization from incompatible pointer type
warning: (near initialization for ‘tiny_ops.stop_tx’)
warning: (near initialization for ‘tiny_ops.start_tx’)
start/stop_tx 函数参数发生了变化:
static void