lorry
驱动牛犊
驱动牛犊
  • 注册日期2004-02-10
  • 最后登录2007-03-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
阅读:994回复:1

ask ask!!

楼主#
更多 发布于:2004-05-11 21:18
以下 程序应该包含哪里的文件?

如何编译

自己写的,有什么错误,谢谢指点

谁能提供linux下与d12通信的最简单的程序

static int vender=0x1234,product=0x5678;
static int
device_open(struct inode * inode, struct file * file)
{

MOD_INC_USE_COUNT;

return 0;
}

static int
device_close(struct inode * inode, struct file * file)
{
MOD_DEC_USE_COUNT;

return 0;
}
static void *
device_probe(struct u s b_device *dev, unsigned int ifnum)
{
if (vendor != 0 || product != 0)
   info(\"U S B  Vendor:Product - %x:%x\\n\", vendor, product);


if (dev->descriptor.idVendor == vendor&&dev>descriptor.idProduct     ==produc
t )
                printk(\"U S B INSERT\");
}


static void
device_disconnect(struct u s b_device *dev, void *ptr)
{
          if (dev->descriptor.idVendor == vendor&&dev>descriptor.idProduct    
 ==product )
                printk(\"U S B DELETE\");

}

static struct
file_operations u s b_device_fops = {
NULL, /* seek */
NULL,,
NULL,
NULL, /* readdir */
NULL, /* poll */
NULL,                /* ioctl */
NULL, /* mmap */
device_open,
NULL, /* flush */
device_close,
NULL,        
NULL,                /* fasync */
};

static struct
u s b_driver device_driver = {
       \"u s bdevice\",
       device_probe,
       device_disconnect,
       { NULL, NULL },
       &u s b_device_fops,
       48
};

int
u s b_device_init(void)
{
        if (u s b_register(&device_driver) < 0)
                return -1;

info(\"U S B  support registered.\");
return 0;
}


void
u s b_device_cleanup(void)
{
u s b_deregister(&device_driver);
}

#ifdef MODULE

int
init_module(void)
{
return u s b_device_init();
}

void
cleanup_module(void)
{
u s b_device_cleanup();
}


[编辑 -  5/11/04 by  lorry]
lorry
驱动牛犊
驱动牛犊
  • 注册日期2004-02-10
  • 最后登录2007-03-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2004-05-12 19:01
谢谢
游客

返回顶部