主题 : 设备模型 struct device 找不到bus_id成员 复制链接 | 浏览器收藏 | 打印
级别: 侠客
UID: 28121
精华: 0
发帖: 58
金钱: 290 两
威望: 58 点
综合积分: 116 分
注册时间: 2010-09-06
最后登录: 2017-09-13
楼主  发表于: 2010-10-03 12:56

 设备模型 struct device 找不到bus_id成员

           在学习设备模型的时候,看了国嵌给的代码,但是在编译的是报错了,好像是
struct device 找不到bus_id成员,后来我在源码中找到了device这个结构,的确没有bus_id
这个成员。
      想问下这是怎么回事,在线等高手解答..........................


这是国嵌给的代码
struct device my_bus = {
    .bus_id   = "my_bus0",
    .release  = my_bus_release
};


这是 linux/device.h中的
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);
};

/* Get the wakeup routines, which depend on struct device */
#include <linux/pm_wakeup.h>

static inline const char *dev_name(const struct device *dev)
{
    /* Use the init name until the kobject becomes available */
    if (dev->init_name)
        return dev->init_name;

    return kobject_name(&dev->kobj);
}
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2010-10-04 01:03
呵呵,也许国嵌的人是为Linux 2.8的内核写的源代码
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 28121
精华: 0
发帖: 58
金钱: 290 两
威望: 58 点
综合积分: 116 分
注册时间: 2010-09-06
最后登录: 2017-09-13
2楼  发表于: 2010-10-06 15:48

 回 1楼(kasim) 的帖子

恩,貌似2.6.3x.xx的内核代码都没bus-id这个成员,哎~害的我又重新编译了一个29的内核和rootfs        
级别: 新手上路
UID: 27344
精华: 0
发帖: 7
金钱: 35 两
威望: 7 点
综合积分: 14 分
注册时间: 2010-08-24
最后登录: 2012-02-17
3楼  发表于: 2010-10-17 12:57
用dev_name(dev)代替bus_id就可以了。。。