From patchwork Wed Oct 23 18:47:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 13847813 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (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 C6E111D151F for ; Wed, 23 Oct 2024 18:50:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729709428; cv=none; b=alYhHLCYT/mamtnHnqm48SI6bQK/hSp762WNOq8ThSt3EYygAEmRIw+S8RcaX2timgSrmMRnMeu3JC1C42McKu/z1CHWJiCKLyeDAVC4Q5cAY0HAcv/3OIpN54qn1BuYRFBEfR5lyDH6RXFu7qDV3jFpbT38MKcsX+JaI01fnX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729709428; c=relaxed/simple; bh=7DS0X8qhKfEVkLOZopAxlKaoXqfTFKueIGVKh5O9W8s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kt9sba6T4wR8x8YzdzvqIfIKl1UJ/ExGQ94HjGEaI46zupJJOr+19MFDJhWgVHeKrxUE3TtrDXV8r7FpA9xPa+vh6Z4MhomLIJqMA1BNXlFfgbPPffCiShThxwnJthz3zUAsxHOGwbeoOdXwEcabGSd0xwV42CJrzRDK3IsiPYw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=C1NZDiPx; arc=none smtp.client-ip=209.85.161.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C1NZDiPx" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5eba450531eso592069eaf.1 for ; Wed, 23 Oct 2024 11:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729709426; x=1730314226; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FXKoPeDo82nTMxnt2Psg/dVsFWr0w1bBH/4wN9F5E34=; b=C1NZDiPxzn9omo9SuqKax8rRz9Nvj0v4Lb7LAn97KOFHHQuMN6RYAx9PYIobmpni6I s5fi7RmSCBhwMnDkAvXZAmYBGrwSjUn8GtgXXlYVMWUFyybbOaL0z6wcQuT2RdGBd1nP vDBozarGvnt0pAUZwYWyYuwpucJYI77/vBmYC207u8F+jx1G1fNy3k8rMGx/pv+et6N+ 8wtOUvDHbJNooXGgd05ZWTe3jbQ5eNalUThcM9h9Zgqq/TgzURngc1+f1Clw95jxEajv 9R1KtvSgl1rjsfEjYIEVLbhp6Gc7HZD6hcOxWyn8FviEiUfnDYobfqhZYbTqlsNlJ2x/ TCnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729709426; x=1730314226; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FXKoPeDo82nTMxnt2Psg/dVsFWr0w1bBH/4wN9F5E34=; b=LQSUzW+9dfVqpNahhJOa7tstUfqqo1Z0D3bstCGF2iKC8dcUzruC96pkZy4PDAfjSO VGEMi5iY7Fae1UNTyHwO/5afvvivHjMY1VdZcFkhaD7/1nDplk6WpnoedvmXNTeUVwwD GuSuGY95FUbkzvULHQYzIc6zTs7RdZWUdGKkCjv1rabzCnO0yghvoYEqEnzYHrv8s/Nq NzSDtsYLemlGDn8faBM0RnkEjKPFkdCfxYpimpMi5tzeEXj1tlyJppXwaH7Vm4K0m7AC RbZUMYELghAgaH5By4Z6kc7mV2mvMRmOWJRhbA9yK8603I7AKzFpD6Rmuw2m+oND2HiA KvWg== X-Gm-Message-State: AOJu0YyLcaIDXxPJQLM4f6RlKCvplRzif3QWFoGshHh4/Sogz7eGPZcM s1ViB9+dBO4yStLlQmpPEKYtJGdcSQnMA6iMo/u1GS5A9dM75Bdx6/E2Aw== X-Google-Smtp-Source: AGHT+IGsqYR4ANWg0g/9koDTocvLpJ4TpBEQuXdoucjL2xRopJh1jCyrklVN4cgX/bb4tyXdInXFRA== X-Received: by 2002:a05:6870:1704:b0:27c:4853:2b68 with SMTP id 586e51a60fabf-28ccc20b380mr1992640fac.20.1729709425555; Wed, 23 Oct 2024 11:50:25 -0700 (PDT) Received: from localhost.localdomain ([2600:1700:fb0:1bcf::54]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7182eb52609sm1860667a34.40.2024.10.23.11.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 11:50:25 -0700 (PDT) From: Chris Morgan To: linux-pm@vger.kernel.org Cc: wens@csie.org, sre@kernel.org, Chris Morgan Subject: [PATCH 1/2] power: supply: axp20x_usb_power: Use scaled iio_read_channel Date: Wed, 23 Oct 2024 13:47:59 -0500 Message-ID: <20241023184800.109376-2-macroalpha82@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241023184800.109376-1-macroalpha82@gmail.com> References: <20241023184800.109376-1-macroalpha82@gmail.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chris Morgan Change iio_read_channel_processed to iio_read_channel_processed_scale where appropriate. Signed-off-by: Chris Morgan --- drivers/power/supply/axp20x_usb_power.c | 33 +++++++++++-------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/power/supply/axp20x_usb_power.c b/drivers/power/supply/axp20x_usb_power.c index 2766352ab737..9722912268fe 100644 --- a/drivers/power/supply/axp20x_usb_power.c +++ b/drivers/power/supply/axp20x_usb_power.c @@ -220,16 +220,15 @@ static int axp20x_usb_power_get_property(struct power_supply *psy, return 0; case POWER_SUPPLY_PROP_VOLTAGE_NOW: if (IS_ENABLED(CONFIG_AXP20X_ADC)) { - ret = iio_read_channel_processed(power->vbus_v, - &val->intval); - if (ret) - return ret; - /* * IIO framework gives mV but Power Supply framework * gives uV. */ - val->intval *= 1000; + ret = iio_read_channel_processed_scale(power->vbus_v, + &val->intval, 1000); + if (ret) + return ret; + return 0; } @@ -253,16 +252,15 @@ static int axp20x_usb_power_get_property(struct power_supply *psy, return 0; case POWER_SUPPLY_PROP_CURRENT_NOW: if (IS_ENABLED(CONFIG_AXP20X_ADC)) { - ret = iio_read_channel_processed(power->vbus_i, - &val->intval); - if (ret) - return ret; - /* * IIO framework gives mA but Power Supply framework * gives uA. */ - val->intval *= 1000; + ret = iio_read_channel_processed_scale(power->vbus_i, + &val->intval, 1000); + if (ret) + return ret; + return 0; } @@ -374,16 +372,15 @@ static int axp717_usb_power_get_property(struct power_supply *psy, break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: if (IS_ENABLED(CONFIG_AXP20X_ADC)) { - ret = iio_read_channel_processed(power->vbus_v, - &val->intval); - if (ret) - return ret; - /* * IIO framework gives mV but Power Supply framework * gives uV. */ - val->intval *= 1000; + ret = iio_read_channel_processed_scale(power->vbus_v, + &val->intval, 1000); + if (ret) + return ret; + return 0; } From patchwork Wed Oct 23 18:48:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Morgan X-Patchwork-Id: 13847814 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (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 46BFB1D1E62 for ; Wed, 23 Oct 2024 18:50:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729709428; cv=none; b=jyLy6f/ixQlk0Dy88StobpEIm94uXiezHvfjwz4xDlq7/2AEC32ImWs35UvGcGCHFB6ZWJNwVEZRWg9nKHM6EOW7IuDg3HRBjqmDNCqFsUlUP947qPcFjmfE7HPrgi305sGT36o7ZIVCmzXc3kVVXhMqpOTqNBg61rHWduq1AP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729709428; c=relaxed/simple; bh=i1opjJ5noztG7W4quqfSUG+1/LQxGlVrZchANNNBAU4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RSHdyTTLWS+eaBkuFy7NmG8ck4++muBPTmwGEtXOEBEvZ0jGdjQQJSsbWL4i0AkG5LSEnxQDE8z/yP+dTxdNmUq4JszwFyngY1CPKfs4CAAtl2If0SNJN8YzIXl9BiRAdCWof9aF7XWgYZGy7MNMB4tPAnKN2vXS0isOK+EoQXw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JM4CDIAt; arc=none smtp.client-ip=209.85.210.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JM4CDIAt" Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-7180dc76075so73814a34.3 for ; Wed, 23 Oct 2024 11:50:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729709426; x=1730314226; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PzWEx+54nXqRyexqxBK02Ff4DIq6Md1prk1WFWanhYk=; b=JM4CDIAtEBrdB0V6LnOcAPN1u1Ny7xTJxfmIp6blqQIJ+1sUpqAIuMQ2VSMK3Is34W t9opcjP//1AiaQh1LsWHc8Ca+NCCNW7mhUVSrztFXdo4fwrKhWsLWdfpNYnBTrp5EVUK bajUAt+Oa7PQ2u4aK0bVoVJ68wDJuUOGvfIIibRG3tBpjfxQatTcwjwBqnchVTQJ0yev xPNj+pKV4jffOIj8bBDPftcrJQjamtNqq8h6bzBYCaOW58J4GrC8iirEK0FQRTORYwZK S7ECGdQJcKiZR6beYwJvu94yKyttw+dOWJd0IBdGwMUXXdfVUSaRYpkRw/tw6FviAyMa E5tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729709426; x=1730314226; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PzWEx+54nXqRyexqxBK02Ff4DIq6Md1prk1WFWanhYk=; b=PE+7g/IbVKUEkfADcVITfcjxaS55G+JUb6u9haZX61z+0OVUIXC52HKU64iUhU62tG KPVFWONuIK8koxpCqjjestHJI9IUF8a4OmISyFYlw4lbYOejYvXmhJVcLwzRRiY3Rcko VwK/ORBSeFwbEX5rIzknJufdy46Vr0NMumqYNuEWkL035MWgjG+iIWIXzv9Jar9xJtaD G2lEkIv2+yQzVaN/0ZuqzOKNqn2N/NV8IufhLxE2/uwrhjUKROVDxt0Ftswc9rk+XEvP ulTEb7Rqf0RaE0InhApPCT4rvPQWsHgRCSIb0MZXUfJYAo3DRsesrBmwc0/oCc0GCRCf GiZg== X-Gm-Message-State: AOJu0YyvS2yoFtdRmzlyg8IZgrC7o/GX9XLbx6/lfhT2Yzxy7qTjlo48 psJotBr35izEpHKYZgVXhYYhwiVLshsQQRTkFGIWWsoJ3sarxEf/8UY43w== X-Google-Smtp-Source: AGHT+IHWRTElqaKFG/p97TiMXmH37N7VT0S2iCKBdvdFt11k14I2JQfm9J4D2BPKNoxV/zwXOWG3+Q== X-Received: by 2002:a05:6830:2691:b0:718:194d:8ab with SMTP id 46e09a7af769-7184b331716mr4380810a34.27.1729709426143; Wed, 23 Oct 2024 11:50:26 -0700 (PDT) Received: from localhost.localdomain ([2600:1700:fb0:1bcf::54]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7182eb52609sm1860667a34.40.2024.10.23.11.50.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2024 11:50:25 -0700 (PDT) From: Chris Morgan To: linux-pm@vger.kernel.org Cc: wens@csie.org, sre@kernel.org, Chris Morgan Subject: [PATCH 2/2] power: supply: axp20x_battery: Use scaled iio_read_channel Date: Wed, 23 Oct 2024 13:48:00 -0500 Message-ID: <20241023184800.109376-3-macroalpha82@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241023184800.109376-1-macroalpha82@gmail.com> References: <20241023184800.109376-1-macroalpha82@gmail.com> Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Chris Morgan Change iio_read_channel_processed to iio_read_channel_processed_scale where appropriate. Signed-off-by: Chris Morgan --- drivers/power/supply/axp20x_battery.c | 33 ++++++++++++++------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/drivers/power/supply/axp20x_battery.c b/drivers/power/supply/axp20x_battery.c index f71cc90fea12..fa27195f074e 100644 --- a/drivers/power/supply/axp20x_battery.c +++ b/drivers/power/supply/axp20x_battery.c @@ -354,17 +354,18 @@ static int axp20x_battery_get_prop(struct power_supply *psy, if (ret) return ret; + /* IIO framework gives mA but Power Supply framework gives uA */ if (reg & AXP20X_PWR_STATUS_BAT_CHARGING) { - ret = iio_read_channel_processed(axp20x_batt->batt_chrg_i, &val->intval); + ret = iio_read_channel_processed_scale(axp20x_batt->batt_chrg_i, + &val->intval, 1000); } else { - ret = iio_read_channel_processed(axp20x_batt->batt_dischrg_i, &val1); + ret = iio_read_channel_processed_scale(axp20x_batt->batt_dischrg_i, + &val1, 1000); val->intval = -val1; } if (ret) return ret; - /* IIO framework gives mA but Power Supply framework gives uA */ - val->intval *= 1000; break; case POWER_SUPPLY_PROP_CAPACITY: @@ -406,13 +407,12 @@ static int axp20x_battery_get_prop(struct power_supply *psy, break; case POWER_SUPPLY_PROP_VOLTAGE_NOW: - ret = iio_read_channel_processed(axp20x_batt->batt_v, - &val->intval); + /* IIO framework gives mV but Power Supply framework gives uV */ + ret = iio_read_channel_processed_scale(axp20x_batt->batt_v, + &val->intval, 1000); if (ret) return ret; - /* IIO framework gives mV but Power Supply framework gives uV */ - val->intval *= 1000; break; default: @@ -519,13 +519,15 @@ static int axp717_battery_get_prop(struct power_supply *psy, * The offset of this value is currently unknown and is * not documented in the datasheet. Based on * observation it's assumed to be somewhere around - * 450ma. I will leave the value raw for now. + * 450ma. I will leave the value raw for now. Note that + * IIO framework gives mA but Power Supply framework + * gives uA. */ - ret = iio_read_channel_processed(axp20x_batt->batt_chrg_i, &val->intval); + ret = iio_read_channel_processed_scale(axp20x_batt->batt_chrg_i, + &val->intval, 1000); if (ret) return ret; - /* IIO framework gives mA but Power Supply framework gives uA */ - val->intval *= 1000; + return 0; case POWER_SUPPLY_PROP_CAPACITY: @@ -564,13 +566,12 @@ static int axp717_battery_get_prop(struct power_supply *psy, return 0; case POWER_SUPPLY_PROP_VOLTAGE_NOW: - ret = iio_read_channel_processed(axp20x_batt->batt_v, - &val->intval); + /* IIO framework gives mV but Power Supply framework gives uV */ + ret = iio_read_channel_processed_scale(axp20x_batt->batt_v, + &val->intval, 1000); if (ret) return ret; - /* IIO framework gives mV but Power Supply framework gives uV */ - val->intval *= 1000; return 0; case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: