Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: [PATCHES] Frontend kernel i2c conversion.
On Monday 19 July 2004 00:15, Johannes Stezenbach wrote:
> Something's wrong with your patchset. In dvb-bt8xx.c you *added*
> the client_register() functions (unused), while you removed them
> everywhere else. Also, IIRC the skystar2 I2C stuff is a bit special
> and will fail for general use (that's why the funny checks in
> master_xfer() are there).
So the skystar2 patch should become something like the attached patch I
belive. Offcourse the client_(un)register functions should be put back in if
this is to be used with current CVS.
Kenneth
Index: b2c2/skystar2.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/b2c2/skystar2.c,v
retrieving revision 1.32
diff -u -r1.32 skystar2.c
--- b2c2/skystar2.c 8 Jul 2004 17:05:42 -0000 1.32
+++ b2c2/skystar2.c 19 Jul 2004 13:41:07 -0000
@@ -91,7 +91,6 @@
struct dmxdev dmxdev;
struct dmx_frontend hw_frontend;
struct dmx_frontend mem_frontend;
- struct dvb_i2c_bus *i2c_bus;
struct i2c_adapter i2c_adap;
struct dvb_net dvbnet;
@@ -280,75 +279,6 @@
return buf - start;
}
-static int master_xfer(struct dvb_i2c_bus *i2c, const struct i2c_msg *msgs, int num)
-{
- struct adapter *tmp = i2c->data;
- int i, ret = 0;
-
- if (down_interruptible(&tmp->i2c_sem))
- return -ERESTARTSYS;
-
- ddprintk("%s: %d messages to transfer\n", __FUNCTION__, num);
-
- for (i = 0; i < num; i++) {
- ddprintk("message %d: flags=0x%x, addr=0x%x, buf=0x%x, len=%d \n", i,
- msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
-
- /* allow only the mt312, mt352 and stv0299 frontends to access the bus */
- if ((msgs[i].addr != 0x0e) && (msgs[i].addr != 0x68) &&
- (msgs[i].addr != 0x61) && (msgs[i].addr != 0x0f)) {
- up(&tmp->i2c_sem);
- return -EREMOTEIO;
- }
- }
-
- // read command
- if ((num == 2) && (msgs[0].flags == 0) && (msgs[1].flags == I2C_M_RD) && (msgs[0].buf != NULL) && (msgs[1].buf != NULL)) {
-
- ret = flex_i2c_read(tmp, 0x10000000, msgs[0].addr, msgs[0].buf[0], msgs[1].buf, msgs[1].len);
-
- up(&tmp->i2c_sem);
-
- if (ret != msgs[1].len) {
- printk("%s: read error !\n", __FUNCTION__);
-
- for (i = 0; i < 2; i++) {
- printk("message %d: flags=0x%x, addr=0x%x, buf=0x%x, len=%d \n", i,
- msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
- }
-
- return -EREMOTEIO;
- }
-
- return num;
- }
- // write command
- for (i = 0; i < num; i++) {
-
- if ((msgs[i].flags != 0) || (msgs[i].buf == NULL) || (msgs[i].len < 2))
- return -EINVAL;
-
- ret = flex_i2c_write(tmp, 0x10000000, msgs[i].addr, msgs[i].buf[0], &msgs[i].buf[1], msgs[i].len - 1);
-
- up(&tmp->i2c_sem);
-
- if (ret != msgs[0].len - 1) {
- printk("%s: write error %i !\n", __FUNCTION__, ret);
-
- printk("message %d: flags=0x%x, addr=0x%x, buf[0]=0x%x, len=%d \n", i,
- msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
-
- return -EREMOTEIO;
- }
-
- return num;
- }
-
- printk("%s: unknown command format !\n", __FUNCTION__);
-
- return -EINVAL;
-}
-
/* SRAM (Skystar2 rev2.3 has one "ISSI IS61LV256" chip on board,
but it seems that FlexCopII can work with more than one chip) */
static void sram_set_net_dest(struct adapter *adapter, u8 dest)
@@ -2231,36 +2161,85 @@
return 0;
}
-
-int client_register(struct i2c_client *client)
+static int flexcop_i2c_xfer(struct i2c_adapter *i2c_adapter,
+ struct i2c_msg msgs[], int num)
{
- struct adapter *adapter = (struct adapter*)i2c_get_adapdata(client->adapter);
+ dprintk("flexcop_i2c_xfer\n");
- dprintk("client_register\n");
+ struct adapter *tmp = i2c_get_adapdata(i2c_adapter);
+ int i, ret = 0;
- if (client->driver->command)
- return client->driver->command(client, FE_REGISTER, adapter->dvb_adapter);
- return 0;
-}
+ if (down_interruptible(&tmp->i2c_sem))
+ return -ERESTARTSYS;
-int client_unregister(struct i2c_client *client)
-{
- struct adapter *adapter = (struct adapter*)i2c_get_adapdata(client->adapter);
+ ddprintk("%s: %d messages to transfer\n", __FUNCTION__, num);
+
+ for (i = 0; i < num; i++) {
+ ddprintk("message %d: flags=0x%x, addr=0x%x, buf=0x%x, len=%d \n", i,
+ msgs[i].flags, msgs[i].addr, msgs[i].buf[0], msgs[i].len);
- dprintk("client_unregister\n");
+ /* allow only the mt312, mt352 and stv0299 frontends to access the bus */
+ if ((msgs[i].addr != 0x0e) && (msgs[i].addr != 0x68) &&
+ (msgs[i].addr != 0x61) && (msgs[i].addr != 0x0f)) {
+ up(&tmp->i2c_sem);
+ return -EREMOTEIO;
+ }
+ }
- if (client->driver->command)
- return client->driver->command(client, FE_UNREGISTER, adapter->dvb_adapter);
- return 0;
-}
+ // read command
+ if ((num == 2) && (msgs[0].flags == 0) &&
+ (msgs[1].flags == I2C_M_RD) && (msgs[0].buf != NULL) &&
+ (msgs[1].buf != NULL)) {
-static int flexcop_i2c_xfer(struct i2c_adapter *i2c_adapter, struct i2c_msg msg[], int num)
-{
- struct adapter *adapter = i2c_get_adapdata(i2c_adapter);
+ ret = flex_i2c_read(tmp, 0x10000000, msgs[0].addr,
+ msgs[0].buf[0], msgs[1].buf, msgs[1].len);
- dprintk("flexcop_i2c_xfer\n");
+ up(&tmp->i2c_sem);
+
+ if (ret != msgs[1].len) {
+ printk("%s: read error !\n", __FUNCTION__);
+
+ for (i = 0; i < 2; i++) {
+ printk("message %d: flags=0x%x, addr=0x%x, "
+ "buf=0x%x, len=%d \n", i, msgs[i].flags,
+ msgs[i].addr, msgs[i].buf[0], msgs[i].len);
+ }
+
+ return -EREMOTEIO;
+ }
+
+ return num;
+ }
+
+ // write command
+ for (i = 0; i < num; i++) {
+
+ if ((msgs[i].flags != 0) || (msgs[i].buf == NULL) ||
+ (msgs[i].len < 2))
+ return -EINVAL;
+
+ ret = flex_i2c_write(tmp, 0x10000000, msgs[i].addr,
+ msgs[i].buf[0], &msgs[i].buf[1],
+ msgs[i].len - 1);
- return master_xfer(adapter->i2c_bus, msg, num);
+ up(&tmp->i2c_sem);
+
+ if (ret != msgs[0].len - 1) {
+ printk("%s: write error %i !\n", __FUNCTION__, ret);
+
+ printk("message %d: flags=0x%x, addr=0x%x, "
+ "buf[0]=0x%x, len=%d \n", i, msgs[i].flags,
+ msgs[i].addr, msgs[i].buf[0], msgs[i].len);
+
+ return -EREMOTEIO;
+ }
+
+ return num;
+ }
+
+ printk("%s: unknown command format !\n", __FUNCTION__);
+
+ return -EINVAL;
}
u32 flexcop_i2c_func(struct i2c_adapter *adapter)
@@ -2292,7 +2271,10 @@
if (driver_initialize(pdev) != 0)
return -ENODEV;
- dvb_register_adapter(&dvb_adapter, skystar2_pci_driver.name, THIS_MODULE);
+ adapter = (struct adapter *) pci_get_drvdata(pdev);
+
+ dvb_register_adapter(&dvb_adapter, skystar2_pci_driver.name,
+ &adapter->i2c_adap, THIS_MODULE);
if (dvb_adapter == NULL) {
printk("%s: Error registering DVB adapter\n", __FUNCTION__);
@@ -2302,8 +2284,6 @@
return -ENODEV;
}
- adapter = (struct adapter *) pci_get_drvdata(pdev);
-
adapter->dvb_adapter = dvb_adapter;
init_MUTEX(&adapter->i2c_sem);
@@ -2312,35 +2292,19 @@
memset(&adapter->i2c_adap, 0, sizeof(struct i2c_adapter));
strcpy(adapter->i2c_adap.name, "Technisat SkyStar2 driver");
-#if ( LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) )
- adapter->i2c_adap.data = adapter;
-#else
- i2c_set_adapdata(&adapter->i2c_adap, adapter);
-
- #ifdef I2C_ADAP_CLASS_TV_DIGITAL
- adapter->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL;
- #else
- adapter->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
- #endif
-
-#endif
adapter->i2c_adap.algo = &flexcop_algo;
adapter->i2c_adap.algo_data = NULL;
adapter->i2c_adap.id = I2C_ALGO_BIT;
- adapter->i2c_adap.client_register = client_register;
- adapter->i2c_adap.client_unregister = client_unregister;
-
- adapter->i2c_bus = dvb_register_i2c_bus(master_xfer, adapter, adapter->dvb_adapter, 0);
-
- if (!adapter->i2c_bus) {
- dvb_unregister_adapter (adapter->dvb_adapter);
- return -ENOMEM;
- }
+#ifdef I2C_ADAP_CLASS_TV_DIGITAL
+ adapter->i2c_adap.class = I2C_ADAP_CLASS_TV_DIGITAL;
+#else
+ adapter->i2c_adap.class = I2C_CLASS_TV_DIGITAL;
+#endif
+ i2c_set_adapdata(&adapter->i2c_adap, adapter);
if (i2c_add_adapter(&adapter->i2c_adap) < 0) {
- dvb_unregister_i2c_bus (master_xfer, adapter->i2c_bus->adapter, adapter->i2c_bus->id);
dvb_unregister_adapter (adapter->dvb_adapter);
return -ENOMEM;
}
@@ -2408,12 +2372,7 @@
if (adapter->dvb_adapter != NULL) {
dvb_remove_frontend_ioctls(adapter->dvb_adapter, flexcop_diseqc_ioctl, NULL);
-
i2c_del_adapter(&adapter->i2c_adap);
-
- if (adapter->i2c_bus != NULL)
- dvb_unregister_i2c_bus(master_xfer, adapter->i2c_bus->adapter, adapter->i2c_bus->id);
-
dvb_unregister_adapter(adapter->dvb_adapter);
}
driver_halt(pdev);
Home |
Main Index |
Thread Index