]> git.karo-electronics.de Git - linux-beck.git/commitdiff
V4L/DVB (3895): Additional frontend_init safety checks
authorAndrew de Quincey <adq_dvb@lidskialf.net>
Thu, 20 Apr 2006 15:01:47 +0000 (12:01 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sun, 25 Jun 2006 04:59:38 +0000 (01:59 -0300)
Don't try and set the tuner ops if the demod was not detected.

Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
drivers/media/dvb/ttpci/av7110.c
drivers/media/dvb/ttpci/budget-av.c
drivers/media/video/saa7134/saa7134-dvb.c

index 939a493b5251936bd49aac8efc0d3c4f9ffc53f9..5f976d5eda42e735ac54fc8d9d887e8743639ee8 100644 (file)
@@ -2083,7 +2083,9 @@ static int frontend_init(struct av7110 *av7110)
                case 0x0000: // Fujitsu/Siemens DVB-Cable (ves1820/Philips CD1516(??))
                        av7110->fe = ves1820_attach(&philips_cd1516_config,
                                                    &av7110->i2c_adap, read_pwm(av7110));
-                       av7110->fe->ops->tuner_ops.set_params = philips_cd1516_tuner_set_params;
+                       if (av7110->fe) {
+                               av7110->fe->ops->tuner_ops.set_params = philips_cd1516_tuner_set_params;
+                       }
                        break;
                }
 
@@ -2134,13 +2136,17 @@ static int frontend_init(struct av7110 *av7110)
                                /* Siemens DVB-C (full-length card) VES1820/Philips CD1516 */
                                av7110->fe = ves1820_attach(&philips_cd1516_config, &av7110->i2c_adap,
                                                        read_pwm(av7110));
-                               av7110->fe->ops->tuner_ops.set_params = philips_cd1516_tuner_set_params;
+                               if (av7110->fe) {
+                                       av7110->fe->ops->tuner_ops.set_params = philips_cd1516_tuner_set_params;
+                               }
                                break;
                        case 0x0003:
                                /* Hauppauge DVB-C 2.1 VES1820/ALPS TDBE2 */
                                av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap,
                                                        read_pwm(av7110));
-                               av7110->fe->ops->tuner_ops.set_params = alps_tdbe2_tuner_set_params;
+                               if (av7110->fe) {
+                                       av7110->fe->ops->tuner_ops.set_params = alps_tdbe2_tuner_set_params;
+                               }
                                break;
                        }
                        break;
@@ -2149,13 +2155,17 @@ static int frontend_init(struct av7110 *av7110)
 
                        // ALPS TDLB7
                        av7110->fe = sp8870_attach(&alps_tdlb7_config, &av7110->i2c_adap);
-                       av7110->fe->ops->tuner_ops.set_params = alps_tdlb7_tuner_set_params;
+                       if (av7110->fe) {
+                               av7110->fe->ops->tuner_ops.set_params = alps_tdlb7_tuner_set_params;
+                       }
                        break;
 
                case 0x0002: // Hauppauge/TT DVB-C premium rev2.X
 
                        av7110->fe = ves1820_attach(&alps_tdbe2_config, &av7110->i2c_adap, read_pwm(av7110));
-                       av7110->fe->ops->tuner_ops.set_params = alps_tdbe2_tuner_set_params;
+                       if (av7110->fe) {
+                               av7110->fe->ops->tuner_ops.set_params = alps_tdbe2_tuner_set_params;
+                       }
                        break;
 
                case 0x0004: // Galaxis DVB-S rev1.3
@@ -2185,7 +2195,9 @@ static int frontend_init(struct av7110 *av7110)
                case 0x0008: // Hauppauge/TT DVB-T
 
                        av7110->fe = l64781_attach(&grundig_29504_401_config, &av7110->i2c_adap);
-                       av7110->fe->ops->tuner_ops.set_params = grundig_29504_401_tuner_set_params;
+                       if (av7110->fe) {
+                               av7110->fe->ops->tuner_ops.set_params = grundig_29504_401_tuner_set_params;
+                       }
                        break;
 
                case 0x000A: // Hauppauge/TT Nexus-CA rev1.X
