diff options
author | Wolfram Sang <wsa@the-dreams.de> | 2014-02-13 15:36:31 -0500 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2014-03-10 12:19:48 -0400 |
commit | 4c5b38e881b1a91ea5816162341275670fd655ca (patch) | |
tree | 7d9cd4c5b45a68c351ede55669258c4d46304751 | |
parent | ceccd298f6fd537457576017d604fc5aa6d3c82a (diff) |
i2c: mv64xxx: refactor send_start
For start and restart, we are doing the same thing. Let's consolidate
that.
Tested-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r-- | drivers/i2c/busses/i2c-mv64xxx.c | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 203a5482a866..98de78fd27eb 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c | |||
@@ -422,6 +422,17 @@ mv64xxx_i2c_fsm(struct mv64xxx_i2c_data *drv_data, u32 status) | |||
422 | } | 422 | } |
423 | } | 423 | } |
424 | 424 | ||
425 | static void mv64xxx_i2c_send_start(struct mv64xxx_i2c_data *drv_data) | ||
426 | { | ||
427 | /* Can we offload this msg ? */ | ||
428 | if (mv64xxx_i2c_offload_msg(drv_data) < 0) { | ||
429 | /* No, switch to standard path */ | ||
430 | mv64xxx_i2c_prepare_for_io(drv_data, drv_data->msgs); | ||
431 | writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_START, | ||
432 | drv_data->reg_base + drv_data->reg_offsets.control); | ||
433 | } | ||
434 | } | ||
435 | |||
425 | static void | 436 | static void |
426 | mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) | 437 | mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) |
427 | { | 438 | { |
@@ -438,14 +449,8 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) | |||
438 | 449 | ||
439 | drv_data->msgs++; | 450 | drv_data->msgs++; |
440 | drv_data->num_msgs--; | 451 | drv_data->num_msgs--; |
441 | if (mv64xxx_i2c_offload_msg(drv_data) < 0) { | 452 | mv64xxx_i2c_send_start(drv_data); |
442 | drv_data->cntl_bits |= MV64XXX_I2C_REG_CONTROL_START; | ||
443 | writel(drv_data->cntl_bits, | ||
444 | drv_data->reg_base + drv_data->reg_offsets.control); | ||
445 | 453 | ||
446 | /* Setup for the next message */ | ||
447 | mv64xxx_i2c_prepare_for_io(drv_data, drv_data->msgs); | ||
448 | } | ||
449 | if (drv_data->errata_delay) | 454 | if (drv_data->errata_delay) |
450 | udelay(5); | 455 | udelay(5); |
451 | 456 | ||
@@ -463,13 +468,7 @@ mv64xxx_i2c_do_action(struct mv64xxx_i2c_data *drv_data) | |||
463 | break; | 468 | break; |
464 | 469 | ||
465 | case MV64XXX_I2C_ACTION_SEND_START: | 470 | case MV64XXX_I2C_ACTION_SEND_START: |
466 | /* Can we offload this msg ? */ | 471 | mv64xxx_i2c_send_start(drv_data); |
467 | if (mv64xxx_i2c_offload_msg(drv_data) < 0) { | ||
468 | /* No, switch to standard path */ | ||
469 | mv64xxx_i2c_prepare_for_io(drv_data, drv_data->msgs); | ||
470 | writel(drv_data->cntl_bits | MV64XXX_I2C_REG_CONTROL_START, | ||
471 | drv_data->reg_base + drv_data->reg_offsets.control); | ||
472 | } | ||
473 | break; | 472 | break; |
474 | 473 | ||
475 | case MV64XXX_I2C_ACTION_SEND_ADDR_1: | 474 | case MV64XXX_I2C_ACTION_SEND_ADDR_1: |