Linux I2C device driver

**

Linux I2C device driver

**
主要工作:結構體的填充,與函數的實現
attach_adapter、detach_adapter、detach_client、device driver文件操作接口(read、write)

i2c-driver的初始化:

static struct i2c_driver hello_driver = {
    .driver = {
        .name = "hello",
    },
    .attach_adapter = hello_attach_adapter,
    .detach_client  = hello_detach_client,
    .command        = hello_command,
};

I2C 設備驅動的模塊加載函數通用的方法是在 I2C 設備驅動的模塊加載函數中完成兩件事
(1)將 I2C 設備註冊爲一個字符設備
(2)通過 I2C 核心的 i2c_add_driver()函數添加 i2c_driver
在模塊卸載函數中需要做相反的兩件事
(1)通過 I2C 核心的 i2c_del_driver()函數刪除 i2c_driver
(2)註銷字符設備

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章