Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp3382433pxb; Wed, 14 Apr 2021 04:23:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRhS07TC4WLMMx+wB/adaefXYj/0fpBPzq4Q3T7+e9gzSmPdCZoV467ZBLHTAeYzbdaIFb X-Received: by 2002:a17:906:8317:: with SMTP id j23mr28966272ejx.13.1618399388939; Wed, 14 Apr 2021 04:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618399388; cv=none; d=google.com; s=arc-20160816; b=M25LS/dBTvob5eDn6eO0OBM99XQXxtAriXbxXOItsSWzGJBRbCLAwtp5j4Qg0h2Hdb 9dlQnYFEooXYofmje3o3oUefyq0MAZaBEH/MM78332ZbzkWaZwYURBPeTwCF+Uy5zQ1k 0oHXxSACdgmgparoogsBMr1GqwYq+zlGvGpmw7wXTRvijGd4neMcxS1sgQlrEcrDhcQq VO63Z9f/Zy8X9ecr33CjkA4399agHoTJ+LcNWHN5PUPfymwaO6q4RzcEM0e7utWgEpmP tYk5vRlx6HtJJbjd6wr9Dp9gG1OjXyiwF754EO4YILPuRFNhsFyWja+aV45KepqoAYVa Lwig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=c4u9Tmp7ZH5AX/rlmzOqTLYd8P3KJj0zG0wbcgk2yAg=; b=wzP1PiaXqwusgy9nkzFjH52YalNdgImSBb00M9c+6DnPCtTG3ajmoDzx7rQ27L8lGd E0bB6Y4TA3zIlCPboDvMjMpyKzCovqqaJo/nRWW/2yzK5eC6CvsFcJEgAgES47s3ELL8 Xj5XdOyAPAaunyfrfLKiNFqo7Y2oOwcHBRucsOjCb8UDQ09R35aD2Z+oQBgxzK0nNsfe fxZZmBiOAXbdTOcmxHLxGOXyP9xGF1x9dOlrbT9zNTNUNvS1et1BmfaOMcca0s5Olu54 vvSzZTG9TvtnV9OG8KR3LOvC5Fu3WLiUZRuKdrFiLNh4bBLhCWX2XMdFLmJAwS+ighaC V5pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=o2jSaxay; 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 dn22si12692590edb.202.2021.04.14.04.22.46; Wed, 14 Apr 2021 04:23:08 -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=o2jSaxay; 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 S1348925AbhDNBAv (ORCPT + 99 others); Tue, 13 Apr 2021 21:00:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348903AbhDNBAs (ORCPT ); Tue, 13 Apr 2021 21:00:48 -0400 Received: from mail-vs1-xe30.google.com (mail-vs1-xe30.google.com [IPv6:2607:f8b0:4864:20::e30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4231EC06175F for ; Tue, 13 Apr 2021 18:00:28 -0700 (PDT) Received: by mail-vs1-xe30.google.com with SMTP id k124so9531667vsk.3 for ; Tue, 13 Apr 2021 18:00:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=c4u9Tmp7ZH5AX/rlmzOqTLYd8P3KJj0zG0wbcgk2yAg=; b=o2jSaxaynSzILqsenU5eU94XstdDEfcr+8Qslmm/mklm5VuSsLkPrNRYCMhErZuLSI +rib2nSDOqgvO5oB+cXyFVnaY95iSY728Ze0VwRhgpbvJaUIDH0g3ExjNtYJz9M+TtS8 Kke/f4yYgKs1QuJK8QjeYVg9qNv7JC14pbvfHg5ZUSKF9MdarZUcy34CdI2+DrevJcls 0/iyrqvTDT/ZKCGexUDcycfXPZxKitln1l6AgKmDP+aKavq7V5Oe7uGTOv3SY1PZv+T5 Fxi8bBc6IQGq3UMP2hdtaKCfwQ0ETvAKLkuRiM2Dj/umSwJ+F9XXwbFYd0hPt87Bc0CV /rmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=c4u9Tmp7ZH5AX/rlmzOqTLYd8P3KJj0zG0wbcgk2yAg=; b=h8PEcWE0vR3TaXyD78grhSEXDUFxXc+MwZ3aGzKORPB1voquUfXZsiAuhXqSsR3YR9 XcYlyFrMMpOSQykbq9exhxG2HLIWV9siWJqw0obYAmeAr+ae3qRSI09YSnLuTFN7yHFu P1wVDIgRWDzMs/UOaWlBPfC/pT2Y7/hQsRDe4dbYz4+02lsuDAA34aJFcEKC4QZz9bE6 sKMA4d+vqr4uQosRkNDRGbm9Hn02BuNlvWkakgPwIKEQ4YYQ5z4z0TnqTjOK6yMU8XGd YmnEdyXiLQ/S4MFF8SAoqjE9udP11HF/CDSkfA92FXLMCm8oikyZcb8ljkc3v83q8N8c l4bQ== X-Gm-Message-State: AOAM533Q4ivEGLV3YVWO3/+vQukhszcSMhBD5Oy+zLLaNiqWdszd9Tei WxrpqE6glzV1mMnkl0J3ZEfnzihXLf8znY/SNEpVnA== X-Received: by 2002:a67:2d14:: with SMTP id t20mr23340021vst.48.1618362027253; Tue, 13 Apr 2021 18:00:27 -0700 (PDT) MIME-Version: 1.0 References: <20210407200723.1914388-1-badhri@google.com> <20210407200723.1914388-5-badhri@google.com> In-Reply-To: From: Badhri Jagan Sridharan Date: Tue, 13 Apr 2021 17:59:52 -0700 Message-ID: Subject: Re: [PATCH v2 5/6] usb: typec: tcpm: Allow slow charging loops to comply to pSnkStby To: Heikki Krogerus Cc: Guenter Roeck , Greg Kroah-Hartman , Rob Herring , Adam Thomson , USB , LKML , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Kyle Tso Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 8, 2021 at 1:22 AM Heikki Krogerus wrote: > > > > @@ -4047,9 +4053,12 @@ static void run_state_machine(struct tcpm_port *port) > > > break; > > > case SNK_DISCOVERY: > > > if (port->vbus_present) { > > > - tcpm_set_current_limit(port, > > > - tcpm_get_current_limit(port), > > > - 5000); > > > + u32 current_lim = (!port->slow_charger_loop || > > > + (tcpm_get_current_limit(port) <= > > > + PD_P_SNK_STDBY_MW / 5)) ? > > > + tcpm_get_current_limit(port) : > > > + PD_P_SNK_STDBY_MW / 5; > > > > Here the use of the ternary operator is not appropriate. Please try to > > clean that up somehow. Maybe something like this would be better? > > > > u32 current_lim = tcpm_get_current_limit(port); > > > > if (port->slow_charger_loop || (current_lim < PD_P_SNK_STDBY_MW / 5)) > > current_lim = PD_P_SNK_STDBY_MW / 5; > > Sorry, I mean: > > if (port->slow_charger_loop || (current_lim > PD_P_SNK_STDBY_MW / 5)) > current_lim = PD_P_SNK_STDBY_MW / 5; Ack. Updating in my next version: V3. Thanks, Badhri > > thanks, > > -- > heikki