From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99AA8C433EF for ; Sun, 19 Jun 2022 11:30:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236488AbiFSLac (ORCPT ); Sun, 19 Jun 2022 07:30:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233282AbiFSLaa (ORCPT ); Sun, 19 Jun 2022 07:30:30 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6837E6153; Sun, 19 Jun 2022 04:30:29 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id b8so11504044edj.11; Sun, 19 Jun 2022 04:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dii8VuYLfhheu24I0H2mSS/JbdyBYyJrhuHrjEWNep8=; b=H73WJ5wS/lcH7ESxBi9N6v0fuq/imzTT243AhNEWbotV+kDycqp4amFwqxVGWPgrEM mfVge7TEHyEOTmFtB26nQkyyGsBe3M2dST4La+SYhuIxfRopySqhZB8tLTQdh4fC0oQr ubNBezbWf3L581nUvkDuv/j8WdvmkmkDzW5bR7EaaaJWHA7hrgI/tcQT2hpZ2l1TOcv4 Kala75ia0q4xpBopGv1xYG9EwogOpWgZIY/Cdt5KP5wpcTqypPiom/w5jkKcqT0LzIz9 SXoHX7rI+eNCdbZVojAgnX4Aq8Ftoy4DG0X0NA8OaRvqDnEdoEVdkiSZF2AWY/ZqjTl/ MMug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dii8VuYLfhheu24I0H2mSS/JbdyBYyJrhuHrjEWNep8=; b=jdK01oSusDBJYu9b9a7zClMmgZSdm13/MicFwTOpxzW+K8rKeTL8GrrcyQQbdTMISi FuCMw7xZR+/DWdL4aO/8MOOgWXIB+c8W8XDzou/6tHysSjA02tPnP29cRHu/oUnPxL6g jgCnQxb22gDt4BZijziP/dDd4efRlM3a4Us7bv9BAQ3+DLhSI64wE1JSXx6tZpMCcQoE 2qSPzrfCHrU2Zu11kyBMc1gpMQ+j76U3ey9iISLa6j1sQCH1luqsCAKLrIY2uQoWA8KC fC/Ma8V90Hg1dBD3gQ2UDimqa2sHxkHamxjnjC/9yUXNYu8N25xCCw3YBPsBWhu0anEt 2jMg== X-Gm-Message-State: AJIora9dhvpwGbGy+Vuax1xaxLH/DKvXC7lriXB94u/lcJEMyDVHUIBQ 5Nlj3aGA6tDrMMDcnTlMff09IjuC/PigmDOTTvc= X-Google-Smtp-Source: AGRyM1tmCPFLldxcHibE0j0SJ2ekIyeJvZqio2SLPBqgBP6Z9t1TIuL93zuILFdc1FEXNfnQrLKTO/klpl+Lyo7EkCo= X-Received: by 2002:aa7:d29a:0:b0:435:705f:1319 with SMTP id w26-20020aa7d29a000000b00435705f1319mr7652411edq.54.1655638227941; Sun, 19 Jun 2022 04:30:27 -0700 (PDT) MIME-Version: 1.0 References: <20220618214009.2178567-1-aidanmacdonald.0x0@gmail.com> <20220618214009.2178567-15-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20220618214009.2178567-15-aidanmacdonald.0x0@gmail.com> From: Andy Shevchenko Date: Sun, 19 Jun 2022 13:29:51 +0200 Message-ID: Subject: Re: [PATCH v3 14/16] power: axp20x_battery: Add constant charge current table To: Aidan MacDonald Cc: Linus Walleij , Bartosz Golaszewski , Rob Herring , Krzysztof Kozlowski , Chen-Yu Tsai , Jonathan Cameron , Lee Jones , Sebastian Reichel , Mark Brown , Greg Kroah-Hartman , Liam Girdwood , Lars-Peter Clausen , "Rafael J. Wysocki" , quic_gurus@quicinc.com, Sebastian Reichel , Michael Walle , "open list:GPIO SUBSYSTEM" , devicetree , Linux Kernel Mailing List , linux-iio , Linux PM Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jun 18, 2022 at 11:40 PM Aidan MacDonald wrote: > > Add a table-based lookup method for constant charge current, > which is necessary when the setting cannot be represented as > a linear range. > > This also replaces the hard-coded 300 mA default ccc setting > if the DT-specified value is unsupported; the minimum value > for the device is now set exactly instead of relying on the > value being rounded down to a supported value. ... > +static int axp20x_get_constant_charge_current_sel(struct axp20x_batt_ps *axp_batt, > + int charge_current) > +{ > + int i; > + > + if (axp_batt->data->ccc_table) { > + for (i = AXP20X_CHRG_CTRL1_TGT_CURR; i >= 0; --i) { i-- should give the same result. > + if (axp_batt->data->ccc_table[i] <= charge_current) > + return i; > + } > + > + return -EINVAL; > + } > + i = (charge_current - axp_batt->data->ccc_offset) / axp_batt->data->ccc_scale; > + No need to have a blank line here. > + if (i > AXP20X_CHRG_CTRL1_TGT_CURR || i < 0) > + return -EINVAL; > + > + return i; > +} -- With Best Regards, Andy Shevchenko