From patchwork Fri Sep 21 15:04:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Thomson X-Patchwork-Id: 10610205 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0015415A6 for ; Fri, 21 Sep 2018 15:04:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3DC42D93C for ; Fri, 21 Sep 2018 15:04:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7AAC2D99B; Fri, 21 Sep 2018 15:04:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,FROM_WORDY, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 544E72D93C for ; Fri, 21 Sep 2018 15:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390180AbeIUUxc (ORCPT ); Fri, 21 Sep 2018 16:53:32 -0400 Received: from mail1.bemta26.messagelabs.com ([85.158.142.3]:53133 "EHLO mail1.bemta26.messagelabs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728184AbeIUUxc (ORCPT ); Fri, 21 Sep 2018 16:53:32 -0400 Received: from [85.158.142.98] (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256 bits)) by server-3.bemta.az-a.eu-central-1.aws.symcld.net id DB/CE-25066-C6805AB5; Fri, 21 Sep 2018 15:04:12 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrGIsWRWlGSWpSXmKPExsUSt3OpsW4Ox9J ogxPdYhbNi9ezWXSt3slicXnXHDaLRctamS2eLDzDZLFg4yNGBzaPeScDPfbPXcPusfN7A7vH 501yASxRrJl5SfkVCawZi/v2shf0clUcX9/H3MB4gqOLkYtDSGA9o8SU5c/Yuhg5gJwKiTdb0 roYOTnYBCwkJp94wAZiswioSly6cIwRxBYWCJN4eX0rM0iviEA3o8TJTU/ZQRLMAjUS3+ZPZA WxeQUcJBa+bmeCsAUlTs58wgJRIyFx8MULZhBbSMBA4vSCRrC4hIC9xPT3V5lBbpAQ0JdoPBY LETaU+D7rG1SJucSbqzOZJzDyz0IydRaSqQsYmVYxWiYVZaZnlOQmZuboGhoY6BoaGusaAUlz vcQq3US91FLd5NS8kqJEoKxeYnmxXnFlbnJOil5easkmRmBopxQyle5gnLY8/RCjJAeTkijvs VlLooX4kvJTKjMSizPii0pzUosPMcpwcChJ8JawL40WEixKTU+tSMvMAUYZTFqCg0dJhNcEJM 1bXJCYW5yZDpE6xWjM8W7B/+nMHF+aOmcwC7Hk5eelSonzTgEpFQApzSjNgxsEi/5LjLJSwry MDAwMQjwFqUW5mSWo8q8YxTkYlYR5a0Cm8GTmlcDtewV0ChPQKVdAvuAtLklESEk1MFbpLPih fMbs1K0f2/grziQn/uVa7SFevFWn3KVUcyK/27ScXo3jq5s6vVfmyT5fea5p0ev3EdwdB78yd m3SZBCsTbq0d+qqn0wvuSzOZy+fefjHHZtzsUI1pf7c9cazxWI2PV566EBS56olotxL40Mi2M p/+ve8vM2izHDgWaHD00eucRN7+JRYijMSDbWYi4oTAU5mNYz5AgAA X-Env-Sender: Adam.Thomson.Opensource@diasemi.com X-Msg-Ref: server-31.tower-223.messagelabs.com!1537542252!88391!1 X-Originating-IP: [94.185.165.51] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.14.24; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24889 invoked from network); 21 Sep 2018 15:04:12 -0000 Received: from mailrelay2.diasemi.com (HELO sw-ex-cashub01.diasemi.com) (94.185.165.51) by server-31.tower-223.messagelabs.com with AES128-SHA encrypted SMTP; 21 Sep 2018 15:04:12 -0000 Received: from swsrvapps-01.diasemi.com (10.20.28.141) by SW-EX-CASHUB01.diasemi.com (10.20.16.140) with Microsoft SMTP Server id 14.3.382.0; Fri, 21 Sep 2018 16:04:11 +0100 Received: by swsrvapps-01.diasemi.com (Postfix, from userid 22379) id 8BEE73FBE5; Fri, 21 Sep 2018 16:04:11 +0100 (BST) From: Adam Thomson Date: Fri, 21 Sep 2018 16:04:11 +0100 Subject: [PATCH] usb: typec: tcpm: Fix APDO PPS order checking to be based on voltage To: Heikki Krogerus , Guenter Roeck , Greg Kroah-Hartman CC: , , , Message-ID: <20180921150411.8BEE73FBE5@swsrvapps-01.diasemi.com> MIME-Version: 1.0 X-KSE-AttachmentFiltering-Interceptor-Info: protection disabled X-KSE-ServerInfo: sw-ex-cashub01.diasemi.com, 9 X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 21/09/2018 13:54:00 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Guenter Roeck Reviewed-by: Heikki Krogerus --- Code based on usb-testing branch (ae8a2ca8a2215c7e31e6d874f7303801bb15fbb) drivers/usb/typec/tcpm/tcpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 4f1f421..c11b3be 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/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]) &&