summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2019-02-07 17:33:13 -0800
committerchrome-bot <chrome-bot@chromium.org>2019-02-12 18:21:56 -0800
commitbe87c9f8beb86dd224226ccf9620ee0679c5024b (patch)
tree2b463d4153fdf7d825b3a767a17e4d280aa409bd /common
parent3cc20195b6e99e087efea315eb0e40c79f7f1344 (diff)
downloadchrome-ec-be87c9f8beb86dd224226ccf9620ee0679c5024b.tar.gz
USB-PD: Fix scope of variable ma in pd_find_pdo_index
This variable, ma, in pd_find_pdo_index is used only in an internal section but its scope is leaking to the entire function. This patch fixes the scope for better readability. Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> BUG=none BRANCH=none TEST=buildall Change-Id: Ice903fc830e9d95cc4f2ecbdb6fe8e606f56cf2d Reviewed-on: https://chromium-review.googlesource.com/1459825 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org>
Diffstat (limited to 'common')
-rw-r--r--common/usb_pd_policy.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/common/usb_pd_policy.c b/common/usb_pd_policy.c
index 1062719d22..aa8fba59b1 100644
--- a/common/usb_pd_policy.c
+++ b/common/usb_pd_policy.c
@@ -89,7 +89,7 @@ static unsigned max_request_mv = PD_MAX_VOLTAGE_MV; /* no cap */
int pd_find_pdo_index(int port, int max_mv, uint32_t *selected_pdo)
{
- int i, uw, mv, ma;
+ int i, uw, mv;
int ret = 0;
int __attribute__((unused)) cur_mv = 0;
int cur_uw = 0;
@@ -116,7 +116,7 @@ int pd_find_pdo_index(int port, int max_mv, uint32_t *selected_pdo)
if ((src_caps[i] & PDO_TYPE_MASK) == PDO_TYPE_BATTERY) {
uw = 250000 * (src_caps[i] & 0x3FF);
} else {
- ma = (src_caps[i] & 0x3FF) * 10;
+ int ma = (src_caps[i] & 0x3FF) * 10;
ma = MIN(ma, PD_MAX_CURRENT_MA);
uw = ma * mv;
}