diff options
Diffstat (limited to 'drivers/media/video/cx18/cx18-i2c.c')
-rw-r--r-- | drivers/media/video/cx18/cx18-i2c.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/media/video/cx18/cx18-i2c.c b/drivers/media/video/cx18/cx18-i2c.c index 680bc4e35b79..bca905901d61 100644 --- a/drivers/media/video/cx18/cx18-i2c.c +++ b/drivers/media/video/cx18/cx18-i2c.c | |||
@@ -311,8 +311,12 @@ int cx18_i2c_hw(struct cx18 *cx, u32 hw, unsigned int cmd, void *arg) | |||
311 | { | 311 | { |
312 | int addr; | 312 | int addr; |
313 | 313 | ||
314 | if (hw == CX18_HW_GPIO || hw == 0) | 314 | if (hw == 0) |
315 | return 0; | 315 | return 0; |
316 | |||
317 | if (hw == CX18_HW_GPIO) | ||
318 | return cx18_gpio(cx, cmd, arg); | ||
319 | |||
316 | if (hw == CX18_HW_CX23418) | 320 | if (hw == CX18_HW_CX23418) |
317 | return cx18_av_cmd(cx, cmd, arg); | 321 | return cx18_av_cmd(cx, cmd, arg); |
318 | 322 | ||
@@ -350,6 +354,8 @@ void cx18_call_i2c_clients(struct cx18 *cx, unsigned int cmd, void *arg) | |||
350 | cx18_av_cmd(cx, cmd, arg); | 354 | cx18_av_cmd(cx, cmd, arg); |
351 | i2c_clients_command(&cx->i2c_adap[0], cmd, arg); | 355 | i2c_clients_command(&cx->i2c_adap[0], cmd, arg); |
352 | i2c_clients_command(&cx->i2c_adap[1], cmd, arg); | 356 | i2c_clients_command(&cx->i2c_adap[1], cmd, arg); |
357 | if (cx->hw_flags & CX18_HW_GPIO) | ||
358 | cx18_gpio(cx, cmd, arg); | ||
353 | } | 359 | } |
354 | 360 | ||
355 | /* init + register i2c algo-bit adapter */ | 361 | /* init + register i2c algo-bit adapter */ |
@@ -358,6 +364,18 @@ int init_cx18_i2c(struct cx18 *cx) | |||
358 | int i; | 364 | int i; |
359 | CX18_DEBUG_I2C("i2c init\n"); | 365 | CX18_DEBUG_I2C("i2c init\n"); |
360 | 366 | ||
367 | /* Sanity checks for the I2C hardware arrays. They must be the | ||
368 | * same size and GPIO/CX23418 must be the last entries. | ||
369 | */ | ||
370 | if (ARRAY_SIZE(hw_driverids) != ARRAY_SIZE(hw_addrs) || | ||
371 | ARRAY_SIZE(hw_devicenames) != ARRAY_SIZE(hw_addrs) || | ||
372 | CX18_HW_GPIO != (1 << (ARRAY_SIZE(hw_addrs) - 2)) || | ||
373 | CX18_HW_CX23418 != (1 << (ARRAY_SIZE(hw_addrs) - 1)) || | ||
374 | hw_driverids[ARRAY_SIZE(hw_addrs) - 1]) { | ||
375 | CX18_ERR("Mismatched I2C hardware arrays\n"); | ||
376 | return -ENODEV; | ||
377 | } | ||
378 | |||
361 | for (i = 0; i < 2; i++) { | 379 | for (i = 0; i < 2; i++) { |
362 | memcpy(&cx->i2c_adap[i], &cx18_i2c_adap_template, | 380 | memcpy(&cx->i2c_adap[i], &cx18_i2c_adap_template, |
363 | sizeof(struct i2c_adapter)); | 381 | sizeof(struct i2c_adapter)); |