当前位置:   article > 正文

s3c2440 usb host device controller驱动分析(七)-----class driver_classdriver定义

classdriver定义

      这里开始分析我们第一节贴的图中的class driver。class driver就是负责实现具体功能的driver,像usb-skeleton和usb鼠标的驱动。我认为class driver的功能应该是两个:一个是具体的操作usb device,实现具体的功能;二是像用户态提供dev的文件操作接口。

我们也用usb-skeleton为例进行分析。在这一层,还把usb device抽象成了一个设备 struct usb_skel dev。

  1. /* Structure to hold all of our device specific stuff */
  2. struct usb_skel {
  3. struct usb_device *udev; /* the usb device for this device */
  4. struct usb_interface *interface; /* the interface for this device */
  5. struct semaphore limit_sem; /* limiting the number of writes in progress */
  6. struct usb_anchor submitted; /* in case we need to retract our submissions */
  7. struct urb *bulk_in_urb; /* the urb to read data with */
  8. unsigned char *bulk_in_buffer; /* the buffer to receive data */
  9. size_t bulk_in_size; /* the size of the receive buffer */
  10. size_t bulk_in_filled; /* number of bytes in the buffer */
  11. size_t bulk_in_copied; /* already copied to user space */
  12. __u8 bulk_in_endpointAddr; /* the address of the bulk in endpoint */
  13. __u8 bulk_out_endpointAddr; /* the address of the bulk out endpoint */
  14. int errors; /* the last request tanked */
  15. int open_count; /* count the number of openers */
  16. bool ongoing_read; /* a read is going on */
  17. bool processed_urb; /* indicates we haven't processed the urb */
  18. spinlock_t err_lock; /* lock for errors */
  19. struct kref kref;
  20. struct mutex io_mutex; /* synchronize I/O with disconnect */
  21. struct completion bulk_in_completion; /* to wait for an ongoing read */
  22. };

我们看到,在class driver这一层,需要用到的gadget的信息就包含在udev、interface、bulk_in_endpointAddr、bulk_out_endpointAddr中,其实主要还是在interface中。

usb-skeleton.c中实现了两个driver。struct usb_driver skel_driver,struct usb_class_driver skel_class。


                
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/246917
推荐阅读
相关标签
  

闽ICP备14008679号