From: Adam Thomson Date: Fri, 21 Sep 2018 15:04:11 +0000 (+0100) Subject: usb: typec: tcpm: Fix APDO PPS order checking to be based on voltage X-Git-Tag: rel_imx_4.19.35_1.1.0~8865 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=512307dd4f0976fa83d7cf576d10c426869bb3f5;p=linux.git usb: typec: tcpm: Fix APDO PPS order checking to be based on voltage commit 1b6af2f58c2b1522e0804b150ca95e50a9e80ea7 upstream. Current code mistakenly checks against max current to determine order but this should be max voltage. This commit fixes the issue so order is correctly determined, thus avoiding failure based on a higher voltage PPS APDO having a lower maximum current output, which is actually valid. Fixes: 2eadc33f40d4 ("typec: tcpm: Add core support for sink side PPS") Cc: Signed-off-by: Adam Thomson Reviewed-by: Heikki Krogerus Reviewed-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/typec/tcpm.c b/drivers/usb/typec/tcpm.c index 18fb0433f59a..c74cc9c309b1 100644 --- a/drivers/usb/typec/tcpm.c +++ b/drivers/usb/typec/tcpm.c @@ -1430,8 +1430,8 @@ static enum pdo_err tcpm_caps_err(struct tcpm_port *port, const u32 *pdo, if (pdo_apdo_type(pdo[i]) != APDO_TYPE_PPS) break; - if (pdo_pps_apdo_max_current(pdo[i]) < - pdo_pps_apdo_max_current(pdo[i - 1])) + if (pdo_pps_apdo_max_voltage(pdo[i]) < + pdo_pps_apdo_max_voltage(pdo[i - 1])) return PDO_ERR_PPS_APDO_NOT_SORTED; else if (pdo_pps_apdo_min_voltage(pdo[i]) == pdo_pps_apdo_min_voltage(pdo[i - 1]) &&