Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp656967pxj; Thu, 27 May 2021 08:46:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8rjc/egUV3CBoAf70dwLLVF7VXpjNLi/b5AzTFUPnh6B+Sm2QeE4d62h52/4+FbeuHuCP X-Received: by 2002:a05:6402:3507:: with SMTP id b7mr4822611edd.101.1622130367763; Thu, 27 May 2021 08:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622130367; cv=none; d=google.com; s=arc-20160816; b=MjxodnbrtghcW+sCrJH8Zsvuaz8V6zM0HvPGpAlgAzVcnO+VFn0Uh7UE6nI88OE92T LLGzyYwTRBWqxHlgwuY7q5tQiU5JnuZovfy3ft15NHH/jvT430w7sCXeWBZZg2kE9pS5 ugcBMel1sCris/JZ3sewTfz/TqnwehXZrm3TfGKIDz9ezSzyxihLpTnw5HQzvYVVnKAE 2ifB+Aax+AG5HEwE/l78yrlB3eUFjQWgtmwLM8O2dnrJDIgn9Sd4UcVFc3HQDxnClnKe ImJhSIvuk5zOnNmTdm0D12imTkX8mblIrpmhYdfcJv7ccuLMxUd/x3Wi6gEbBXiXL3kB 6Llg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:user-agent:date :mime-version:references:in-reply-to:cc:to:reply-to:from:subject :message-id; bh=4IxwT6jVEBPP1PUK7HR4Lpreyst/kOYfM9RywQLhveM=; b=jCwtB+FBQXOk9vuwZyuiy0iZpuLwcbo9ERJ7qrh0jzWwnk621xZlnJEyCkpgqDL9oN 7B2KkmPhpyF2yO5IsdqM/O5q1r3tZMlgH4vnVLEqytAduOy6F/GRcPkA9780uWKwQ7QS Se13CJpsHJ49d1XVZb1pCmdM2XDIq6XbC+JwM5nSzSQMdMHPXCnMr3JG0hN2mA0KPzES O+enyYIayLkr5zkXbQZtbIFeIMBdgMjRd7D5B9ZVB/m+oBxZuBjdt/WXvQjBRRsChKUQ hNuCv8YgR+ug+5l4GrLSkOJ8BqRKVkooH4FYcUQdshEUB7rBSCbCC9zG9MxvfLL+5Z7b vyaA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i27si2408112ejh.691.2021.05.27.08.45.41; Thu, 27 May 2021 08:46:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236173AbhE0KYV (ORCPT + 99 others); Thu, 27 May 2021 06:24:21 -0400 Received: from mail-lj1-f171.google.com ([209.85.208.171]:46914 "EHLO mail-lj1-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236134AbhE0KYS (ORCPT ); Thu, 27 May 2021 06:24:18 -0400 Received: by mail-lj1-f171.google.com with SMTP id e11so49053ljn.13; Thu, 27 May 2021 03:22:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:reply-to:to:cc :in-reply-to:references:mime-version:date:user-agent :content-transfer-encoding; bh=4IxwT6jVEBPP1PUK7HR4Lpreyst/kOYfM9RywQLhveM=; b=q+AjMj00SHs3oe46KQ9gNDyTmNKACNn40UPqjEhDpoC76+CN5hd2J28v+K9w8kOUO3 VZ32r6g3ls8UM6DuOzye8FpOoD9cONzhOqFFwUw6BctsIMSbyXaQQ2bCFAoXqtoG4BRJ pVyNDp5EvCW6lJunvCnNzXgdhIOWATAGlSD8hB/8VPTH1MttGnwTqSuCoJWcEfMYcNj2 2hSmqHMLWEXHA/1LAkVZ23cDg0dYN1gL29UtMDF2Qs+XQXwxkccyDMFo2HrTUNmygdK1 QTrjZX7RdVrTJGeC9pyDW5k5a/NNDMcupwLWpeIv3CO48UhbzQu+LioU0APqTKySidrX NZmQ== X-Gm-Message-State: AOAM530922Ysi1wGL/4nEoP0Lfx0/SuFbHaFYKnmalFXAjO+PcEVuOC8 GjY89HcSe4vy9tO4OBDnUAiA1gNFiyg= X-Received: by 2002:a2e:b6d2:: with SMTP id m18mr1878911ljo.233.1622110963168; Thu, 27 May 2021 03:22:43 -0700 (PDT) Received: from dc7vkhyyyyyyyyyyyyycy-3.rev.dnainternet.fi (dc7vkhyyyyyyyyyyyyycy-3.rev.dnainternet.fi. [2001:14ba:16e2:8300::4]) by smtp.gmail.com with ESMTPSA id r17sm185818ljp.40.2021.05.27.03.22.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 03:22:42 -0700 (PDT) Message-ID: Subject: Re: [PATCH v4 2/2] power: supply: mt6360_charger: add MT6360 charger support From: Matti Vaittinen Reply-To: matti.vaittinen@fi.rohmeurope.com To: Gene Chen Cc: sre@kernel.org, Matthias Brugger , Rob Herring , linux-pm@vger.kernel.org, devicetree , linux-arm Mailing List , "moderated list:ARM/Mediatek SoC support" , Linux Kernel Mailing List , Gene Chen , Wilma.Wu@mediatek.com, shufan_lee@richtek.com, ChiYuan Huang , benjamin.chao@mediatek.com In-Reply-To: References: <1610973703-676-1-git-send-email-gene.chen.richtek@gmail.com> <1610973703-676-3-git-send-email-gene.chen.richtek@gmail.com> <771c7da0584cf37da6ba370207a89a7401a20c33.camel@fi.rohmeurope.com> Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Thu, 27 May 2021 13:22:33 +0300 User-Agent: Evolution 3.34.4 (3.34.4-1.fc31) Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2021-05-27 at 17:58 +0800, Gene Chen wrote: > Matti Vaittinen 於 2021年5月27日 週四 > 下午12:25寫道: > > > > On Wed, 2021-05-26 at 17:40 +0800, Gene Chen wrote: > > > Matti Vaittinen 於 2021年3月30日 > > > 週二 > > > 下午7:48寫道: > > > > On Mon, 2021-01-18 at 20:41 +0800, Gene Chen wrote: > > > > > From: Gene Chen > > > > > > > > > > Add basic support for the battery charger for MT6360 PMIC > > > > > > > > > > Signed-off-by: Gene Chen > > > > > --- > > > > > drivers/power/supply/Kconfig | 10 + > > > > > drivers/power/supply/Makefile | 1 + > > > > > drivers/power/supply/mt6360_charger.c | 914 > > > > > ++++++++++++++++++++++++++++++++++ > > > > > 3 files changed, 925 insertions(+) > > > > > create mode 100644 drivers/power/supply/mt6360_charger.c > > > > > > > > > > > > > Thanks for the contribution :) > > > > > > > > Few comments which I am not demanding to be 'fixed' - but which > > > > might > > > > be good to be checked. Eg, please consider my comments as > > > > 'nit's. > > > > > > > > ... > > > > > > > > > +static unsigned int mt6360_map_reg_sel(u32 data, u32 min, > > > > > u32 > > > > > max, > > > > > u32 step) > > > > > +{ > > > > > + u32 target = 0, max_sel; > > > > > + > > > > > + if (data >= min) { > > > > > + target = (data - min) / step; > > > > > + max_sel = (max - min) / step; > > > > > + if (target > max_sel) > > > > > + target = max_sel; > > > > > + } > > > > > + return target; > > > > > +} > > > > > > > > lib/linear_ranges.c might already implement this ... > > > > > > > > > > I found we are neither linear_range_get_selector_high or > > > linear_range_get_selector_low. > > > When value lower than min_value, choose min_sel. If higher than > > > max_value, choose max_sel. > > > > Ah, correct. > > > > > Should I create linear_range_get_selector() for this? > > > > My suggestion would be yes, but I am not insisting on it. > > > > Maybe this is a special choosing mechanism, I will keep it. > Could I also keep mt6360_map_real_val? I think adding generic function to linear range code for others to re- use would be nice. But if you choose to keep the mt6360_map_reg_sel() then it I agree that you should also keep the mt6360_map_real_val(). Best regards Matti Vaittinen