From d67e76fb420f440b71101157ebb22cf2004eb0cd Mon Sep 17 00:00:00 2001 From: Aseda Aboagye Date: Thu, 3 Aug 2017 18:30:06 -0700 Subject: [PATCH] bq24392: Remove unneeded variables. The variable is_high_power was only used if a board was using charge ramping. However, we can get rid of the variable entirely. Additionally some of the intermediate gpio_signal variables can be removed as well. BUG=none BRANCH=none TEST=Build a board that uses the bq24392 but does not charge ramp. Verify that there are no compliation errors. Change-Id: I7edaa74f5029c08662d8c4a15c973beae9729fdf Signed-off-by: Aseda Aboagye Reviewed-on: https://chromium-review.googlesource.com/601533 Commit-Ready: Aseda Aboagye Tested-by: Aseda Aboagye Reviewed-by: Shawn N --- driver/bc12/bq24392.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/driver/bc12/bq24392.c b/driver/bc12/bq24392.c index 0e7948697e..ec7f71d4bf 100644 --- a/driver/bc12/bq24392.c +++ b/driver/bc12/bq24392.c @@ -43,17 +43,16 @@ static const struct bq24392_pins pin_tbl[] = { */ static void bc12_detect(const int port) { - int is_high_power; struct charge_port_info new_chg; - enum gpio_signal chip_enable; - enum gpio_signal chg_det; - chip_enable = pin_tbl[port].chip_enable; - chg_det = pin_tbl[port].chg_det; - - /* Enable the IC to begin detection. */ - gpio_set_level(chip_enable, 1); + /* + * Enable the IC to begin detection and connect switches if + * necessary. + */ + gpio_set_level(pin_tbl[port].chip_enable, 1); + new_chg.voltage = USB_CHARGER_VOLTAGE_MV; +#if defined(CONFIG_CHARGE_RAMP) || defined(CONFIG_CHARGE_RAMP_HW) /* * Apple or TomTom charger detection can take as long as 600ms. Wait a * little bit longer for margin. @@ -66,11 +65,7 @@ static void bc12_detect(const int port) * low-power standard downstream port (SDP). The system will have to * ramp the current to determine the limit. */ - is_high_power = gpio_get_level(chg_det); - - new_chg.voltage = USB_CHARGER_VOLTAGE_MV; -#ifdef CONFIG_CHARGE_RAMP - new_chg.current = is_high_power ? 2400 : 500; + new_chg.current = gpio_get_level(pin_tbl[port].chg_det) ? 2400 : 500; #else /* * If the board doesn't support charge ramping, then assume the lowest @@ -78,7 +73,7 @@ static void bc12_detect(const int port) * charging port (DCP) which can only supply 500mA. */ new_chg.current = 500; -#endif /* !defined(CONFIG_CHARGE_RAMP) */ +#endif /* !defined(CONFIG_CHARGE_RAMP && CONFIG_CHARGE_RAMP_HW) */ charge_manager_update_charge(CHARGE_SUPPLIER_OTHER, port, &new_chg); } @@ -91,10 +86,9 @@ static void bc12_detect(const int port) static void power_down_ic(const int port) { struct charge_port_info no_chg = { 0 }; - enum gpio_signal chip_enable = pin_tbl[port].chip_enable; /* Turn off the IC. */ - gpio_set_level(chip_enable, 0); + gpio_set_level(pin_tbl[port].chip_enable, 0); /* Let charge manager know there's no more charge available. */ charge_manager_update_charge(CHARGE_SUPPLIER_OTHER, port, &no_chg);