《LINUX设备驱动程序(第二版)》的原文摘录

  • GFP_ATOMIC Used to allocate memory from interrupt handlers and other code outside of a process context. Never sleeps. GFP_KERNEL Normal allocation of kernel memory. May sleep. (查看原文)
    jeff 1赞 2015-05-24 11:18:57
    —— 引自第214页
  • struct gendisk is a dynamically allocated structure that requires special kernel manipulation to be initialized; drivers cannot allocate the structure on their own. Instead, you must call: (查看原文)
    Anana 2015-09-21 18:42:59
    —— 引自第468页
  • The minors argument should be the number of minor numbers this disk uses; note that you cannot change the minors field later and expect things to work properly. When a disk is no longer needed, it should be freed with: (查看原文)
    Anana 2015-09-21 18:42:59
    —— 引自第468页
  • A gendisk is a reference-counted structure (it contains a kobject). There are get_disk and put_disk functions available to manipulate the reference count, but drivers should never need to do that. Normally, the call to del_gendisk removes the final reference to a gendisk, but there are no guarantees of that. Thus, it is possible that the structure could continue to exist (and your methods could be called) after a call to del_gendisk. If you delete the structure when there are no users (that is, after the final release or in your module cleanup function), however, you can be sure that you will not hear from it again. Allocating a gendisk structure does not make the disk available to the system. To do that, you must initialize the structure and call add_disk: (查看原文)
    Anana 2015-09-21 18:42:59
    —— 引自第468页