diff options
Diffstat (limited to 'drivers/media/i2c/s5k5baf.c')
-rw-r--r-- | drivers/media/i2c/s5k5baf.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index 4b8381111cbd..77e10e0fd8d6 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c | |||
@@ -478,25 +478,33 @@ static void s5k5baf_write_arr_seq(struct s5k5baf *state, u16 addr, | |||
478 | u16 count, const u16 *seq) | 478 | u16 count, const u16 *seq) |
479 | { | 479 | { |
480 | struct i2c_client *c = v4l2_get_subdevdata(&state->sd); | 480 | struct i2c_client *c = v4l2_get_subdevdata(&state->sd); |
481 | __be16 buf[count + 1]; | 481 | __be16 buf[65]; |
482 | int ret, n; | ||
483 | 482 | ||
484 | s5k5baf_i2c_write(state, REG_CMDWR_ADDR, addr); | 483 | s5k5baf_i2c_write(state, REG_CMDWR_ADDR, addr); |
485 | if (state->error) | 484 | if (state->error) |
486 | return; | 485 | return; |
487 | 486 | ||
487 | v4l2_dbg(3, debug, c, "i2c_write_seq(count=%d): %*ph\n", count, | ||
488 | min(2 * count, 64), seq); | ||
489 | |||
488 | buf[0] = __constant_cpu_to_be16(REG_CMD_BUF); | 490 | buf[0] = __constant_cpu_to_be16(REG_CMD_BUF); |
489 | for (n = 1; n <= count; ++n) | ||
490 | buf[n] = cpu_to_be16(*seq++); | ||
491 | 491 | ||
492 | n *= 2; | 492 | while (count > 0) { |
493 | ret = i2c_master_send(c, (char *)buf, n); | 493 | int n = min_t(int, count, ARRAY_SIZE(buf) - 1); |
494 | v4l2_dbg(3, debug, c, "i2c_write_seq(count=%d): %*ph\n", count, | 494 | int ret, i; |
495 | min(2 * count, 64), seq - count); | ||
496 | 495 | ||
497 | if (ret != n) { | 496 | for (i = 1; i <= n; ++i) |
498 | v4l2_err(c, "i2c_write_seq: error during transfer (%d)\n", ret); | 497 | buf[i] = cpu_to_be16(*seq++); |
499 | state->error = ret; | 498 | |
499 | i *= 2; | ||
500 | ret = i2c_master_send(c, (char *)buf, i); | ||
501 | if (ret != i) { | ||
502 | v4l2_err(c, "i2c_write_seq: error during transfer (%d)\n", ret); | ||
503 | state->error = ret; | ||
504 | break; | ||
505 | } | ||
506 | |||
507 | count -= n; | ||
500 | } | 508 | } |
501 | } | 509 | } |
502 | 510 | ||