I've got some Linux drivers for some canbus hardware direct from the manufacturer, but they're out of date (for my kernel at least), leaving me to fend for myself. After jumping through some hoops I'm down to a single error in compilation, but it's one I can't seem to shake.
The error is this:
./src/esdcan_pci.c:353:9: error: ‘struct device’ has no member named ‘driver_data’
After much internet sleuthing I'm almost sure it has to do with the header file for my kernel device.h. I've opened the header and taken a look at the struct, and sure enough, there is no member named driver_data. What I'm not sure about is what member would be the equivalent, or if there is one at all. Here's the version of the struct in my header file:
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);
};
Being that this is my first time compiling a linux driver, I'm not sure what I'm looking at. Does anyone have experience in this sort of area that might be able to drop some hints? Thanks.
The driver model has switched to using void * dev_get_drvdata( const struct device *dev )
and void dev_set_drvdata( struct device *dev, void * data)
rather than direct manipulation of struct device
members. You'll find the prototypes for these functions in include/linux/device.h
Almost every device driver uses these calls so you'll have no trouble finding examples.
One thing to note though is that several subsystems (including PCI) have what look like subsystem-specific versions of these functions: pci_get_drvdata()
. However, these are just wrappers around the dev_*
functions.
精彩评论