Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp481101pxb; Wed, 14 Apr 2021 22:04:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCsgifEYf8BoRM4w3jICU3foQ2/9ivybOqpW0I238E2r5FRlIJJKww1pgeF0uevrcMVYHy X-Received: by 2002:a17:906:9344:: with SMTP id p4mr1501312ejw.346.1618463087031; Wed, 14 Apr 2021 22:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618463087; cv=none; d=google.com; s=arc-20160816; b=ERAzVaLEyLeSg4gtYZWrmSHo0QkdhOFhUG5hi3l7czulMqUOmb+NRyfoGiMg6OQYuW ThafmyrFrEtvmLf781jEEk/weMKBIL1d8SGtiZiMLoG/y1hg46nk6kFgOEvxsUIKsowy q4DLY08Li9w6YseafKQCdY9b4U80LEUy56UZJTM/+l0jWQJTnjusIrt3FAk+nvAnpDM2 7g5ERtYIcaq0a/2wlCPSaJnlphrRG67ve4NG/slRIgK6Rq2Tkt5ZZKsSZgT1KAVgkpbo taXY1um1atW8n3hsSXfCgwLkybHu9pI98Em5YnaycEpe9HGc8fF7MjY7sv2XcUTHzx5G TjEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=ta/hfuNTgaP1E3sjxBNUiHOKgcFvSsn4fCVYN2yQ2i8=; b=UgPdb+77d/28zopqps9QexHOrzQdSj0WQ7ldcVyItbE4IaItkJl0fWd84iPpnFIsZg MkDzR8h/4vL1WELl5CFe+APMGto7xl1MufABeIV7cYQW+Arc7imTXvM2yco4AIp6Sp7i f0hKaWmJjYErpfydfGGbr3wd3uwKUdRZ9ZGcNpgRNMHVsNPaEZFhiZ2lEbRARQaQDCCw ObbZG6EE6GPYa0f3lk5rly1mi4l1rpniKYKhUT08GyjKg1LiQC6kryAj91TMcfyRWUgW lbyPqNKtuq41k9Q6wMp3o+NyNA0dcAj4cXCJOptOcxQE7Pd1QEwWaMtMwDPpPOBkmsYP gF+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ahXW1Hpf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w7si1357222edq.537.2021.04.14.22.04.23; Wed, 14 Apr 2021 22:04:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ahXW1Hpf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229883AbhDOFBv (ORCPT + 99 others); Thu, 15 Apr 2021 01:01:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbhDOFBs (ORCPT ); Thu, 15 Apr 2021 01:01:48 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B9ECC061756 for ; Wed, 14 Apr 2021 22:01:26 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id e18-20020a17090ac212b029014dedae7057so10635199pjt.6 for ; Wed, 14 Apr 2021 22:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=ta/hfuNTgaP1E3sjxBNUiHOKgcFvSsn4fCVYN2yQ2i8=; b=ahXW1HpfNTMtsV5U1jCpAPpqhaawkSgv+MlM/UgWctofOhAtvwxMA6cWIxInmMS4MU TdFcza3jtLTLwSRjEgxPjfAUtIf7J/DlMVCZ8QRULtVkYdKEYuhP8yTZVU6humj1kIQn Vt+pa0FqW3VAs8opeLd20G0KCJJhjkdddU44eYvDufO7yoZ9rhTPYv/BcKaId2akmT67 Au+TsA1HEhlVKJ37PqPenR3lO9XuJ+ovfEGjAV1/E8EODCERvqBUorE1pVbA3ZyYL4Gv 38AcVo1we9FXdS35W7x0cEyh4e9/YgAKb7EQDkYNH8MHkIpf2olVGjkBLCVisgLh1+Wx UWhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=ta/hfuNTgaP1E3sjxBNUiHOKgcFvSsn4fCVYN2yQ2i8=; b=WmTyZSFhRebU7D3w315qF9kqQgMtIUBDHIhkyNSArnpcEEWr/E1Jtxp6/yFEsV8uOY So4lBtPI/r8Nd6JBPEjsyMyVQ/5GzuMIMTgU4yGX+xCOzPU89YozUoXX3blxid0O+P0v 9LjwVLoSF0ZVqCd8Mb5xm35PIBNgWWMlKFEQv8uHkQ8/Rj3oXfQ5yRlA2yGyP5yRsJfG GbTgNt2b6EsYOnALYlPFPrm0u1AF2UHTph6FYFrIo43Dqh6zxGQzgXQlQzHGGFM+RUOG gGjssskYEBD2/Q17MZILWbZjGophysdCLXbRjVtQXLlR6p7YoQ2yXbmppM7tcyDtlalJ WQjw== X-Gm-Message-State: AOAM533J/MLTviLecizLiFk5gD8cH80EF0JzHkPJemYpdEPcRmlPeH5b iPcE7xMBDTl6nQDsrThTFHkBYqhz0kA= X-Received: from badhri.mtv.corp.google.com ([2620:15c:211:201:91dd:58ac:7590:aa21]) (user=badhri job=sendgmr) by 2002:a62:ab06:0:b029:249:db1c:3d7d with SMTP id p6-20020a62ab060000b0290249db1c3d7dmr1572187pff.72.1618462885850; Wed, 14 Apr 2021 22:01:25 -0700 (PDT) Date: Wed, 14 Apr 2021 22:01:21 -0700 Message-Id: <20210415050121.1928298-1-badhri@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.1.295.g9ea45b61b8-goog Subject: [PATCH v1] usb: typec: tcpm: Fix error while calculating PPS out values From: Badhri Jagan Sridharan To: Guenter Roeck , Heikki Krogerus , Greg Kroah-Hartman , Adam Thomson Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Kyle Tso , Badhri Jagan Sridharan Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org "usb: typec: tcpm: Address incorrect values of tcpm psy for pps supply" introduced a regression for req_out_volt and req_op_curr calculation. req_out_volt should consider the newly calculated max voltage instead of previously accepted max voltage by the port partner. Likewise, req_op_curr should consider the newly calculated max current instead of previously accepted max current by the port partner. Fixes: e3a072022487 ("usb: typec: tcpm: Address incorrect values of tcpm psy for pps supply") Signed-off-by: Badhri Jagan Sridharan --- drivers/usb/typec/tcpm/tcpm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c index 1c32bdf62852..04652aa1f54e 100644 --- a/drivers/usb/typec/tcpm/tcpm.c +++ b/drivers/usb/typec/tcpm/tcpm.c @@ -3132,10 +3132,10 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port) port->pps_data.req_max_volt = min(pdo_pps_apdo_max_voltage(src), pdo_pps_apdo_max_voltage(snk)); port->pps_data.req_max_curr = min_pps_apdo_current(src, snk); - port->pps_data.req_out_volt = min(port->pps_data.max_volt, - max(port->pps_data.min_volt, + port->pps_data.req_out_volt = min(port->pps_data.req_max_volt, + max(port->pps_data.req_min_volt, port->pps_data.req_out_volt)); - port->pps_data.req_op_curr = min(port->pps_data.max_curr, + port->pps_data.req_op_curr = min(port->pps_data.req_max_curr, port->pps_data.req_op_curr); } -- 2.31.1.295.g9ea45b61b8-goog