int i, ret = -1;
char buf[4];
- usbvision = i2c_get_adapdata(i2c_adap);
+ usbvision = (struct usb_usbvision *)i2c_get_adapdata(i2c_adap);
buf[0] = 0x00;
for (i = 0; i <= retries; i++) {
ret = (usbvision_i2c_write(usbvision, addr, buf, 1));
int i, ret = -1;
char buf[4];
- usbvision = i2c_get_adapdata(i2c_adap);
+ usbvision = (struct usb_usbvision *)i2c_get_adapdata(i2c_adap);
for (i = 0; i <= retries; i++) {
ret = (usbvision_i2c_read(usbvision, addr, buf, 1));
if (ret == 1)
int i, ret;
unsigned char addr;
- usbvision = i2c_get_adapdata(i2c_adap);
+ usbvision = (struct usb_usbvision *)i2c_get_adapdata(i2c_adap);
+
for (i = 0; i < num; i++) {
pmsg = &msgs[i];
ret = usb_find_address(i2c_adap, pmsg, i2c_adap->retries, &addr);
};
+/*
+ * registering functions to load algorithms at runtime
+ */
+static int usbvision_i2c_usb_add_bus(struct i2c_adapter *adap)
+{
+ PDEBUG(DBG_I2C, "I2C debugging is enabled [i2c]");
+ PDEBUG(DBG_I2C, "ALGO debugging is enabled [i2c]");
+
+ /* register new adapter to i2c module... */
+
+ adap->algo = &usbvision_algo;
+
+ adap->timeout = 100; /* default values, should */
+ adap->retries = 3; /* be replaced by defines */
+
+ i2c_add_adapter(adap);
+
+ PDEBUG(DBG_I2C,"i2c bus for %s registered", adap->name);
+
+ return 0;
+}
+
/* ----------------------------------------------------------------------- */
/* usbvision specific I2C functions */
/* ----------------------------------------------------------------------- */
int usbvision_i2c_register(struct usb_usbvision *usbvision)
{
- int ret;
-
- usbvision->i2c_adap = i2c_adap_template;
- usbvision->i2c_adap.dev.parent = &usbvision->dev->dev;
-
- PDEBUG(DBG_I2C, "I2C debugging is enabled [i2c]");
+ memcpy(&usbvision->i2c_adap, &i2c_adap_template,
+ sizeof(struct i2c_adapter));
+ memcpy(&usbvision->i2c_client, &i2c_client_template,
+ sizeof(struct i2c_client));
sprintf(usbvision->i2c_adap.name + strlen(usbvision->i2c_adap.name),
" #%d", usbvision->vdev->minor & 0x1f);
- PDEBUG(DBG_I2C,"I2C Registering adaptername: %s", usbvision->i2c_adap.name);
- i2c_set_adapdata(&usbvision->i2c_adap,usbvision);
- if ((ret = i2c_add_adapter(&usbvision->i2c_adap)) < 0) {
- PDEBUG(DBG_I2C,"could not add I2C adapter %s", usbvision->i2c_adap.name);
- return ret;
- }
+ PDEBUG(DBG_I2C,"Adaptername: %s", usbvision->i2c_adap.name);
+ usbvision->i2c_adap.dev.parent = &usbvision->dev->dev;
+
+ i2c_set_adapdata(&usbvision->i2c_adap, usbvision);
+ i2c_set_clientdata(&usbvision->i2c_client, usbvision);
- /* TODO: use i2c_client for eeprom detection as an example... */
- usbvision->i2c_client = i2c_client_template;
usbvision->i2c_client.adapter = &usbvision->i2c_adap;
if (usbvision_write_reg(usbvision, USBVISION_SER_MODE, USBVISION_IIC_LRNACK) < 0) {
- printk(KERN_ERR "usbvision_i2c_register: can't write reg\n");
+ printk(KERN_ERR "usbvision_register: can't write reg\n");
return -EBUSY;
}
}
#endif
- return 0;
+ return usbvision_i2c_usb_add_bus(&usbvision->i2c_adap);
}
int usbvision_i2c_unregister(struct usb_usbvision *usbvision)
{
struct usb_usbvision *usbvision;
- usbvision = i2c_get_adapdata(client->adapter);
+ usbvision = (struct usb_usbvision *)i2c_get_adapdata(client->adapter);
+
switch (client->addr << 1) {
case 0x42 << 1:
case 0x43 << 1:
{
struct usb_usbvision *usbvision;
- usbvision = i2c_get_adapdata(client->adapter);
+ usbvision = (struct usb_usbvision *)i2c_get_adapdata(client->adapter);
PDEBUG(DBG_I2C,"usbvision[%d] detaches %s", usbvision->nr, client->name);
return 0;
.owner = THIS_MODULE,
.name = "usbvision",
.id = I2C_HW_B_BT848, /* FIXME */
- .algo = &usbvision_algo,
- .algo_data = NULL,
.client_register = attach_inform,
.client_unregister = detach_inform,
#ifdef I2C_ADAP_CLASS_TV_ANALOG