linux驱动板载信息注册

一、定义板载信息数组

static struct i2c_board_info i2c_devs3[] __initdata = {
    /* add by cym 20130318 support for FT5X0X TouchScreen */
    #if defined(CONFIG_TOUCHSCREEN_FT5X0X)
    {
        I2C_BOARD_INFO("ft5x0x_ts", 0x70>>1),
        .irq = IRQ_EINT(4),
        .platform_data = &ft5x0x_pdata,
    },
}

二、注册板载信息



i2c_register_board_info(3, i2c_devs3, ARRAY_SIZE(i2c_devs3));

三、注册板载信息的函数实现

int __init
i2c_register_board_info(int busnum,
    struct i2c_board_info const *info, unsigned len)
{
    int status;

    down_write(&__i2c_board_lock);

    /* dynamic bus numbers will be assigned after the last static one */
    if (busnum >= __i2c_first_dynamic_bus_num)
        __i2c_first_dynamic_bus_num = busnum + 1;

    for (status = 0; len; len--, info++) {
        struct i2c_devinfo  *devinfo;

        devinfo = kzalloc(sizeof(*devinfo), GFP_KERNEL);
        if (!devinfo) {
            pr_debug("i2c-core: can't register boardinfo!\n");
            status = -ENOMEM;
            break;
        }

        devinfo->busnum = busnum;
        devinfo->board_info = *info;
        list_add_tail(&devinfo->list, &__i2c_board_list);
    }

    up_write(&__i2c_board_lock);

    return status;
}

你可能感兴趣的:(linux驱动)