Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2009492iog; Sun, 19 Jun 2022 05:05:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sYMmNDgifcE8HrGxj1jnQOmdhW1L9hq/WgTy7NXcNwLMKD626jROimX5Ufm7A8zYVtGoRe X-Received: by 2002:a63:368f:0:b0:40c:50f1:a9a0 with SMTP id d137-20020a63368f000000b0040c50f1a9a0mr10763662pga.312.1655640359693; Sun, 19 Jun 2022 05:05:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655640359; cv=none; d=google.com; s=arc-20160816; b=AqKEYUkkYE6cOkV86alEBc96MJ7mBZCpxQlwyvEVsBdKGNpkyXR+4B8gSP5BzhbB+g DeBO4FIdMgPpijBgsLHS6xUUvK7HoIbSWUy4XgZwPGdQguvo6mv6hGOQjKCoUqTO22R0 mkfagmLPNhCCA08SIauLKzVzsUJkFU6JV4BBc+4UrSW+rttXZTUnp6admZPgmIWweQ/G thbHsl8V4DAgpPk5iRSEcUVszgZ9FLrwjNiVRffaAxW2MwIeEswhyBThxCPUU/+vAJHy AnQB3+hZmRWWZcvrFJkyXNEDr+5C1KrqG9dA8NustXMwtrm62NVl6fX4SYU/V3/ZVlVR pvPg== 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=dii8VuYLfhheu24I0H2mSS/JbdyBYyJrhuHrjEWNep8=; b=R9mc5Usl+IeeKX/iT+wE4R5gg2tmd05ozCXdLyxzihKN1RUl2pYX6vHgXxIUsv0gue Tmhl32cDvoxD4c4wRgkKFJ/AY6aodl7PYgNsxnn4cbB3niXtjCvXCmiQZZgemZoPp1kK j2JrfA41VFHdDxo4bAbLPpFvCYN8u/Be1lu5gEuQ5V2t6JviFH04EZBR+7w3wkUhbFGw FAx+96FtPJiJOz8erKZTQ/r73MeF2YnV2r2ZOeSfz8dYe9RwwQKQze6F381/C19BY+3l jnnV1IqLz6BMHlU1ucXzhruQ3p4CsjW2fNa4Nd6tHIhOW0MOe96vyD/wLmFDsK+El0TS o+Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=H73WJ5wS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u186-20020a6385c3000000b0040c67af0819si6060393pgd.290.2022.06.19.05.05.46; Sun, 19 Jun 2022 05:05:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=H73WJ5wS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236450AbiFSLab (ORCPT + 99 others); Sun, 19 Jun 2022 07:30:31 -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-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" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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