现在的位置: 首页 > 综合 > 正文

驱动中id_table的分析(Input/I2C)

2013年10月03日 ⁄ 综合 ⁄ 共 1547字 ⁄ 字号 评论关闭

驱动中id_table的分析

一、I2C驱动probe

***i2c_device_id用于devicedrive配对

static const struct i2c_device_id tps65010_id[] = {

    { "tps65010", TPS65010 },

    { "tps65011", TPS65011 },

    { "tps65012", TPS65012 },

    { "tps65013", TPS65013 },

    { "tps65014", TPS65011 },   /* tps65011 charging at 6.5V max */

    { }

};

MODULE_DEVICE_TABLE(i2c, tps65010_id);

 

static struct i2c_driver tps65010_driver = {

    .driver = {

       .name  = "tps65010",

    },

    .probe = tps65010_probe,  /* bus->match成功后调用 */

    .remove    = __exit_p(tps65010_remove),

    .id_table = tps65010_id,  /* 用于I2C driverprobe函数调用 */

};

 

struct bus_type i2c_bus_type = {

    .name      = "i2c",

    .match     = i2c_device_match,

    .probe     = i2c_device_probe,

    .remove       = i2c_device_remove,

    .shutdown  = i2c_device_shutdown,

    .pm    = &i2c_device_pm_ops,

};

 

int device_add(struct device *dev)-> bus_probe_device(dev)->

device_attach(dev)-> __device_attach->driver_match_device(drv, dev)

 

static inline int driver_match_device(struct device_driver *drv,

                    struct device *dev)

{

    return drv->bus->match ? drv->bus->match(dev, drv) : 1;

}

 

->driver_probe_device->really_probe->dev->bus->probe(dev)

 

二、  input driver probe机制

input driverinput handler配对机制

static struct input_handler evbug_handler = {

    .event =   evbug_event,

    .connect = evbug_connect,

    .disconnect = evbug_disconnect,

    .name =       "evbug",

    .id_table =   evbug_ids,

};

 

static int __init evbug_init(void)

{

    return input_register_handler(&evbug_handler);

}

input_attach_handler(dev, handler)-> input_match_device(handler, dev)-> handler->connect(handler, dev, id)

***handler & input driver连接成功

Author : Woodpecker <pecker.hu@gmail.com>

南京 2010-09-25 21:06

【上篇】
【下篇】

抱歉!评论已关闭.