From 0550d92204570ab8a87baf6a3a076a2eb2d37209 Mon Sep 17 00:00:00 2001 From: Bill Richardson Date: Wed, 2 Oct 2013 08:40:47 -0700 Subject: Internalize magic numbers for smart USB charging Link is the only platform that uses smart usb ports. Link's board.h defines USB_CHARGE_PORT_COUNT, yet the usb_port_power_smart.c file is peppered with assumptions that that constant is always 2. This moves the constant into usb_port_power_smart.c where it belongs. BUG=chrome-os-partner:18343 BRANCH=none TEST=manual make runtests Code refactoring only, no visible changes, Change-Id: Id45e11d88585a98348105b1399c7e18c554add50 Signed-off-by: Bill Richardson Reviewed-on: https://chromium-review.googlesource.com/171565 Reviewed-by: Randall Spangler --- board/link/board.h | 3 --- common/usb_port_power_smart.c | 5 ++++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/board/link/board.h b/board/link/board.h index 0986ed20fa..4582500620 100644 --- a/board/link/board.h +++ b/board/link/board.h @@ -96,9 +96,6 @@ enum pwm_channel { /* Host connects to keyboard controller module via LPC */ #define HOST_KB_BUS_LPC -/* USB charge port */ -#define USB_CHARGE_PORT_COUNT 2 - /* GPIO signal definitions. */ enum gpio_signal { /* Inputs with interrupt handlers are first for efficiency */ diff --git a/common/usb_port_power_smart.c b/common/usb_port_power_smart.c index 369179a6de..dfe7b32d5f 100644 --- a/common/usb_port_power_smart.c +++ b/common/usb_port_power_smart.c @@ -21,10 +21,13 @@ #define USB_SYSJUMP_TAG 0x5550 /* "UP" - Usb Port */ #define USB_HOOK_VERSION 1 +#define USB_CHARGE_PORT_COUNT 2 + /* The previous USB port state before sys jump */ struct usb_state { uint8_t port_mode[USB_CHARGE_PORT_COUNT]; - uint8_t pad[2]; /* Pad to 4 bytes for system_add_jump_tag(). */ + /* Pad to 4 bytes for system_add_jump_tag(). */ + uint8_t pad[4 - USB_CHARGE_PORT_COUNT]; }; static uint8_t charge_mode[USB_CHARGE_PORT_COUNT]; -- cgit v1.2.1