网卡驱动程序的一个重要数据结构

在/usr/src/linux/linux-2.6.20.1/include/linux/pci.h中找到的。根据内核版本的不同和源代码安装的位置不同,位置可能略有不同。
  struct pci_driver {
   struct list_head node;
   char *name;
   const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */
   int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
   void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
   int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */
   int (*suspend_late) (struct pci_dev *dev, pm_message_t state);
   int (*resume_early) (struct pci_dev *dev);
   int (*resume) (struct pci_dev *dev); /* Device woken up */
   int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */
   void (*shutdown) (struct pci_dev *dev);
   struct pci_error_handlers *err_handler;
   struct device_driver driver;
   struct pci_dynids dynids;
   int multithread_probe;
  };
  好长!看看下面的代码就明白了,这个是PCI网卡驱动的数据结构!再看看网卡驱动内核模块的注册部分!
  下面的代码来自via_rhine.c
  static struct pci_driver rhine_driver = {
   .name = DRV_NAME,
   .id_table = rhine_pci_tbl,
   .probe = rhine_init_one,
   .remove = __devexit_p(rhine_remove_one),
  #ifdef CONFIG_PM
   .suspend = rhine_suspend,
   .resume = rhine_resume,
  #endif /* CONFIG_PM */
   .shutdown = rhine_shutdown,
  };
  下面的代码来自8139cp.c
  static struct pci_driver cp_driver = {
   .name = DRV_NAME,
   .id_table = cp_pci_tbl,
   .probe = cp_init_one,
   .remove = cp_remove_one,
  #ifdef CONFIG_PM
   .resume = cp_resume,
   .suspend = cp_suspend,
  #endif
  };
  下面的代码来自8139too.c
  static struct pci_driver rtl8139_pci_driver = {
   .name = DRV_NAME,
   .id_table = rtl8139_pci_tbl,
   .probe = rtl8139_init_one,
   .remove = __devexit_p(rtl8139_remove_one),
  #ifdef CONFIG_PM
   .suspend = rtl8139_suspend,
   .resume = rtl8139_resume,
  #endif /* CONFIG_PM */
  };
  都差不多吧!其重点是函数指针的使用。越来越有才了! 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值