- 论坛徽章:
- 0
|
下文是一个串口驱动,我把它从2.4内核移植到2.6内核,只列出了几行代码,请大家帮我看看对不对,谢谢。
(一) linux 2.4的旧代码
void irq_handler(int irq,void *dev_id,struct pt_regs *regs)
{
static unsigned char serial_in_byte;
static unsigned outbuf_has_data;
static struct tq_struct task = {
{ NULL },
0 ,
serial_char_buffer_in,
&serial_in_byte,
};
unsigned int intID_reg, intID;
intID_reg = inb_p(combase+2); /* read interrupt ID register */
intID = intID_reg & 0x0f;
switch (intID) {
case 0x00: /* modem status changed */
modem_status = inb_p(combase+6); /* read MSR */
break;
case 0x01: /* no interrupt active */
break;
(二) linux 2.6 的改动
// 1. 2.6的内核中断处理函数是有类型的
irqreturn_t irq_handler(int irq,void *dev_id,struct pt_regs *regs)
{
static unsigned char serial_in_byte;
static unsigned outbuf_has_data;
// 2. 2.6内核的任务队列声明和使用都发生了变化
static DECLARE_WORK(task, serial_char_buffer_in);
unsigned int intID_reg, intID;
intID_reg = inb_p(combase+2); /* read interrupt ID register */
intID = intID_reg & 0x0f;
switch (intID) {
case 0x00: /* modem status changed */
modem_status = inb_p(combase+6); /* read MSR */
break;
case 0x01: /* no interrupt active */
break; |
|