- memcpy(&dev->i2c_adap, &cx8800_i2c_adap_template,
- sizeof(dev->i2c_adap));
- memcpy(&dev->i2c_algo, &cx8800_i2c_algo_template,
- sizeof(dev->i2c_algo));
- memcpy(&dev->i2c_client, &cx8800_i2c_client_template,
- sizeof(dev->i2c_client));
-
- dev->i2c_adap.dev.parent = &dev->pci->dev;
- strlcpy(dev->i2c_adap.name,dev->name,sizeof(dev->i2c_adap.name));
- dev->i2c_algo.data = dev;
- i2c_set_adapdata(&dev->i2c_adap,dev);
- dev->i2c_adap.algo_data = &dev->i2c_algo;
- dev->i2c_client.adapter = &dev->i2c_adap;
-
- cx8800_bit_setscl(dev,1);
- cx8800_bit_setsda(dev,1);
-
- dev->i2c_rc = i2c_bit_add_bus(&dev->i2c_adap);
- printk("%s: i2c register %s\n", dev->name,
- (0 == dev->i2c_rc) ? "ok" : "FAILED");
- return dev->i2c_rc;
+ /* Prevents usage of invalid delay values */
+ if (i2c_udelay<5)
+ i2c_udelay=5;
+ cx8800_i2c_algo_template.udelay=i2c_udelay;
+
+ memcpy(&core->i2c_adap, &cx8800_i2c_adap_template,
+ sizeof(core->i2c_adap));
+ memcpy(&core->i2c_algo, &cx8800_i2c_algo_template,
+ sizeof(core->i2c_algo));
+ memcpy(&core->i2c_client, &cx8800_i2c_client_template,
+ sizeof(core->i2c_client));
+
+ if (core->tuner_type != TUNER_ABSENT)
+ core->i2c_adap.class |= I2C_CLASS_TV_ANALOG;
+ if (cx88_boards[core->board].mpeg & CX88_MPEG_DVB)
+ core->i2c_adap.class |= I2C_CLASS_TV_DIGITAL;
+
+ core->i2c_adap.dev.parent = &pci->dev;
+ strlcpy(core->i2c_adap.name,core->name,sizeof(core->i2c_adap.name));
+ core->i2c_algo.data = core;
+ i2c_set_adapdata(&core->i2c_adap,core);
+ core->i2c_adap.algo_data = &core->i2c_algo;
+ core->i2c_client.adapter = &core->i2c_adap;
+
+ cx8800_bit_setscl(core,1);
+ cx8800_bit_setsda(core,1);
+
+ core->i2c_rc = i2c_bit_add_bus(&core->i2c_adap);
+ if (0 == core->i2c_rc) {
+ dprintk(1, "i2c register ok\n");
+ if (i2c_scan)
+ do_i2c_scan(core->name,&core->i2c_client);
+ } else
+ printk("%s: i2c register FAILED\n", core->name);
+ return core->i2c_rc;