···191191/*192192 * Attempt to instantiate an I2C client by ID, probably loading a module.193193 */194194-static int init_i2c_module(struct i2c_adapter *adapter, int id, int addr)194194+static int init_i2c_module(struct i2c_adapter *adapter, const char *type,195195+ int id, int addr)195196{197197+ struct i2c_board_info info;196198 char *modname;197199198200 switch (id) {···228226 }229227 if (modname != NULL)230228 request_module(modname);231231- if (wis_i2c_probe_device(adapter, id, addr) == 1)229229+230230+ memset(&info, 0, sizeof(struct i2c_board_info));231231+ info.addr = addr;232232+ strlcpy(info.type, type, I2C_NAME_SIZE);233233+ if (!i2c_new_device(adapter, &info))232234 return 0;233235 if (modname != NULL)234236 printk(KERN_INFO···272266 if (go->i2c_adapter_online) {273267 for (i = 0; i < go->board_info->num_i2c_devs; ++i)274268 init_i2c_module(&go->i2c_adapter,269269+ go->board_info->i2c_devs[i].type,275270 go->board_info->i2c_devs[i].id,276271 go->board_info->i2c_devs[i].addr);277272 if (go->board_id == GO7007_BOARDID_ADLINK_MPG24)
-83
drivers/staging/go7007/go7007-i2c.c
···3131#include "go7007-priv.h"3232#include "wis-i2c.h"33333434-/************** Registration interface for I2C client drivers **************/3535-3636-/* Since there's no way to auto-probe the I2C devices connected to the I2C3737- * bus on the go7007, we have this silly little registration system that3838- * client drivers can use to register their I2C driver ID and their3939- * detect_client function (the one that's normally passed to i2c_probe).4040- *4141- * When a new go7007 device is connected, we can look up in a board info4242- * table by the USB or PCI vendor/product/revision ID to determine4343- * which I2C client module to load. The client driver module will register4444- * itself here, and then we can call the registered detect_client function4545- * to force-load a new client at the address listed in the board info table.4646- *4747- * Really the I2C subsystem should have a way to force-load I2C client4848- * drivers when we have a priori knowledge of what's on the bus, especially4949- * since the existing I2C auto-probe mechanism is so hokey, but we'll use5050- * our own mechanism for the time being. */5151-5252-struct wis_i2c_client_driver {5353- unsigned int id;5454- found_proc found_proc;5555- struct list_head list;5656-};5757-5858-static LIST_HEAD(i2c_client_drivers);5959-static DECLARE_MUTEX(i2c_client_driver_list_lock);6060-6161-/* Client drivers register here by their I2C driver ID */6262-int wis_i2c_add_driver(unsigned int id, found_proc found_proc)6363-{6464- struct wis_i2c_client_driver *driver;6565-6666- driver = kmalloc(sizeof(struct wis_i2c_client_driver), GFP_KERNEL);6767- if (driver == NULL)6868- return -ENOMEM;6969- driver->id = id;7070- driver->found_proc = found_proc;7171-7272- down(&i2c_client_driver_list_lock);7373- list_add_tail(&driver->list, &i2c_client_drivers);7474- up(&i2c_client_driver_list_lock);7575-7676- return 0;7777-}7878-EXPORT_SYMBOL(wis_i2c_add_driver);7979-8080-void wis_i2c_del_driver(found_proc found_proc)8181-{8282- struct wis_i2c_client_driver *driver, *next;8383-8484- down(&i2c_client_driver_list_lock);8585- list_for_each_entry_safe(driver, next, &i2c_client_drivers, list)8686- if (driver->found_proc == found_proc) {8787- list_del(&driver->list);8888- kfree(driver);8989- }9090- up(&i2c_client_driver_list_lock);9191-}9292-EXPORT_SYMBOL(wis_i2c_del_driver);9393-9494-/* The main go7007 driver calls this to instantiate a client by driver9595- * ID and bus address, which are both stored in the board info table */9696-int wis_i2c_probe_device(struct i2c_adapter *adapter,9797- unsigned int id, int addr)9898-{9999- struct wis_i2c_client_driver *driver;100100- int found = 0;101101-102102- if (addr < 0 || addr > 0x7f)103103- return -1;104104- down(&i2c_client_driver_list_lock);105105- list_for_each_entry(driver, &i2c_client_drivers, list)106106- if (driver->id == id) {107107- if (driver->found_proc(adapter, addr, 0) == 0)108108- found = 1;109109- break;110110- }111111- up(&i2c_client_driver_list_lock);112112- return found;113113-}114114-11534/********************* Driver for on-board I2C adapter *********************/1163511736/* #define GO7007_I2C_DEBUG */···206287207288static struct i2c_adapter go7007_adap_templ = {208289 .owner = THIS_MODULE,209209- .class = I2C_CLASS_TV_ANALOG,210290 .name = "WIS GO7007SB",211211- .id = I2C_ALGO_GO7007,212291 .algo = &go7007_algo,213292};214293
+1
drivers/staging/go7007/go7007-priv.h
···8787 int audio_main_div;8888 int num_i2c_devs;8989 struct {9090+ const char *type;9091 int id;9192 int addr;9293 } i2c_devs[4];
···2424#define I2C_DRIVERID_WIS_OV7640 0xf0f52525#define I2C_DRIVERID_WIS_TW2804 0xf0f62626#define I2C_DRIVERID_S2250 0xf0f72727-#define I2C_ALGO_GO7007 0xf000002828-#define I2C_ALGO_GO7007_USB 0xf1000029273028/* Flag to indicate that the client needs to be accessed with SCCB semantics */3129/* We re-use the I2C_M_TEN value so the flag passes through the masks in the3230 * core I2C code. Major kludge, but the I2C layer ain't exactly flexible. */3331#define I2C_CLIENT_SCCB 0x103434-3535-typedef int (*found_proc) (struct i2c_adapter *, int, int);3636-int wis_i2c_add_driver(unsigned int id, found_proc found_proc);3737-void wis_i2c_del_driver(found_proc found_proc);3838-3939-int wis_i2c_probe_device(struct i2c_adapter *adapter,4040- unsigned int id, int addr);41324233/* Definitions for new video decoder commands */4334