[PATCH] i2c: Drop i2c_driver.{owner,name}, 5 of 11
[safe/jmp/linux-2.6] / drivers / media / video / tuner-core.c
index e677869..e8c8549 100644 (file)
@@ -28,7 +28,7 @@
 
 /* standard i2c insmod options */
 static unsigned short normal_i2c[] = {
-       0x4b,                   /* tda8290 */
+       0x42, 0x43, 0x4a, 0x4b,                 /* tda8290 */
        0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
        0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
        I2C_CLIENT_END
@@ -206,7 +206,7 @@ static void set_type(struct i2c_client *c, unsigned int type,
 
        set_freq(c, t->freq);
        tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n",
-                 c->adapter->name, c->driver->name, c->addr << 1, type,
+                 c->adapter->name, c->driver->driver.name, c->addr << 1, type,
                  t->mode_mask);
 }
 
@@ -222,9 +222,9 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup)
 {
        struct tuner *t = i2c_get_clientdata(c);
 
-       if ((tun_setup->addr == ADDR_UNSET &&
+       if ( t->type == UNSET && ((tun_setup->addr == ADDR_UNSET &&
                (t->mode_mask & tun_setup->mode_mask)) ||
-               tun_setup->addr == c->addr) {
+               tun_setup->addr == c->addr)) {
                        set_type(c, tun_setup->type, tun_setup->mode_mask);
        }
 }
@@ -251,7 +251,7 @@ static inline int check_mode(struct tuner *t, char *cmd)
 
 static char pal[] = "-";
 module_param_string(pal, pal, sizeof(pal), 0644);
-static char secam[] = "-";
+static char secam[] = "--";
 module_param_string(secam, secam, sizeof(secam), 0644);
 
 /* get more precise norm info from insmod option */
@@ -307,8 +307,13 @@ static int tuner_fixup_std(struct tuner *t)
                        break;
                case 'l':
                case 'L':
-                       tuner_dbg ("insmod fixup: SECAM => SECAM-L\n");
-                       t->std = V4L2_STD_SECAM_L;
+                       if ((secam[1]=='C')||(secam[1]=='c')) {
+                               tuner_dbg ("insmod fixup: SECAM => SECAM-L'\n");
+                               t->std = V4L2_STD_SECAM_LC;
+                       } else {
+                               tuner_dbg ("insmod fixup: SECAM => SECAM-L\n");
+                               t->std = V4L2_STD_SECAM_L;
+                       }
                        break;
                case '-':
                        /* default parameter, do nothing */
@@ -348,23 +353,33 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
        t->audmode = V4L2_TUNER_MODE_STEREO;
        t->mode_mask = T_UNINITIALIZED;
 
-
-       tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
-
        if (show_i2c) {
                unsigned char buffer[16];
                int i,rc;
 
                memset(buffer, 0, sizeof(buffer));
                rc = i2c_master_recv(&t->i2c, buffer, sizeof(buffer));
-               printk("tuner-%04x I2C RECV = ",addr);
+               tuner_info("I2C RECV = ");
                for (i=0;i<rc;i++)
                        printk("%02x ",buffer[i]);
                printk("\n");
        }
        /* TEA5767 autodetection code - only for addr = 0xc0 */
        if (!no_autodetect) {
-               if (addr == 0x60) {
+               switch (addr) {
+               case 0x42:
+               case 0x43:
+               case 0x4a:
+               case 0x4b:
+                       /* If chip is not tda8290, don't register.
+                          since it can be tda9887*/
+                       if (tda8290_probe(&t->i2c) != 0) {
+                               tuner_dbg("chip at addr %x is not a tda8290\n", addr);
+                               kfree(t);
+                               return 0;
+                       }
+                       break;
+               case 0x60:
                        if (tea5767_autodetection(&t->i2c) != EINVAL) {
                                t->type = TUNER_TEA5767;
                                t->mode_mask = T_RADIO;
@@ -372,10 +387,9 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
                                t->freq = 87.5 * 16; /* Sets freq to FM range */
                                default_mode_mask &= ~T_RADIO;
 
-                               i2c_attach_client (&t->i2c);
-                               set_type(&t->i2c,t->type, t->mode_mask);
-                               return 0;
+                               goto register_client;
                        }
+                       break;
                }
        }
 
@@ -388,6 +402,8 @@ static int tuner_attach(struct i2c_adapter *adap, int addr, int kind)
        }
 
        /* Should be just before return */
+register_client:
+       tuner_info("chip found @ 0x%x (%s)\n", addr << 1, adap->name);
        i2c_attach_client (&t->i2c);
        set_type (&t->i2c,t->type, t->mode_mask);
        return 0;
@@ -486,8 +502,6 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
                        break;
                }
        case AUDC_CONFIG_PINNACLE:
-               if (check_mode(t, "AUDC_CONFIG_PINNACLE") == EINVAL)
-                       return 0;
                switch (*iarg) {
                case 2:
                        tuner_dbg("pinnacle pal\n");
@@ -728,21 +742,19 @@ static int tuner_resume(struct device *dev)
 /* ----------------------------------------------------------------------- */
 
 static struct i2c_driver driver = {
-       .owner = THIS_MODULE,
-       .name = "tuner",
        .id = I2C_DRIVERID_TUNER,
-       .flags = I2C_DF_NOTIFY,
        .attach_adapter = tuner_probe,
        .detach_client = tuner_detach,
        .command = tuner_command,
        .driver = {
+                  .owner = THIS_MODULE,
+                  .name = "tuner",
                   .suspend = tuner_suspend,
                   .resume = tuner_resume,
                   },
 };
 static struct i2c_client client_template = {
        .name = "(tuner unset)",
-       .flags = I2C_CLIENT_ALLOW_USE,
        .driver = &driver,
 };