升级内核到4.1.3后,Struct API发生了变化

时间:2015-08-06 12:38:45

标签: linux-kernel

struct net_device没有名为pm_qos_req的成员。

我在哪里可以找到相关的API结构?

1 个答案:

答案 0 :(得分:1)

简短回答

pm_qos_req中的

struct net_device字段仅用于e1000e驱动程序,因此决定将此字段移至e1000e驱动程序结构,以便其他使用的驱动程序分配struct net_device时,struct net_device不会浪费几个字节的内存。有关详细信息,请参阅e2c6544829 commit。

如果您正在开发e1000e驱动程序并遇到问题,可以将e2c6544829提交到内核基线。

否则,如果您要维护一些未经过上传并且正在使用pm_qos_req的驱动程序,请使用e2c6544829 commit作为重写驱动程序的参考。基本上,您需要将pm_qos_req字段添加到您的驱动程序结构中,并使用该结构而不是struct net_device

全面调查

以下是解决这个问题的方法:

  1. 下载主线内核:

    $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
    
  2. 结帐到相应的标签(在您的情况下,您可以跳过此步骤):

    $ git checkout v4.1-rc3
    

    v4.1-rc3是一个标签;所有标签都可以通过git tag命令列出)

  3. 使用git搜索pm_qos_req文件中更改的include/linux/netdevice.h文字:

    $ git log -S'pm_qos_req' --oneline -- include/linux/netdevice.h
    

    它将为您提供下一次提交:

    01d460d   net: Remove remaining remnants of pm_qos from netdevice.h
    e2c6544   e1000e: Move pm_qos_req to e1000e adapter
    536721b   net: kernel-doc compliant documentation for net_device
    ed77134   PM QOS update
    

    该列表中的最高提交是最后一次提交(最近添加)。

  4. 使用git show命令查看感兴趣的提交。您对e2c6544提交特别感兴趣(从.pm_qos_req移除了struct net_device):

    $ git show e2c6544
    

    注意提交消息:

    e1000e is the only driver requiring pm_qos_req, instead of causing
    every device to waste up to 240 bytes. Allocate it for the specific
    driver.
    
  5. 现在我们可以查看以前的内核版本,并检查哪些驱动程序正在使用此pm_qos_req字段。

    $ git grep -n '\bpm_qos_req\b' v3.0 -- drivers/
    

    grep输出我们可以看到只有e1000e驱动程序正在使用此字段。