科创园

科创园地,分享技术知识,为科技助力发展,贡献一己之力。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
上一页 1 2 3 4 5 6 7 ··· 12 下一页

2014年4月1日

摘要: 现在开始就沿着usb_generic_driver的生命线继续往下走。设备的生命线你可以为是从你的usb设备连接到hub的某个端口时开始,而驱动的生命线就必须得回溯到usb子系统的初始化函数usb_init了。if (retval)goto hub_init_failed;retval = usb_register_device_driver(&usb_generic_driver, THIS_MODULE);if (!retval)goto out;在usb子系统初始化的时候就调用driver.c里的usb_register_device_driver函数将usb_generic_d 阅读全文

posted @ 2014-04-01 11:04 科创园 阅读(2158) 评论(0) 推荐(0) 编辑

摘要: 现在已经使用GET_DESCRIPTOR请求取到了包含一个配置里所有相关描述符内容的一堆数据,这些数据是raw的,即原始的,所有数据不管是配置描述符、接口描述符还是端点描述符都挤在一起,所以得想办法将它们给分开。,于是usb_parse_configuration()就做这些事。static int usb_parse_configuration(struct device *ddev, int cfgidx, struct usb_host_config *config, unsigned char *buffer, int size){ unsigned char *buffer0 ... 阅读全文

posted @ 2014-04-01 10:45 科创园 阅读(1843) 评论(1) 推荐(1) 编辑

摘要: 拜会完了山头的几位大哥,还记得我们从哪里来要到哪里去吗?时刻不能忘记自身的使命啊。我们是从usb_submit_urb()最后的那个遗留问题usb_hcd_submit_urb()函数一路走来,现在就要去分析usb_hcd_submit_urb()里面的内容。/* may be called in any context with a valid urb->dev usecount * caller surrenders "ownership" of urb * expects usb_submit_urb() to have sanity checked and c 阅读全文

posted @ 2014-04-01 10:39 科创园 阅读(1604) 评论(0) 推荐(0) 编辑

摘要: 回到struct usb_hcd,继续努力的往下看。kref,usb主机控制器的引用计数。struct usb_hcd也有自己专用的引用计数函数,看hcd.c文件。static void hcd_release (struct kref *kref){ struct usb_hcd *hcd = container_of (kref, struct usb_hcd, kref); kfree(hcd);}struct usb_hcd *usb_get_hcd (struct usb_hcd *hcd){ if (hcd) kref_get (&hcd->kref); return 阅读全文

posted @ 2014-04-01 10:35 科创园 阅读(1137) 评论(0) 推荐(0) 编辑

2014年3月31日

摘要: 总算是进入了HCD的片儿区,既然来到一个片区,怎么都要去拜会一下山头几个大哥吧。,先回忆一些我们怎么到这里的?给你列举一个调用函数过程usb_control_msg->usb_internal_control_msg->usb_start_wait_urb->usb_submit_urb->usb_hcd_submit_urb。这个山头儿,王中之王就是drivers/usb/core/hcd.h里定义的struct usb_hcd。/*-------------------------------------------------------------------- 阅读全文

posted @ 2014-03-31 18:23 科创园 阅读(1444) 评论(0) 推荐(0) 编辑

摘要: 直接看代码吧。 /*-------------------------------------------------------------------*//** * usb_submit_urb - issue an asynchronous transfer request for an endpoint * @urb: pointer to the urb describing the request * @mem_flags: the type of memory to allocate, see kmalloc() for a list * of valid options ... 阅读全文

posted @ 2014-03-31 18:22 科创园 阅读(2420) 评论(0) 推荐(0) 编辑

摘要: 上一节勉勉强强把struct urb这个中心给说完,接着看那三个基本点。第一个基本点,usb_alloc_urb函数,创建urb的专用函数,为一个urb申请内存并做初始化,在drviers/usb/core/urb.c里定义。/** * usb_alloc_urb - creates a new urb for a USB driver to use * @iso_packets: number of iso packets for this urb * @mem_flags: the type of memory to allocate, see kmalloc() for a list o 阅读全文

posted @ 2014-03-31 18:19 科创园 阅读(1578) 评论(0) 推荐(0) 编辑

摘要: 函数usb_control_msg完成一些初始化后调用了usb_internal_control_msg之后就free urb。剩下的活,全部留给usb_internal_control_msg去做了,那就去了解一下它背后的生活吧。/*-------------------------------------------------------------------*/// returns status (negative) or length (positive)static int usb_internal_control_msg(struct usb_device *usb_dev, 阅读全文

posted @ 2014-03-31 18:18 科创园 阅读(3887) 评论(1) 推荐(1) 编辑

2014年3月30日

摘要: 暂时先告别媒人,我们去分析各自的生命旅程,最后还会回到usb_device_match函数。首先当你将usb设备连接在hub的某个端口上,hub检测到有设备连接了进来,它会为设备分配一个struct usb_device结构的对象并初始化,并调用设备模型提供的接口将设备添加到usb总线的设备列表里,然后usb总线会遍历驱动列表里的每个驱动,调用自己的match函数看它们和你的设备或接口是否匹配。hub检测到自己的某个端口有设备连接了进来后,它会调用core里的usb_alloc_dev函数为struct usb_device结构的对象申请内存,这个函数在drivers/usb/core/usb 阅读全文

posted @ 2014-03-30 23:10 科创园 阅读(2292) 评论(0) 推荐(0) 编辑

摘要: 在第五节我们说过会专门分析函数usb_device_match,以体现模型的重要性。同时,我们还是要守信用的。再贴一遍代码,看代码就要不厌其烦。static int usb_device_match(struct device *dev, struct device_driver *drv){ /* devices and interfaces are handled separately */ if (is_usb_device(dev)) { /* interface drivers never match devices */ if (!is_usb_device_driver(dr.. 阅读全文

posted @ 2014-03-30 22:41 科创园 阅读(6725) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 ··· 12 下一页