2011-04-13 136 views
3

我已经有一些Linux驱动程序可以直接从制造商处购买一些canbus硬件,但它们已经过时(至少对我的内核来说),让我为自己谋生。在跳过一些圈之后,我编译时遇到了一个单一的错误,但这是我似乎无法动摇的错误。Linux驱动程序和device.h

的错误是这样的:

./src/esdcan_pci.c:353:9: error: ‘struct device’ has no member named ‘driver_data’ 

很多互联网的侦探之后我几乎可以肯定它与我的内核device.h中头文件做。我打开了头文件并查看了结构,果然,没有名为driver_data的成员。我不确定的是什么成员是等同的,或者如果有的话。这里的结构在我的头文件版本:

struct device { 
    struct device  *parent; 

    struct device_private *p; 

    struct kobject kobj; 
    const char  *init_name; /* initial name of the device */ 
    struct device_type *type; 

    struct mutex  mutex; /* mutex to synchronize calls to 
        * its driver. 
        */ 

    struct bus_type *bus;  /* type of bus device is on */ 
    struct device_driver *driver; /* which driver has allocated this 
         device */ 
    void  *platform_data; /* Platform specific data, device 
         core doesn't touch it */ 
    struct dev_pm_info power; 

#ifdef CONFIG_NUMA 
    int  numa_node; /* NUMA node this device is close to */ 
#endif 
    u64  *dma_mask; /* dma mask (if dma'able device) */ 
    u64  coherent_dma_mask;/* Like dma_mask, but for 
         alloc_coherent mappings as 
         not all hardware supports 
         64 bit addresses for consistent 
         allocations such descriptors. */ 

    struct device_dma_parameters *dma_parms; 

    struct list_head dma_pools; /* dma pools (if dma'ble) */ 

    struct dma_coherent_mem *dma_mem; /* internal for coherent mem 
         override */ 
    /* arch specific additions */ 
    struct dev_archdata archdata; 
#ifdef CONFIG_OF 
    struct device_node *of_node; 
#endif 

    dev_t   devt; /* dev_t, creates the sysfs "dev" */ 

    spinlock_t  devres_lock; 
    struct list_head devres_head; 

    struct klist_node knode_class; 
    struct class  *class; 
    const struct attribute_group **groups; /* optional groups */ 

    void (*release)(struct device *dev); 
}; 

作为,这是我第一次编译Linux驱动程序,我不知道我在看。有没有人有这方面的经验,可能会放弃一些提示?谢谢。

+1

包含驱动程序期望的内核版本以及您使用的版本将会很有帮助。 – Jonathan 2011-04-13 13:52:16

+0

我正在运行2.6.35.12-88.fc14.x86_64。我不知道司机期望什么。我最好的参考是文档指出,对于2.6.0以上的内核,你需要有root权限来编译,所以我认为它至少预计2.6.0。 – iegod 2011-04-13 14:01:13

回答

5

驱动程序模型已切换为使用void * dev_get_drvdata(const struct device *dev)void dev_set_drvdata(struct device *dev, void * data),而不是直接操作struct device成员。您可以在include/linux/device.h中找到这些函数的原型几乎每个设备驱动程序都使用这些调用,因此您可以毫无困难地找到示例。

但有一点需要注意的是,几个子系统(包括PCI)具有这些功能的子系统特定版本的外观:pci_get_drvdata()。但是,这些仅仅是围绕dev_*函数的包装。

+0

完美。现在替换所有这些宏。干杯! – iegod 2011-04-13 14:48:39