index 9bd069e4e11a9ca4d9314fe97fd5bdebf94401a4..68004187860f433fb13f9f0df8bed36c69e6f894 100644 (file)
@@ -1113,6 +1113,10 @@ static void frontend_init(struct budget_av *budget_av)
        case SUBID_DVBT_CINERGY1200:
                fe = tda10046_attach(&philips_tu1216_config,
                                     &budget_av->budget.i2c_adap);
+               if (fe) {
+                       fe->ops->tuner_ops.init = philips_tu1216_tuner_init;
+                       fe->ops->tuner_ops.set_params = philips_tu1216_tuner_set_params;
+               }
                break;
        }
 
index d62e9a4f2a1c3db36df07de569877eeea26e98ff..a83db2abb44950a0accc9f02c46aace1b3edbe59 100644 (file)
@@ -1020,112 +1020,144 @@ static int dvb_init(struct saa7134_dev *dev)
                printk("%s: pinnacle 300i dvb setup\n",dev->name);
                dev->dvb.frontend = mt352_attach(&pinnacle_300i,
                                                 &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.calc_regs = mt352_pinnacle_tuner_calc_regs;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.calc_regs = mt352_pinnacle_tuner_calc_regs;
+               }
                break;
 
        case SAA7134_BOARD_AVERMEDIA_777:
                printk("%s: avertv 777 dvb setup\n",dev->name);
                dev->dvb.frontend = mt352_attach(&avermedia_777,
                                                 &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
+               }
                break;
 #endif
 #ifdef HAVE_TDA1004X
        case SAA7134_BOARD_MD7134:
                dev->dvb.frontend = tda10046_attach(&medion_cardbus,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.init = philips_fmd1216_tuner_init;
-               dev->dvb.frontend->ops->tuner_ops.sleep = philips_fmd1216_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = philips_fmd1216_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.init = philips_fmd1216_tuner_init;
+                       dev->dvb.frontend->ops->tuner_ops.sleep = philips_fmd1216_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = philips_fmd1216_tuner_set_params;
+               }
                break;
        case SAA7134_BOARD_PHILIPS_TOUGH:
                dev->dvb.frontend = tda10046_attach(&philips_tu1216_60_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.init = philips_tu1216_tuner_60_init;
-               dev->dvb.frontend->ops->tuner_ops.set_params = philips_tu1216_tuner_60_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.init = philips_tu1216_tuner_60_init;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = philips_tu1216_tuner_60_set_params;
+               }
                break;
        case SAA7134_BOARD_FLYDVBTDUO:
                dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.init = philips_tda827x_tuner_init;
-               dev->dvb.frontend->ops->tuner_ops.sleep = philips_tda827x_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = philips_tda827x_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.init = philips_tda827x_tuner_init;
+                       dev->dvb.frontend->ops->tuner_ops.sleep = philips_tda827x_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = philips_tda827x_tuner_set_params;
+               }
                break;
        case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
                dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.init = philips_tda827x_tuner_init;
-               dev->dvb.frontend->ops->tuner_ops.sleep = philips_tda827x_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = philips_tda827x_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.init = philips_tda827x_tuner_init;
+                       dev->dvb.frontend->ops->tuner_ops.sleep = philips_tda827x_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = philips_tda827x_tuner_set_params;
+               }
                break;
        case SAA7134_BOARD_PHILIPS_EUROPA:
                dev->dvb.frontend = tda10046_attach(&philips_europa_config,
                                                    &dev->i2c_adap);
