Received: by 2002:a05:6500:2018:b0:1fb:9675:f89d with SMTP id t24csp150638lqh; Thu, 30 May 2024 17:59:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVj6nz0wRnh22Khx5Mi54NgmLSb18Zs0L9V3xZBtIrDbMl7F4kEoUtwJyT1mTIk7sx1l11LZZ9xMW4xZNvLDS3/T7r2RGeHY+3PWbW/nw== X-Google-Smtp-Source: AGHT+IHBOHlU0A8P/v5mncn0DyKwCd6pb/RKuWDlcuFzklXNDR3/nBMNmLn75ueSPtSpakqrEIOn X-Received: by 2002:a05:620a:2018:b0:790:a3a7:7cab with SMTP id af79cd13be357-794f5c99261mr33573985a.39.1717117156881; Thu, 30 May 2024 17:59:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717117156; cv=pass; d=google.com; s=arc-20160816; b=lW0NsrmMKW5JsU4EB/W+PMjQmK7F/L0hXEKgqs6cNUCsSZAECm/AlWezZG+7NceZwB 2JvLpwMyS60WBXm1lEj1zLzi0gg20J6cpqD5w08HZr69RgFFN3cD6Lr8OrsW+53qbF93 IeLe3kNLz7iv/CUzBxzAVILJjE49A9zVX2xC2oJdPZEnjaFV6Fd4qE5XE44czdgPZcg4 lNgTqq3wBUfyStxxatkv11FyrM/h+L6OXh6Ptsl4n5VlXQchjlrNxrEciAj3oj/Jsd3H SJ3gDOeLbFGt1p2GiFkRpoakeVApJiIILv69fmXe2Im8adO07LbNEOV9JBee63qDWqH6 nIkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QnFCRKDrZ3vO/pkEAc8zl9OdD2pxO44AabYMP/pb1KM=; fh=WS26t4Gb4zwHFjlarLZBw6Y9Ba4SYGnAREqd6XXB17I=; b=ohTTW7ftjJPO5Ak2D1f3UpW1g73TLCwBhx9WlwZKTYK3esSYAYBqq6AZ+gXVu7u5aF 9bnXhZCHTN7/c3lSSmJd72MRctqWMVLMmM/cRn5+dHUtfvFxf6OB7f+riLTolbJTZonQ Il/PnF14pyx86ADAVbKeszWpJMfxtOoPug2ZjeyzgUNeWJTb+SrUSxTP5A3ONUH57aA2 pU5f0NV23YCy6TjiA2DGZya4OKv5iLMVVhPWZEMp/XKgsaMDfYbHew8k4C7RfrKQE5XI GS8p8dss/au3YLZA76FYUGdZ8R9s6EZhxhzgwrMxwnnHcGSnZ5GM5dB/wpbCxWjkVgnk IQWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYwyhbK3; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-196109-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196109-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794f318a3ebsi89281085a.463.2024.05.30.17.59.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 17:59:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-196109-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LYwyhbK3; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-196109-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-196109-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 966D71C229B8 for ; Fri, 31 May 2024 00:59:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B12BA15B3; Fri, 31 May 2024 00:59:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="LYwyhbK3" Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10C0A4C84 for ; Fri, 31 May 2024 00:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717117142; cv=none; b=hPaKsm0MWhChMva5jW9o8hgyQTrvI9bnbZ3uSPUDWatbdWroy8m8ht9dmG8T22W7odJmQl7DkOVgSKkZqaQSpa84KsuKEMffdJosEJ/4WSSdv8i84oSLJrYmfrqLsZ2yMAbPuxDvIMKlnsH2aWEc1AIVu4onmq82U9NQC1URNVg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717117142; c=relaxed/simple; bh=bG+7N/6ZBRzyPqoSKv4Si9VHH6RWf6RrJ2vJAjp+SIw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=M4Ez1oEXYNmlEPjibLgSWpGyPx4rUBL3UsZUrgUwJy7eQhmduEBREvWfF9tTMwK5QMpVJcVUpZGvYnE1ME0C0gcnjFF3NG3YdRzbXOzLmjNIHSY2uqbERzgE5AiVFOJ8nADFzr1me1mAxO9HES1ThCDVavlTHu1d6A7pzVsHuKE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=LYwyhbK3; arc=none smtp.client-ip=209.85.167.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lf1-f48.google.com with SMTP id 2adb3069b0e04-52b7e693b8aso1188244e87.1 for ; Thu, 30 May 2024 17:59:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717117139; x=1717721939; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=QnFCRKDrZ3vO/pkEAc8zl9OdD2pxO44AabYMP/pb1KM=; b=LYwyhbK3t8UrsGk/nheTSAJ3TWN+Fo8uaufQ66JBi4cdbZHqUpgMTXixrqOxstULvh Gb/QUDbZlKyDcnSa+fzerkNU1Ksf7w10TJw4ZNVn2iizFiVEX3thRB0kR5utUN33j9Q3 QX2OfgAgVbwxNUvRaWOlb0Ar6i8qviMKqFDIyGGnTXtHmk0QppRfTU84mKwGYFO4p3Km 5OnMl3YtCmAr9HlCz/5dpy4s8X24yWcn9ROh0accSf0bhCj4zi35j/Ens4sbgxKKszLU AB4xdp9YcfpzF1OTIBh7A854fw9GaaHhkta7y968jRygOuI70Jk7Ja/Xbm35mFjua1Zr bubA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717117139; x=1717721939; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QnFCRKDrZ3vO/pkEAc8zl9OdD2pxO44AabYMP/pb1KM=; b=r1/QWrpC2hWkH7UYj48MBtvWrFDNH585RpIzi5hQB5ZGQ3fu3qEN5mldSq4xq5ox9Z K+gKa/UXtxYFhtTeuq9EckhyaKfUt/ezYJFEL4G1s8c/QeOvv6iVx2+81Ue4byWiVXeT W0KmOMI9/G1RBpjuAWIbCWBKyAkEt6ZhskYUvXgBO0dvy8mzrF799ZDh1LkzK8gPcTuw XI/mcnz+Gnx3SqU/LwgWw8GM6xkhibh/MntggEEeeRSKsTUvc+XCSk99/99tHiwYTpuZ E+aqrRm9qR/vW2pS7DvP2QDi/2YEPas9TVG6M6nogM6s1b7DImLQPXMrhLk+cogTwhXr 9rXw== X-Forwarded-Encrypted: i=1; AJvYcCU2rv6x5IBqPQVcjGIFayGQPWULoMTf+k/5VE7kkB2QAWUXW/3QByPSCya0vYRo5CnalRjr6PI5R721XknwuuNxq1IouVwyn4ciPkLc X-Gm-Message-State: AOJu0YwYb7P5gGyEk+q5Sa9yTi8+OS9GkNAoE2wTrtZn9tSua+wVjovV MOhDGuXNtXM3QmZfCx5sROrgmR06hlagg9agejiOd8vUP1GwRAQqxncbXSTEvtE= X-Received: by 2002:ac2:46f4:0:b0:52b:8366:27c6 with SMTP id 2adb3069b0e04-52b88783f7amr136279e87.23.1717117139073; Thu, 30 May 2024 17:58:59 -0700 (PDT) Received: from eriador.lumag.spb.ru (dzdbxzyyyyyyyyyyyykxt-3.rev.dnainternet.fi. [2001:14ba:a0c3:3a00::227]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-52b84d3f835sm143476e87.115.2024.05.30.17.58.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 17:58:58 -0700 (PDT) Date: Fri, 31 May 2024 03:58:57 +0300 From: Dmitry Baryshkov To: Ilpo =?utf-8?B?SsOkcnZpbmVu?= Cc: Sebastian Reichel , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Bjorn Andersson , Hans de Goede , Bryan O'Donoghue , Heikki Krogerus , Greg Kroah-Hartman , Konrad Dybcio , linux-pm@vger.kernel.org, devicetree@vger.kernel.org, LKML , platform-driver-x86@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-msm@vger.kernel.org, Nikita Travkin Subject: Re: [PATCH v4 4/6] power: supply: lenovo_yoga_c630_battery: add Lenovo C630 driver Message-ID: References: <20240528-yoga-ec-driver-v4-0-4fa8dfaae7b6@linaro.org> <20240528-yoga-ec-driver-v4-4-4fa8dfaae7b6@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, May 29, 2024 at 06:41:36PM +0300, Ilpo J?rvinen wrote: > On Tue, 28 May 2024, Dmitry Baryshkov wrote: > > > On the Lenovo Yoga C630 WOS laptop the EC provides access to the adapter > > and battery status. Add the driver to read power supply status on the > > laptop. > > > > Signed-off-by: Dmitry Baryshkov > > --- > > drivers/power/supply/Kconfig | 9 + > > drivers/power/supply/Makefile | 1 + > > drivers/power/supply/lenovo_yoga_c630_battery.c | 479 ++++++++++++++++++++++++ > > 3 files changed, 489 insertions(+) > > > > + > > + val = yoga_c630_ec_read16(ec, LENOVO_EC_BAT_DESIGN_CAPACITY); > > + if (val < 0) > > + return val; > > + ecbat->design_capacity = val * 1000; > > Check linux/units.h if some WATT related one matches to that literal 1000. I'd rather not do that. The capacity might be either in microWatt-hours or in microAmp-hours. Using WATT will be confusing in the second case. > > + msleep(50); > > + > > + val = yoga_c630_ec_read16(ec, LENOVO_EC_BAT_VOLTAGE); > > + if (val < 0) > > + return val; > > + ecbat->voltage_now = val * 1000; > > Ditto. No, Volts and Amps don't have units in > > > + msleep(50); > > + > > + val = yoga_c630_ec_read16(ec, LENOVO_EC_BAT_CURRENT); > > + if (val < 0) > > + return val; > > + current_mA = sign_extend32(val, 15); > > + ecbat->current_now = current_mA * 1000; > > + ecbat->rate_now = current_mA * (ecbat->voltage_now / 1000); > > Ditto. The same > > > + msleep(50); > > + > > + if (!ecbat->unit_mA) > > + ecbat->capacity_now *= 10; > > + > > + ecbat->last_status_update = jiffies; -- With best wishes Dmitry