【发布时间】:2011-04-13 13:47:15
【问题描述】:
我从制造商那里直接获得了一些适用于某些 canbus 硬件的 Linux 驱动程序,但它们已经过时(至少对于我的内核而言),让我只能自谋生路。在经历了一些麻烦之后,我在编译中发现了一个错误,但这是我似乎无法摆脱的错误。
错误是这样的:
./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 驱动程序,我不确定我在看什么。有没有人在这类领域有经验可以提供一些提示?谢谢。
【问题讨论】:
-
包含驱动程序期望的内核版本以及您正在使用的版本会很有帮助。
-
我正在运行 2.6.35.12-88.fc14.x86_64。我不知道司机期望什么。我最好的参考是文档指出对于 2.6.0 以上的内核,您需要具有 root 访问权限才能进行编译,所以我认为它至少需要 2.6.0。
标签: c linux-kernel drivers