-               dev->original_demod_sleep = dev->dvb.frontend->ops->sleep;
-               dev->dvb.frontend->ops->sleep = philips_europa_demod_sleep;
-               dev->dvb.frontend->ops->tuner_ops.init = philips_europa_tuner_init;
-               dev->dvb.frontend->ops->tuner_ops.sleep = philips_europa_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = philips_td1316_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->original_demod_sleep = dev->dvb.frontend->ops->sleep;
+                       dev->dvb.frontend->ops->sleep = philips_europa_demod_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.init = philips_europa_tuner_init;
+                       dev->dvb.frontend->ops->tuner_ops.sleep = philips_europa_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = philips_td1316_tuner_set_params;
+               }
                break;
        case SAA7134_BOARD_VIDEOMATE_DVBT_300:
                dev->dvb.frontend = tda10046_attach(&philips_europa_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.init = philips_europa_tuner_init;
-               dev->dvb.frontend->ops->tuner_ops.sleep = philips_europa_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = philips_td1316_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.init = philips_europa_tuner_init;
+                       dev->dvb.frontend->ops->tuner_ops.sleep = philips_europa_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = philips_td1316_tuner_set_params;
+               }
                break;
        case SAA7134_BOARD_VIDEOMATE_DVBT_200:
                dev->dvb.frontend = tda10046_attach(&philips_tu1216_61_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.init = philips_tu1216_tuner_61_init;
-               dev->dvb.frontend->ops->tuner_ops.set_params = philips_tu1216_tuner_61_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.init = philips_tu1216_tuner_61_init;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = philips_tu1216_tuner_61_set_params;
+               }
                break;
        case SAA7134_BOARD_PHILIPS_TIGER:
                dev->dvb.frontend = tda10046_attach(&philips_tiger_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.init = philips_tiger_tuner_init;
-               dev->dvb.frontend->ops->tuner_ops.sleep = philips_tiger_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = philips_tiger_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.init = philips_tiger_tuner_init;
+                       dev->dvb.frontend->ops->tuner_ops.sleep = philips_tiger_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = philips_tiger_tuner_set_params;
+               }
                break;
        case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
                dev->dvb.frontend = tda10046_attach(&philips_tiger_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.init = philips_tiger_tuner_init;
-               dev->dvb.frontend->ops->tuner_ops.sleep = philips_tiger_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = philips_tiger_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.init = philips_tiger_tuner_init;
+                       dev->dvb.frontend->ops->tuner_ops.sleep = philips_tiger_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = philips_tiger_tuner_set_params;
+               }
                break;
        case SAA7134_BOARD_FLYDVBT_LR301:
                dev->dvb.frontend = tda10046_attach(&tda827x_lifeview_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.init = philips_tda827x_tuner_init;
-               dev->dvb.frontend->ops->tuner_ops.sleep = philips_tda827x_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = philips_tda827x_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.init = philips_tda827x_tuner_init;
+                       dev->dvb.frontend->ops->tuner_ops.sleep = philips_tda827x_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = philips_tda827x_tuner_set_params;
+               }
                break;
        case SAA7134_BOARD_FLYDVB_TRIO:
                dev->dvb.frontend = tda10046_attach(&lifeview_trio_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.sleep = lifeview_trio_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = lifeview_trio_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.sleep = lifeview_trio_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = lifeview_trio_tuner_set_params;
+               }
                break;
        case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
                dev->dvb.frontend = tda10046_attach(&ads_tech_duo_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.init = ads_duo_tuner_init;
-               dev->dvb.frontend->ops->tuner_ops.sleep = ads_duo_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = ads_duo_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.init = ads_duo_tuner_init;
+                       dev->dvb.frontend->ops->tuner_ops.sleep = ads_duo_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = ads_duo_tuner_set_params;
+               }
                break;
        case SAA7134_BOARD_TEVION_DVBT_220RF:
                dev->dvb.frontend = tda10046_attach(&tevion_dvbt220rf_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
+               }
                break;
        case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
                dev->dvb.frontend = tda10046_attach(&ads_tech_duo_config,
                                                    &dev->i2c_adap);
-               dev->dvb.frontend->ops->tuner_ops.init = ads_duo_tuner_init;
-               dev->dvb.frontend->ops->tuner_ops.sleep = ads_duo_tuner_sleep;
-               dev->dvb.frontend->ops->tuner_ops.set_params = ads_duo_tuner_set_params;
+               if (dev->dvb.frontend) {
+                       dev->dvb.frontend->ops->tuner_ops.init = ads_duo_tuner_init;
+                       dev->dvb.frontend->ops->tuner_ops.sleep = ads_duo_tuner_sleep;
+                       dev->dvb.frontend->ops->tuner_ops.set_params = ads_duo_tuner_set_params;
+               }
                break;
 #endif
 #ifdef HAVE_NXT200X