首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

linux 2.6下编译usb驱动和arm板进行数据通信(6)

linux 2.6下编译usb驱动和arm板进行数据通信(6)

static void lcd_disconnect(struct usb_interface *interface)
{
    struct usb_lcd *dev;
        int minor = interface->minor;

        /* prevent skel_open() from racing skel_disconnect() */
        mutex_lock(&usb_lcd_open_mutex);

        dev = usb_get_intfdata(interface);
        usb_set_intfdata(interface, NULL);

        /* give back our minor */
        usb_deregister_dev(interface, &lcd_class);

    mutex_unlock(&usb_lcd_open_mutex);

    /* decrement our usage count */
    kref_put(&dev->kref, lcd_delete);

    info("USB LCD #%d now disconnected", minor);
}

static struct usb_driver lcd_driver = {
    .name =        "usblcd",
    .probe =    lcd_probe,
    .disconnect =    lcd_disconnect,
    .id_table =    id_table,
};

static int __init usb_lcd_init(void)
{
    int result;
   
    result = usb_register(&lcd_driver);
    if (result)
        err("usb_register failed. Error number %d", result);

    return result;
}


static void __exit usb_lcd_exit(void)
{
    usb_deregister(&lcd_driver);
}

module_init(usb_lcd_init);
module_exit(usb_lcd_exit);

MODULE_AUTHOR("Georges Toth ");
MODULE_DESCRIPTION(DRIVER_VERSION);
MODULE_LICENSE("GPL");


luther@gliethttp:~/work/kernel/module_drivers/gliethttp_flash$ echo "obj-m:=gliethttp_flash.o" > Makefile


luther@gliethttp:~/work/kernel/module_drivers/gliethttp_flash$ make -C /lib/modules/`uname -r`/build M=`pwd` modules
make: Entering directory `/usr/src/linux-headers-2.6.22-14-generic'
  CC [M]  /home/luther/work/kernel/module_drivers/gliethttp_flash/gliethttp_flash.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/luther/work/kernel/module_drivers/gliethttp_flash/gliethttp_flash.mod.o
  LD [M]  /home/luther/work/kernel/module_drivers/gliethttp_flash/gliethttp_flash.ko
make: Leaving directory `/usr/src/linux-headers-2.6.22-14-generic'

luther@gliethttp:~/work/kernel/module_drivers/gliethttp_flash$


luther@gliethttp:~/work/kernel/module_drivers/gliethttp_flash$ ls /dev/gliethttp_flash0
/dev/gliethttp_flash0
luther@gliethttp:~/work/kernel/module_drivers/gliethttp_flash$
继承事业,薪火相传
返回列表