diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-22 13:46:10 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:07:53 -0400 |
commit | 0be51b4671b3ae3ae544a0bb3d15b55478b55e72 (patch) | |
tree | 0de42232dc985bfa3d2e9490be89b870702880ff | |
parent | 0fea03fbd3aeaa9b4a4de8409e5ef3aca43a6d0b (diff) |
V4L/DVB (7398): Adds an error if priv argument of tuner_callback is NULL
Adds a consistency check to avoid OOPS, if tuner_callback priv argument is
NULL. Also, simplifies callback codes on cx88.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/video/cx88/cx88-cards.c | 55 | ||||
-rw-r--r-- | drivers/media/video/saa7134/saa7134-cards.c | 3 |
2 files changed, 32 insertions, 26 deletions
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c index 603b3664381a..6b83e3457b70 100644 --- a/drivers/media/video/cx88/cx88-cards.c +++ b/drivers/media/video/cx88/cx88-cards.c | |||
@@ -2090,11 +2090,9 @@ static void gdi_eeprom(struct cx88_core *core, u8 *eeprom_data) | |||
2090 | 2090 | ||
2091 | /* ------------------------------------------------------------------- */ | 2091 | /* ------------------------------------------------------------------- */ |
2092 | /* some Divco specific stuff */ | 2092 | /* some Divco specific stuff */ |
2093 | static int cx88_dvico_xc2028_callback(void *priv, int command, int arg) | 2093 | static int cx88_dvico_xc2028_callback(struct cx88_core *core, |
2094 | int command, int arg) | ||
2094 | { | 2095 | { |
2095 | struct i2c_algo_bit_data *i2c_algo = priv; | ||
2096 | struct cx88_core *core = i2c_algo->data; | ||
2097 | |||
2098 | switch (command) { | 2096 | switch (command) { |
2099 | case XC2028_TUNER_RESET: | 2097 | case XC2028_TUNER_RESET: |
2100 | cx_write(MO_GP0_IO, 0x101000); | 2098 | cx_write(MO_GP0_IO, 0x101000); |
@@ -2112,11 +2110,9 @@ static int cx88_dvico_xc2028_callback(void *priv, int command, int arg) | |||
2112 | /* ----------------------------------------------------------------------- */ | 2110 | /* ----------------------------------------------------------------------- */ |
2113 | /* some Geniatech specific stuff */ | 2111 | /* some Geniatech specific stuff */ |
2114 | 2112 | ||
2115 | static int cx88_xc3028_geniatech_tuner_callback(void *priv, int command, int mode) | 2113 | static int cx88_xc3028_geniatech_tuner_callback(struct cx88_core *core, |
2114 | int command, int mode) | ||
2116 | { | 2115 | { |
2117 | struct i2c_algo_bit_data *i2c_algo = priv; | ||
2118 | struct cx88_core *core = i2c_algo->data; | ||
2119 | |||
2120 | switch (command) { | 2116 | switch (command) { |
2121 | case XC2028_TUNER_RESET: | 2117 | case XC2028_TUNER_RESET: |
2122 | switch (INPUT(core->input).type) { | 2118 | switch (INPUT(core->input).type) { |
@@ -2143,11 +2139,9 @@ static int cx88_xc3028_geniatech_tuner_callback(void *priv, int command, int mod | |||
2143 | 2139 | ||
2144 | /* ------------------------------------------------------------------- */ | 2140 | /* ------------------------------------------------------------------- */ |
2145 | /* some Divco specific stuff */ | 2141 | /* some Divco specific stuff */ |
2146 | static int cx88_pv_8000gt_callback(void *priv, int command, int arg) | 2142 | static int cx88_pv_8000gt_callback(struct cx88_core *core, |
2143 | int command, int arg) | ||
2147 | { | 2144 | { |
2148 | struct i2c_algo_bit_data *i2c_algo = priv; | ||
2149 | struct cx88_core *core = i2c_algo->data; | ||
2150 | |||
2151 | switch (command) { | 2145 | switch (command) { |
2152 | case XC2028_TUNER_RESET: | 2146 | case XC2028_TUNER_RESET: |
2153 | cx_write(MO_GP2_IO, 0xcf7); | 2147 | cx_write(MO_GP2_IO, 0xcf7); |
@@ -2198,21 +2192,20 @@ static void dvico_fusionhdtv_hybrid_init(struct cx88_core *core) | |||
2198 | } | 2192 | } |
2199 | } | 2193 | } |
2200 | 2194 | ||
2201 | static int cx88_xc2028_tuner_callback(void *priv, int command, int arg) | 2195 | static int cx88_xc2028_tuner_callback(struct cx88_core *core, |
2196 | int command, int arg) | ||
2202 | { | 2197 | { |
2203 | struct i2c_algo_bit_data *i2c_algo = priv; | ||
2204 | struct cx88_core *core = i2c_algo->data; | ||
2205 | |||
2206 | /* Board-specific callbacks */ | 2198 | /* Board-specific callbacks */ |
2207 | switch (core->boardnr) { | 2199 | switch (core->boardnr) { |
2208 | case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: | 2200 | case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: |
2209 | case CX88_BOARD_POWERCOLOR_REAL_ANGEL: | 2201 | case CX88_BOARD_POWERCOLOR_REAL_ANGEL: |
2210 | case CX88_BOARD_GENIATECH_X8000_MT: | 2202 | case CX88_BOARD_GENIATECH_X8000_MT: |
2211 | return cx88_xc3028_geniatech_tuner_callback(priv, command, arg); | 2203 | return cx88_xc3028_geniatech_tuner_callback(core, |
2204 | command, arg); | ||
2212 | case CX88_BOARD_PROLINK_PV_8000GT: | 2205 | case CX88_BOARD_PROLINK_PV_8000GT: |
2213 | return cx88_pv_8000gt_callback(priv, command, arg); | 2206 | return cx88_pv_8000gt_callback(core, command, arg); |
2214 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: | 2207 | case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO: |
2215 | return cx88_dvico_xc2028_callback(priv, command, arg); | 2208 | return cx88_dvico_xc2028_callback(core, command, arg); |
2216 | } | 2209 | } |
2217 | 2210 | ||
2218 | switch (command) { | 2211 | switch (command) { |
@@ -2246,11 +2239,9 @@ static int cx88_xc2028_tuner_callback(void *priv, int command, int arg) | |||
2246 | * PCTV HD 800i with an xc5000 sillicon tuner. This is used for both * | 2239 | * PCTV HD 800i with an xc5000 sillicon tuner. This is used for both * |
2247 | * analog tuner attach (tuner-core.c) and dvb tuner attach (cx88-dvb.c) */ | 2240 | * analog tuner attach (tuner-core.c) and dvb tuner attach (cx88-dvb.c) */ |
2248 | 2241 | ||
2249 | static int cx88_xc5000_tuner_callback(void *priv, int command, int arg) | 2242 | static int cx88_xc5000_tuner_callback(struct cx88_core *core, |
2243 | int command, int arg) | ||
2250 | { | 2244 | { |
2251 | struct i2c_algo_bit_data *i2c_algo = priv; | ||
2252 | struct cx88_core *core = i2c_algo->data; | ||
2253 | |||
2254 | switch (core->boardnr) { | 2245 | switch (core->boardnr) { |
2255 | case CX88_BOARD_PINNACLE_PCTV_HD_800i: | 2246 | case CX88_BOARD_PINNACLE_PCTV_HD_800i: |
2256 | if (command == 0) { /* This is the reset command from xc5000 */ | 2247 | if (command == 0) { /* This is the reset command from xc5000 */ |
@@ -2284,15 +2275,27 @@ static int cx88_xc5000_tuner_callback(void *priv, int command, int arg) | |||
2284 | int cx88_tuner_callback(void *priv, int command, int arg) | 2275 | int cx88_tuner_callback(void *priv, int command, int arg) |
2285 | { | 2276 | { |
2286 | struct i2c_algo_bit_data *i2c_algo = priv; | 2277 | struct i2c_algo_bit_data *i2c_algo = priv; |
2287 | struct cx88_core *core = i2c_algo->data; | 2278 | struct cx88_core *core; |
2279 | |||
2280 | if (!i2c_algo) { | ||
2281 | printk(KERN_ERR "cx88: Error - i2c private data undefined.\n"); | ||
2282 | return -EINVAL; | ||
2283 | } | ||
2284 | |||
2285 | core = i2c_algo->data; | ||
2286 | |||
2287 | if (!core) { | ||
2288 | printk(KERN_ERR "cx88: Error - device struct undefined.\n"); | ||
2289 | return -EINVAL; | ||
2290 | } | ||
2288 | 2291 | ||
2289 | switch (core->board.tuner_type) { | 2292 | switch (core->board.tuner_type) { |
2290 | case TUNER_XC2028: | 2293 | case TUNER_XC2028: |
2291 | info_printk(core, "Calling XC2028/3028 callback\n"); | 2294 | info_printk(core, "Calling XC2028/3028 callback\n"); |
2292 | return cx88_xc2028_tuner_callback(priv, command, arg); | 2295 | return cx88_xc2028_tuner_callback(core, command, arg); |
2293 | case TUNER_XC5000: | 2296 | case TUNER_XC5000: |
2294 | info_printk(core, "Calling XC5000 callback\n"); | 2297 | info_printk(core, "Calling XC5000 callback\n"); |
2295 | return cx88_xc5000_tuner_callback(priv, command, arg); | 2298 | return cx88_xc5000_tuner_callback(core, command, arg); |
2296 | } | 2299 | } |
2297 | err_printk(core, "Error: Calling callback for tuner %d\n", | 2300 | err_printk(core, "Error: Calling callback for tuner %d\n", |
2298 | core->board.tuner_type); | 2301 | core->board.tuner_type); |
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c index b622d979e634..c323ca005f72 100644 --- a/drivers/media/video/saa7134/saa7134-cards.c +++ b/drivers/media/video/saa7134/saa7134-cards.c | |||
@@ -5266,6 +5266,9 @@ int saa7134_tuner_callback(void *priv, int command, int arg) | |||
5266 | case TUNER_XC2028: | 5266 | case TUNER_XC2028: |
5267 | return saa7134_xc2028_callback(dev, command, arg); | 5267 | return saa7134_xc2028_callback(dev, command, arg); |
5268 | } | 5268 | } |
5269 | } else { | ||
5270 | printk(KERN_ERR "saa7134: Error - device struct undefined.\n"); | ||
5271 | return -EINVAL; | ||
5269 | } | 5272 | } |
5270 | return -EINVAL; | 5273 | return -EINVAL; |
5271 | } | 5274 | } |