免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1009 | 回复: 0
打印 上一主题 下一主题

The probe function in s3c2410fb.c(kernel 2.6.16) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-04-12 09:40 |只看该作者 |倒序浏览
在s3c2410fb.c中,在平台相关的设备探测函数中有这么一段code,请高手帮忙看看。

static int __init s3c2410fb_probe(struct platform_device *pdev)
{
    ……
    static struct s3c2410fb_mach_info *mach_info;
    ……       
   mach_info = pdev->dev.platform_data;
    if (mach_info == NULL)
    {
        dev_err(&pdev->dev,"no platform data for lcd, cannot attach\n");
         return -EINVAL;
    }
    mregs = &mach_info->regs;
     ……
}

    mach_info,platform_data和platform_device的声明如下:

struct s3c2410fb_mach_info {
        unsigned char        fixed_syncs;        /* do not update sync/border */

        /* Screen size */
        int                width;
        int                height;

        /* Screen info */
        struct s3c2410fb_val xres;
        struct s3c2410fb_val yres;
        struct s3c2410fb_val bpp;

        /* lcd configuration registers */
        struct s3c2410fb_hw  regs;

        /* GPIOs */

        unsigned long        gpcup;
        unsigned long        gpcup_mask;
        unsigned long        gpccon;
        unsigned long        gpccon_mask;
        unsigned long        gpdup;
        unsigned long        gpdup_mask;
        unsigned long        gpdcon;
        unsigned long        gpdcon_mask;

        /* lpc3600 control register */
        unsigned long        lpcsel;
};  

struct device {
        struct klist                klist_children;
        struct klist_node        knode_parent;                /* node in sibling list */
        struct klist_node        knode_driver;
        struct klist_node        knode_bus;
        struct device         * parent;

        struct kobject kobj;
        char        bus_id[BUS_ID_SIZE];        /* position on parent bus */
        struct device_attribute uevent_attr;

        struct semaphore        sem;        /* semaphore 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                *driver_data;        /* data private to the driver */
       
                void                *platform_data;        /* Platform specific data, device
                                           core doesn't touch it */

        void                *firmware_data; /* Firmware specific data (e.g. ACPI,
                                           BIOS data),reserved for device core*/
        struct dev_pm_info        power;

        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 list_head        dma_pools;        /* dma pools (if dma'ble) */

        struct dma_coherent_mem        *dma_mem; /* internal for coherent mem
                                             override */

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

struct platform_device {
        const char        * name;
        u32                id;
        struct device        dev;
        u32                num_resources;
        struct resource        * resource;
};

请问上面那段代码怎么理解?代码的细节可以参看内核源代码。fb核心是怎样用这么个void *得到设备信息的?

[ 本帖最后由 grep_one 于 2006-4-12 09:54 编辑 ]
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP