Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2366508pxp; Fri, 18 Mar 2022 09:05:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEvzFNClVHFn61QQt/MxibrEAzbsfTyep3qSl9SYYoWWosUntA1pdMarIfC/y8T3o5Q6k5 X-Received: by 2002:a17:902:b490:b0:151:6ee1:8034 with SMTP id y16-20020a170902b49000b001516ee18034mr174598plr.28.1647619542678; Fri, 18 Mar 2022 09:05:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647619542; cv=none; d=google.com; s=arc-20160816; b=qSyopJR3oo8c/bzN8cdOQ4YrWRtBwsJTGRmC0wrxG0dJcqYJlADlIopvwDJA6ClGUa yrm9ZKidnvoyuGi9QZWDZUku3T8v0v3RsPUR3xWHwF0BGPsoROzmxArqHj6q1imSEGfB zfE/KNRpgHOBJ2ddRn41k9MwNkPKZi8gn7pmZFDq6CXTG5ai1dtd8+3fCQHBb/tDga/C TBP6IAiOClrYZG7OT1Ze5pr9Gi+HJYu+jgdxkWGzkfbIwIEulPy2+24hLOull7cCRdU0 Un10me2Yf/5ta9p7u+Z6cqrHPXJqDYmW5FIAKPkzMR9e4bA7zzlITlq8SduKQQZ2WuV1 10mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=gdJy8KDJJqmZ9B5JDH3Ed9jqDYHGnMTV1QhHIxa70VU=; b=O0K0COWsX5l474J3QVgAT6jplyTgxMBa/4fUgKicBlp3O8JBzZCJn8o8mu6MrsszK9 vq+UEjClt1t+A8L5cB+XUTGb+dvQtOk5G2z5AAmnYlCMkK3gJKyyh4mDoiEkFJyi5eCr MiGjeFi07/CBP74im8MOvHLiEecQQZz1feCQbzxxLvWcwSJXxrXFeJGqyO6x9GdMPk8m MV0tLPV5/OZtElY58RSvyLcD8GaheE/ETj0J/aJ4ACnfo3YvcxhPkrhtvHBhMfYZLe6H IG5EdR49S6BxZdZ/dFjVeeexDd/G24tpFtgsB5nUcqKo8O2ppbNYUf0OB7SAsBf393r3 UE2g== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a639f01000000b003816043ef94si5726158pge.393.2022.03.18.09.05.27; Fri, 18 Mar 2022 09:05:42 -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; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233630AbiCRISK (ORCPT + 99 others); Fri, 18 Mar 2022 04:18:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233645AbiCRIR4 (ORCPT ); Fri, 18 Mar 2022 04:17:56 -0400 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B2D72DD9BD; Fri, 18 Mar 2022 01:16:36 -0700 (PDT) Received: by mail-lj1-f176.google.com with SMTP id 25so10325286ljv.10; Fri, 18 Mar 2022 01:16:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=gdJy8KDJJqmZ9B5JDH3Ed9jqDYHGnMTV1QhHIxa70VU=; b=GVM42SLm2lGCheCmSygx2ufuVdNvkgpp7NOnZxDwrfAZ0IMawN8wuuTFTeLufayWrt OTG3ri8PSqJqEO59RmC9Rksu4cdinWSPqEovriMnuun9btG+POeEDBUbc+I0gORWPMcw KWbZkfqzTxYK2H4pXJnjpgVarEStfgOHHWIYyqXuGHpEOvXtSqO5ueABE4J7v5A2RqUB 2OxD9UBcY3pqyTsI5gX0J74ki8bLm2SIs5GktoR7Pgzb4PcHpM4e04Qoy8MdJq4rST/Y djuHNI+91ZPW19t2kPOXb4/qzMLqcJzswLkZT+tDFVO0mt95hoGn22iTnvpu7fUofAKy tLRw== X-Gm-Message-State: AOAM532agG29LLzg6LeP5BTMfoqXFERPRrpWLfjPkx0HOWVqXz/cMmHa vGXo6w/4R0klIoVQr4aftH4= X-Received: by 2002:a2e:9bd7:0:b0:248:ca3:ecf1 with SMTP id w23-20020a2e9bd7000000b002480ca3ecf1mr5678862ljj.66.1647591394254; Fri, 18 Mar 2022 01:16:34 -0700 (PDT) Received: from [192.168.0.17] (78-11-189-27.static.ip.netia.com.pl. [78.11.189.27]) by smtp.googlemail.com with ESMTPSA id d12-20020ac241cc000000b004437eab8187sm743539lfi.73.2022.03.18.01.16.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Mar 2022 01:16:33 -0700 (PDT) Message-ID: <97d88728-4e73-0820-07e7-199377ebff2a@kernel.org> Date: Fri, 18 Mar 2022 09:16:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH 1/4] power: supply: max17042_battery: Add unit conversion macros Content-Language: en-US To: Sebastian Krzyszkowiak , Hans de Goede , Marek Szyprowski , Sebastian Reichel , linux-pm@vger.kernel.org Cc: Purism Kernel Team , Rob Herring , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org References: <20220318001048.20922-1-sebastian.krzyszkowiak@puri.sm> <20220318001048.20922-2-sebastian.krzyszkowiak@puri.sm> From: Krzysztof Kozlowski In-Reply-To: <20220318001048.20922-2-sebastian.krzyszkowiak@puri.sm> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 18/03/2022 01:10, Sebastian Krzyszkowiak wrote: > Instead of sprinkling the code with magic numbers, put the unit > definitions used by the gauge into a set of macros. Macros are > used instead of simple defines in order to not require floating > point operations for divisions. > > Signed-off-by: Sebastian Krzyszkowiak > --- > drivers/power/supply/max17042_battery.c | 40 +++++++++++++++---------- > 1 file changed, 24 insertions(+), 16 deletions(-) > > diff --git a/drivers/power/supply/max17042_battery.c b/drivers/power/supply/max17042_battery.c > index ab031bbfbe78..c019d6c52363 100644 > --- a/drivers/power/supply/max17042_battery.c > +++ b/drivers/power/supply/max17042_battery.c > @@ -51,6 +51,15 @@ > > #define MAX17042_VMAX_TOLERANCE 50 /* 50 mV */ > > +#define MAX17042_CURRENT_LSB 1562500ll /* µV */ Is this really long long? The usage in max17042_get_status() is with int operand and result. > +#define MAX17042_CURRENT_RSENSE(x) (x * MAX17042_CURRENT_LSB) /* µV */ > +#define MAX17042_CAPACITY_LSB 5000000ll /* µVh */ > +#define MAX17042_CAPACITY_RSENSE(x) (x * MAX17042_CAPACITY_LSB) /* µVh */ > +#define MAX17042_TIME(x) (x * 5625 / 1000) /* s */ > +#define MAX17042_VOLTAGE(x) (x * 625 / 8) /* µV */ > +#define MAX17042_RESISTANCE(x) (x / 4096) /* Ω */ > +#define MAX17042_TEMPERATURE(x) (x / 256) /* °C */ Please enclose the "x" in (), in each macro Best regards, Krzysztof