V4L/DVB (6021): cx88: Copy board information into card state
[deliverable/linux.git] / drivers / media / video / cx88 / cx88-i2c.c
index 9830d5c43921daa1753afdcfab230bf9166f1d94..6b42dea860fd6876cadffac87f0e5fa0504b34c8 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
 
     cx88-i2c.c  --  all the i2c code is here
@@ -107,28 +108,28 @@ static int attach_inform(struct i2c_client *client)
        if (!client->driver->command)
                return 0;
 
-       if (core->radio_type != UNSET) {
-               if ((core->radio_addr==ADDR_UNSET)||(core->radio_addr==client->addr)) {
+       if (core->board.radio_type != UNSET) {
+               if ((core->board.radio_addr==ADDR_UNSET)||(core->board.radio_addr==client->addr)) {
                        tun_setup.mode_mask = T_RADIO;
-                       tun_setup.type = core->radio_type;
-                       tun_setup.addr = core->radio_addr;
+                       tun_setup.type = core->board.radio_type;
+                       tun_setup.addr = core->board.radio_addr;
 
                        client->driver->command (client, TUNER_SET_TYPE_ADDR, &tun_setup);
                }
        }
-       if (core->tuner_type != UNSET) {
-               if ((core->tuner_addr==ADDR_UNSET)||(core->tuner_addr==client->addr)) {
+       if (core->board.tuner_type != UNSET) {
+               if ((core->board.tuner_addr==ADDR_UNSET)||(core->board.tuner_addr==client->addr)) {
 
                        tun_setup.mode_mask = T_ANALOG_TV;
-                       tun_setup.type = core->tuner_type;
-                       tun_setup.addr = core->tuner_addr;
+                       tun_setup.type = core->board.tuner_type;
+                       tun_setup.addr = core->board.tuner_addr;
 
                        client->driver->command (client,TUNER_SET_TYPE_ADDR, &tun_setup);
                }
        }
 
-       if (core->tda9887_conf)
-               client->driver->command(client, TDA9887_SET_CONFIG, &core->tda9887_conf);
+       if (core->board.tda9887_conf)
+               client->driver->command(client, TDA9887_SET_CONFIG, &core->board.tda9887_conf);
        return 0;
 }
 
@@ -159,7 +160,7 @@ void cx88_call_i2c_clients(struct cx88_core *core, unsigned int cmd, void *arg)
                i2c_clients_command(&core->i2c_adap, cmd, arg);
 }
 
-static struct i2c_algo_bit_data cx8800_i2c_algo_template = {
+static const struct i2c_algo_bit_data cx8800_i2c_algo_template = {
        .setsda  = cx8800_bit_setsda,
        .setscl  = cx8800_bit_setscl,
        .getsda  = cx8800_bit_getsda,
@@ -170,18 +171,6 @@ static struct i2c_algo_bit_data cx8800_i2c_algo_template = {
 
 /* ----------------------------------------------------------------------- */
 
-static struct i2c_adapter cx8800_i2c_adap_template = {
-       .name              = "cx2388x",
-       .owner             = THIS_MODULE,
-       .id                = I2C_HW_B_CX2388x,
-       .client_register   = attach_inform,
-       .client_unregister = detach_inform,
-};
-
-static struct i2c_client cx8800_i2c_client_template = {
-       .name   = "cx88xx internal",
-};
-
 static char *i2c_devs[128] = {
        [ 0x1c >> 1 ] = "lgdt330x",
        [ 0x86 >> 1 ] = "tda9887/cx22702",
@@ -195,7 +184,7 @@ static void do_i2c_scan(char *name, struct i2c_client *c)
        unsigned char buf;
        int i,rc;
 
-       for (i = 0; i < 128; i++) {
+       for (i = 0; i < ARRAY_SIZE(i2c_devs); i++) {
                c->addr = i;
                rc = i2c_master_recv(c,&buf,0);
                if (rc < 0)
@@ -211,26 +200,27 @@ int cx88_i2c_init(struct cx88_core *core, struct pci_dev *pci)
        /* 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)
+       if (core->board.tuner_type != TUNER_ABSENT)
                core->i2c_adap.class |= I2C_CLASS_TV_ANALOG;
-       if (cx88_boards[core->board].mpeg & CX88_MPEG_DVB)
+       if (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_adap.owner = THIS_MODULE;
+       core->i2c_adap.id = I2C_HW_B_CX2388x;
+       core->i2c_adap.client_register = attach_inform;
+       core->i2c_adap.client_unregister = detach_inform;
+       core->i2c_algo.udelay = i2c_udelay;
        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;
+       strlcpy(core->i2c_client.name, "cx88xx internal", I2C_NAME_SIZE);
 
        cx8800_bit_setscl(core,1);
        cx8800_bit_setsda(core,1);
This page took 0.028426 seconds and 5 git commands to generate.