summaryrefslogtreecommitdiff
path: root/chip/stm32
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2013-10-04 11:28:48 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2013-10-07 16:20:59 +0000
commit57aaa0267ec042d8b36aacf5b3efba12df4e6ec2 (patch)
treefea9614f2048f9866b1f6333a534c15cab4056e0 /chip/stm32
parent616cc446e2cc8acb5506592ba1f965d4c06f9b2b (diff)
downloadchrome-ec-57aaa0267ec042d8b36aacf5b3efba12df4e6ec2.tar.gz
cleanup: Replace awkward I2C_PORTS_USED macro with constant
We only used I2C_PORTS_USED to iterate through the list of hardware ports actually in use, but we defined it in board.h at the same place where we matched particular I2C devices to the (possibly shared) buses they're on. This CL makes I2C_PORTS_USED into a global constant, so it can be set automatically where we initialize the ports, and doesn't have to be related to the list of attached devices. BUG=chrome-os-partner:18343 BRANCH=none TEST=manual Build everything, run all tests, should still work. Change-Id: I65f22f5cadfc4b3afe51af48faa5fb369bc3aa09 Signed-off-by: Bill Richardson <wfrichar@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/171884
Diffstat (limited to 'chip/stm32')
-rw-r--r--chip/stm32/i2c-stm32l.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/chip/stm32/i2c-stm32l.c b/chip/stm32/i2c-stm32l.c
index 778e8bc1bb..71b93a2953 100644
--- a/chip/stm32/i2c-stm32l.c
+++ b/chip/stm32/i2c-stm32l.c
@@ -402,7 +402,7 @@ int i2c_xfer(int port, int slave_addr, const uint8_t *out, int out_bytes,
const struct i2c_port_t *p = i2c_ports;
CPRINTF("[%T i2c_xfer start error; "
"try resetting i2c%d to unwedge.\n", port);
- for (i = 0; i < I2C_PORTS_USED; i++, p++) {
+ for (i = 0; i < i2c_ports_used; i++, p++) {
if (p->port == port) {
i2c_init_port(p, 1); /* force unwedge */
break;
@@ -492,7 +492,7 @@ static void i2c_freq_change(void)
const struct i2c_port_t *p = i2c_ports;
int i;
- for (i = 0; i < I2C_PORTS_USED; i++, p++)
+ for (i = 0; i < i2c_ports_used; i++, p++)
i2c_set_freq_port(p);
}
@@ -502,7 +502,7 @@ static void i2c_pre_freq_change_hook(void)
int i;
/* Lock I2C ports so freq change can't interrupt an I2C transaction */
- for (i = 0; i < I2C_PORTS_USED; i++, p++)
+ for (i = 0; i < i2c_ports_used; i++, p++)
i2c_lock(p->port, 1);
}
DECLARE_HOOK(HOOK_PRE_FREQ_CHANGE, i2c_pre_freq_change_hook, HOOK_PRIO_DEFAULT);
@@ -514,7 +514,7 @@ static void i2c_freq_change_hook(void)
i2c_freq_change();
/* Unlock I2C ports we locked in pre-freq change hook */
- for (i = 0; i < I2C_PORTS_USED; i++, p++)
+ for (i = 0; i < i2c_ports_used; i++, p++)
i2c_lock(p->port, 0);
}
DECLARE_HOOK(HOOK_FREQ_CHANGE, i2c_freq_change_hook, HOOK_PRIO_DEFAULT);
@@ -524,7 +524,7 @@ static void i2c_init(void)
const struct i2c_port_t *p = i2c_ports;
int i;
- for (i = 0; i < I2C_PORTS_USED; i++, p++)
+ for (i = 0; i < i2c_ports_used; i++, p++)
i2c_init_port(p, 0); /* do not force unwedged */
}
DECLARE_HOOK(HOOK_INIT, i2c_init, HOOK_PRIO_DEFAULT);