Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp932201lqh; Fri, 29 Mar 2024 01:19:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVIOs6TY0qLgOLqLQmvimC9EyJ8ONIi0M3pqvABPxyhTD29DEkVTrFXRtKiUTYpdc9FKbnDGJCdsYuVdH44HltZyo40HeoPktQmPcWKHg== X-Google-Smtp-Source: AGHT+IHxNtrqWfNn613S96EUHv4utvl4CN+7p80KZ992xDSJJcVuObXzwItTLlY3KZ5oFeAWUQZD X-Received: by 2002:a05:6a20:2d21:b0:1a3:bd8a:edd with SMTP id g33-20020a056a202d2100b001a3bd8a0eddmr2542191pzl.28.1711700375962; Fri, 29 Mar 2024 01:19:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711700375; cv=pass; d=google.com; s=arc-20160816; b=OexHy0Iu6+VseqUIZPGsZoY2KSXRZL0Jz44E3NWCqXDwcMLgu2h7QCWA5Gd3e3fE4Q 5+88CkXlEWoVgUlhhiO4vepp6T4rz/ISEHZeaMuLIqoaZvuMGFp7byJI556TuXaYhH4E oPL4isyreBrCz3Ss42IiMRwMh1cdrY8C3VroljCbRIjw7P7SStOH242i6NUnYTJBfy/8 zwdOeckAqN13bLYLYgmHdZB4p6r+Qej3GlJaeafwgWdwoRCFPqK5OABp6GBqodITjkpv hTyUMXK8yzMh0OTxXI6wHwXHkflhNDJ8nbF1gYewsHQghO96unh5JP6ziNY4z9uw8+nO qnug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:message-id:content-transfer-encoding:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:date :from:dkim-signature; bh=hmVi471qH5iwveHEu1t7ypJvSQnUmwqpTBhuOygO15I=; fh=sJAg1f29lJQ3/zuH9zCgAbvITfGvB8gDSNZFqXoIY0k=; b=fzfwBocEiBSL56NrQgavcgiuIQPn5y38hJ6zL3NHpEyR0Rzl8CCfzBSohmeJlBUe8F DrPUCQBurpMN0HFSOyz2uiLqjeW5IhT8tX/jJkbKgk1UdXzkQu7U9uqBe+U8WGPOvAWy o9a+8ALWf+ze2qUrI9ivHgx9AXiRiFMNJVcWf7+guNhQ7is6MUVzS69fO4S3DjFufMPF nLv8yvj2FQacKIJ4IKujgpqrIXkLK/8R5pDK2kd1Tpvnw2X5e1D2EMkDVOqIxGSM78ZS jgDgeAJmtC4728GPT1Me9wx51Xxi68FrerqIxHqcDTP+Smit/351iq6zkYqflTGTEOUx QsLw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=IsYIrUMT; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-124288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124288-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id q16-20020a638c50000000b005f059e5d689si3252815pgn.498.2024.03.29.01.19.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 01:19:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=IsYIrUMT; arc=pass (i=1 spf=pass spfdomain=weissschuh.net dkim=pass dkdomain=weissschuh.net); spf=pass (google.com: domain of linux-kernel+bounces-124288-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124288-linux.lists.archive=gmail.com@vger.kernel.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 49E6AB230C1 for ; Fri, 29 Mar 2024 08:18:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 504BC4AEC0; Fri, 29 Mar 2024 08:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="IsYIrUMT" Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37C5339AF2; Fri, 29 Mar 2024 08:18:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.69.126.157 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711700327; cv=none; b=hLtzqdFZAYXEsL17BGolQGx/M6ZZPJX2z3EqBxQEwWXCmARXSiaPbbe/XMqgGb8BQ22VJIctTXS/UsKs1tcU5Jdiyy3gGlcXuDjBiA4NtdS6pMQO6aC8hDSB/OcJWocEO2k/Y+UYwx4UfeSHh2WRv0pGDn+nGJJ2UWKaSkNa4TQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711700327; c=relaxed/simple; bh=ZfQyfX5CleZ4VR7K3+4MxiIAG8HW4iNUDvajqU/luM4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=dp/OR88Xqi4ocVy9ZpQUGns2Bc/OONrZ2oBg+e15b5iw2VbqeybFBuyCum7XtEbYNzD94PHGssuHjrPSPQbhugAbx/UFAodGzD7TVaI6VZ5Umvje1VO4ecauQAmVDUf0PCsWbfGwrSdAla7Djjn4rpjJXLaPmTCl2em45A5Dhlo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net; spf=pass smtp.mailfrom=weissschuh.net; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b=IsYIrUMT; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1711700312; bh=ZfQyfX5CleZ4VR7K3+4MxiIAG8HW4iNUDvajqU/luM4=; h=From:Date:Subject:To:Cc:From; b=IsYIrUMT6qvhdJP3Nqpx2Y1RQLmgsXvM5aDNvMplmnwg1Z+EN+Ee9OUMl9VdxkGCj EEI6+RpTvXqng1MU6tqHidAzFgi2dToJtmvKm2Pt+UIvd1iTAJrCw0pERRlYq6xrlB +9IHQ5yb2Mipza7zufX6g1/2JQI0LJBJUHbiQ1Kg= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Fri, 29 Mar 2024 09:18:29 +0100 Subject: [PATCH] power: supply: core: simplify charge_behaviour formatting 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="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240329-power-supply-simplify-v1-1-416f1002739f@weissschuh.net> X-B4-Tracking: v=1; b=H4sIAFR5BmYC/x3MSQqEQAxA0atI1gbK2IN6FXEhVqo74BAqOCHev YtevsX/FxhHYYMmuyDyJibLnFDkGQzffv4wik8GcvRwJdWoy84RbVUdTzSZdJRw4vNNVLkXc/A eUquRgxz/b9vd9w+m194eZwAAAA== To: Sebastian Reichel Cc: Sebastian Reichel , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Hans de Goede , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1711700312; l=2284; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=ZfQyfX5CleZ4VR7K3+4MxiIAG8HW4iNUDvajqU/luM4=; b=b0srRQ1bNaeTiPSKG7E15ppmTB1Ze+XWTTodFvwIzEbVkGs4E7euS+hhWsnqYJiBwBTXQVMu6 j6JJDJ4nQOWCUkxpx5GRc9d3c/B0zFXQVTD4YFl3ENB8KoABGcD1sxg X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The function power_supply_show_charge_behaviour() is not needed and can be removed completely. Removing the function also saves a spurious read of the property from the driver on each call. The convulted logic was a leftover from an earlier patch revision. Some restructuring made this cleanup possible. Suggested-by: Hans de Goede Link: https://lore.kernel.org/all/9e035ae4-cb07-4f84-8336-1a0050855bea@redhat.com/ Fixes: 4e61f1e9d58f ("power: supply: core: fix charge_behaviour formatting") Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply_sysfs.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 0d2c3724d0bc..b86e11bdc07e 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -271,23 +271,6 @@ static ssize_t power_supply_show_usb_type(struct device *dev, return count; } -static ssize_t power_supply_show_charge_behaviour(struct device *dev, - struct power_supply *psy, - union power_supply_propval *value, - char *buf) -{ - int ret; - - ret = power_supply_get_property(psy, - POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR, - value); - if (ret < 0) - return ret; - - return power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours, - value->intval, buf); -} - static ssize_t power_supply_show_property(struct device *dev, struct device_attribute *attr, char *buf) { @@ -321,7 +304,8 @@ static ssize_t power_supply_show_property(struct device *dev, &value, buf); break; case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR: - ret = power_supply_show_charge_behaviour(dev, psy, &value, buf); + ret = power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours, + value.intval, buf); break; case POWER_SUPPLY_PROP_MODEL_NAME ... POWER_SUPPLY_PROP_SERIAL_NUMBER: ret = sysfs_emit(buf, "%s\n", value.strval); --- base-commit: 070c1470ae24317e7b19bd3882b300b6d69922a4 change-id: 20240329-power-supply-simplify-5722806eefdd Best regards, -- Thomas Weißschuh