【问题标题】:how to define struct priv_struct of net_device?如何定义net_device的struct priv_struct?
【发布时间】:2016-11-26 01:20:17
【问题描述】:

当设备驱动程序编写者编写驱动程序时,我注意到他们使用函数调用alloc_etherdev(sizeof(struct priv_struct)) 来分配结构struct net_device。 我的问题是关于struct priv_struct。 我不明白他们如何定义它(struct priv_struct)。 他们从哪里来? 是否存在解释如何为设备定义 priv_struct 的文档? 如果是,我在哪里可以找到这样的文件?谢谢。

【问题讨论】:

    标签: linux-device-driver


    【解决方案1】:

    这很简单。 priv_struct 是包含驱动程序所有私有数据的自定义结构的名称。 alloc_etherdev 想知道它的大小,仅此而已。由您来定义此结构。

    内核源代码非常庞大,不可能记录所有内容,因此解决问题的最快方法通常是 look into the code 本身。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-13
      • 1970-01-01
      • 2011-07-20
      • 1970-01-01
      • 1970-01-01
      • 2016-01-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多