From patchwork Sat Oct 5 10:06:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 833305 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 22D29143722; Sat, 5 Oct 2024 10:06:33 +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=1728122794; cv=none; b=qZUMCJfg13YkWR4aOoljZZHelPaFTRSsIF1HaVbIAFlX9LqbQ6vQZoGsLF6HRkoqec0Hqlk5BzQO//Kr+MZG7iO0KVuY71qaHioCL8VV0w817gctIwu7Sbj43h6G8kvi0vkivyobJSQJEB14xmr/qe0Eh1ZAhJZHE0hvRxVmc3Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728122794; c=relaxed/simple; bh=rQqJk4dyO0+vcBE042JZaU+PemfPpi5XskxKiPeoKH4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hDk8oDl5RL9kDse489kZsfOZ5pUW6iSrQ1DBDwEZcbx8BQ/S6HLwHPVIxacvCev0NqTPh0JBSuIfU6DkQDQbPvMKu8020J3+urG7Xyocrfux8iPqITCy2wENs1VhLnW0KvuaDXscYMuI9/F3jnY89sf3HjrPSKjP6Xl8jSiaMA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=M4A1qthn; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="M4A1qthn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1728122791; bh=rQqJk4dyO0+vcBE042JZaU+PemfPpi5XskxKiPeoKH4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=M4A1qthnEe6R9V3fRwtv2JJhQtNADyH48dz9ZIvvxI4pSPwuetlz5KF499o7QnG38 Qfsoe5K0kUKgiINh4kjUpjvxa0N9wNGT4q8/t3KAIZkPBJzk4VWMQvMTiceAExzjm5 GyM2UlD9LGsD7FHco1t7K7fo+5zNSi/ADOUH4iDs= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 05 Oct 2024 12:06:15 +0200 Subject: [PATCH 1/4] power: supply: core: use device mutex wrappers Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241005-power-supply-cleanups-v1-1-45303b2d0a4d@weissschuh.net> References: <20241005-power-supply-cleanups-v1-0-45303b2d0a4d@weissschuh.net> In-Reply-To: <20241005-power-supply-cleanups-v1-0-45303b2d0a4d@weissschuh.net> To: Sebastian Reichel Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas?= =?utf-8?q?_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728122791; l=1155; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=rQqJk4dyO0+vcBE042JZaU+PemfPpi5XskxKiPeoKH4=; b=ilW1nhcHjJI7VD50fAviaxeuVWC3BqFooOZLwGFtFGpvGpDnl27HbnGjbYE7w08ugPexIEipq yf5FGpVC/9pCkyBoMcgWcs/DVUnzr0+3OAnFnjqRkxVgySMUdMXB/Ah X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The mutex is an implementation detail of struct device. Use the dedicated wrappers to access the field. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 49534458a9f7d3f6d7c01bd91fa1bb6ed23bc7ad..c4608c60f7de2618941aae6e345a413ee249c0ae 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -152,7 +152,7 @@ static void power_supply_deferred_register_work(struct work_struct *work) deferred_register_work.work); if (psy->dev.parent) { - while (!mutex_trylock(&psy->dev.parent->mutex)) { + while (!device_trylock(psy->dev.parent)) { if (psy->removing) return; msleep(10); @@ -162,7 +162,7 @@ static void power_supply_deferred_register_work(struct work_struct *work) power_supply_changed(psy); if (psy->dev.parent) - mutex_unlock(&psy->dev.parent->mutex); + device_unlock(psy->dev.parent); } #ifdef CONFIG_OF From patchwork Sat Oct 5 10:06:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 833303 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 17BED13DDDD; Sat, 5 Oct 2024 10:06:33 +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=1728122795; cv=none; b=IWTxrwRwPCsAXbPayBn4JQEGPswWQvIHPrzJXYkBkMxEj+GceFNYlPlBmsH9aEwFIfdaPc/nPzyyCULFVP11hMwkxoSo19t2P0iEIy2RraB9e3WnjHSOJwiU7f1I8wAN+0KL9ao/5vZ+3INbO/c9MrHaMqbINpBnzZ0hL6YRXqM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728122795; c=relaxed/simple; bh=iaZA482jF5FfFGlgdv4MON26pqjatXtV2BsozZy2/eI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WAGG+NqJiZ/rE3ch4L2jmEkiI+mufuMUw8brh+8rrjRWGYIElox9r5jKbefZ2Zqg/ok3rXF2xI3Mppt9dZsk/vCxbeyVpvwaJSQZ5uBBLeE1Gz7CTS/OYT0Kv16OwIJcgaRYbEp5X1hrq6lWdZbLU2sKlWd/QlLIW7qj64QCOqU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=e0HwC/oc; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="e0HwC/oc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1728122791; bh=iaZA482jF5FfFGlgdv4MON26pqjatXtV2BsozZy2/eI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=e0HwC/oct/PbLG/CJCb5Ldue2PY9AH+BmBVqdFSuQjBSXgQOytKpqtL4JkwND7gLX oRRLmGK2ePcwKhxc5MTdAIZxFPOPMVLcrygl0gYNUgROpyQNHAzQJz7+ZDDQcpX14o Nv8O56gLzjaYqwA5JtvybYAd1wekVf/b139E4AVI= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 05 Oct 2024 12:06:16 +0200 Subject: [PATCH 2/4] power: supply: core: unexport power_supply_property_is_writeable() Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241005-power-supply-cleanups-v1-2-45303b2d0a4d@weissschuh.net> References: <20241005-power-supply-cleanups-v1-0-45303b2d0a4d@weissschuh.net> In-Reply-To: <20241005-power-supply-cleanups-v1-0-45303b2d0a4d@weissschuh.net> To: Sebastian Reichel Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas?= =?utf-8?q?_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728122791; l=2920; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=iaZA482jF5FfFGlgdv4MON26pqjatXtV2BsozZy2/eI=; b=gokUJLtPrG3OxCXLQQM2qYbnzx7BmEzF6IYQdyaiIB6VX7GClPy1ikwPL55WN6KM4smoW2deB iy84iJWZ+K+B/ukTEGH65uM+okHfok/dShgtqrbptWle8JWfBLi2xO5 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Since commit ("power: supply: Drop use_cnt check from power_supply_property_is_writeable()"), this function does not check use_cnt anymore, making it unsuitable for general usage. As it is only used by the psy core anyways, remove it from the public header and unexport it to avoid misusage. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply.h | 3 +++ drivers/power/supply/power_supply_core.c | 1 - drivers/power/supply/power_supply_hwmon.c | 1 + include/linux/power_supply.h | 2 -- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h index 3cbafc58bdad0b9766441fa22981e5cf15870c80..1bc57615ba68fb33e5b77f720e454dbba6daa291 100644 --- a/drivers/power/supply/power_supply.h +++ b/drivers/power/supply/power_supply.h @@ -13,6 +13,9 @@ struct device; struct device_type; struct power_supply; +extern int power_supply_property_is_writeable(struct power_supply *psy, + enum power_supply_property psp); + #ifdef CONFIG_SYSFS extern void power_supply_init_attrs(void); diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index c4608c60f7de2618941aae6e345a413ee249c0ae..3fea6c973d751ba97ab5e132895eaf39c3a79266 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -1233,7 +1233,6 @@ int power_supply_property_is_writeable(struct power_supply *psy, { return psy->desc->property_is_writeable && psy->desc->property_is_writeable(psy, psp); } -EXPORT_SYMBOL_GPL(power_supply_property_is_writeable); void power_supply_external_power_changed(struct power_supply *psy) { diff --git a/drivers/power/supply/power_supply_hwmon.c b/drivers/power/supply/power_supply_hwmon.c index 6fbbfb1c685e6c7fde41ea2fa88a557ed6dda2a1..01be04903d7d2465ae2acb9eeb0b55a87868bb87 100644 --- a/drivers/power/supply/power_supply_hwmon.c +++ b/drivers/power/supply/power_supply_hwmon.c @@ -7,6 +7,7 @@ #include #include #include +#include "power_supply.h" struct power_supply_hwmon { struct power_supply *psy; diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index 910d407ebe6323aaf4b31f0081f2cdd4be43a9fa..ea0ba149f296644bd18717d91f338172602eb6d6 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -863,8 +863,6 @@ static inline int power_supply_set_property(struct power_supply *psy, const union power_supply_propval *val) { return 0; } #endif -extern int power_supply_property_is_writeable(struct power_supply *psy, - enum power_supply_property psp); extern void power_supply_external_power_changed(struct power_supply *psy); extern struct power_supply *__must_check From patchwork Sat Oct 5 10:06:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 833168 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 3017D14C5AE; Sat, 5 Oct 2024 10:06:33 +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=1728122794; cv=none; b=awEWZifOAqx6rwuIY1Jqy+Hs18UhxxfcHKl5BEzhaFBW6yj6/nUUQS1u8osnu7pv8xHcwteWePd9cyO9I4pCQdY2AuKSbhFi1a2sz815r/f4c6eDWQFm8znKCh2Y/IlBTMvcb1ihXxTF89VL+VpUoAMkXCHx+ipxNusHgiesiNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728122794; c=relaxed/simple; bh=cVeJsyW6U2wZJ6iC3eZHoUXaNynzQYlamOESFTS23GI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E0v9woHx/B9ic8vWgxQJkg+eQudQkkJrMv7wbUGVQafqcoW9S3iM9pZqH8X1752sRR04sdoefRA2mgUjEnGnz/Jpesf5NfrwWWGDIjXzvMfWN8gV3DyknxRdE1cdze8e4B0oiidzdlpnunafngzBrYMY3kOVj2Y2/WnQjX1o4wc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=Rj7m4jmi; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="Rj7m4jmi" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1728122791; bh=cVeJsyW6U2wZJ6iC3eZHoUXaNynzQYlamOESFTS23GI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Rj7m4jmislF/SBdurxFNvhaTC+uSfBTDDziJi43AC446/0IAvsKZYr5p/yXpKcmfF I7P6FhkoWYzA5IrwTXbHQdtwHqVJYKC/iXXIwdilx6I/NPd/kkDUlLvoFHdnfPqfr1 JfAq7Vl26caRbj6DzLKJGBqTPk4WbfWxtmSM0L04= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 05 Oct 2024 12:06:17 +0200 Subject: [PATCH 3/4] power: supply: core: mark attribute arrays as ro_after_init Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241005-power-supply-cleanups-v1-3-45303b2d0a4d@weissschuh.net> References: <20241005-power-supply-cleanups-v1-0-45303b2d0a4d@weissschuh.net> In-Reply-To: <20241005-power-supply-cleanups-v1-0-45303b2d0a4d@weissschuh.net> To: Sebastian Reichel Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas?= =?utf-8?q?_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728122791; l=3387; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=cVeJsyW6U2wZJ6iC3eZHoUXaNynzQYlamOESFTS23GI=; b=24viEx2PtK/jahp7sIGwnohJclF/Xq5E2PE1rJsfaqUF7sSYUZbAkq7EjMUgNQbNixmGiH+GY TiQdpwIw8NhD1t5YVN2g3tsbtM33exykL3gr3mfBiuwlv+7PUNb7kt4 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The attribute arrays are only modified during the __init phase. To protect them against intentional or accidental modification, mark them as __ro_after_init. To make sure no modifications are introduced, also mark the return values of the accessors as const. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply.h | 2 +- drivers/power/supply/power_supply_sysfs.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h index 1bc57615ba68fb33e5b77f720e454dbba6daa291..4c558fb3db7211a610134960292790ea3584b363 100644 --- a/drivers/power/supply/power_supply.h +++ b/drivers/power/supply/power_supply.h @@ -18,7 +18,7 @@ extern int power_supply_property_is_writeable(struct power_supply *psy, #ifdef CONFIG_SYSFS -extern void power_supply_init_attrs(void); +extern void __init power_supply_init_attrs(void); extern int power_supply_uevent(const struct device *dev, struct kobj_uevent_env *env); extern const struct attribute_group *power_supply_attr_groups[]; diff --git a/drivers/power/supply/power_supply_sysfs.c b/drivers/power/supply/power_supply_sysfs.c index 16b3c5880cd8ce14cd7c697b11fcf5449b65c2d6..571de43fcca9827cf0fe3023e453defbf1eaec7d 100644 --- a/drivers/power/supply/power_supply_sysfs.c +++ b/drivers/power/supply/power_supply_sysfs.c @@ -142,7 +142,7 @@ static const char * const POWER_SUPPLY_CHARGE_BEHAVIOUR_TEXT[] = { [POWER_SUPPLY_CHARGE_BEHAVIOUR_FORCE_DISCHARGE] = "force-discharge", }; -static struct power_supply_attr power_supply_attrs[] = { +static struct power_supply_attr power_supply_attrs[] __ro_after_init = { /* Properties of type `int' */ POWER_SUPPLY_ENUM_ATTR(STATUS), POWER_SUPPLY_ENUM_ATTR(CHARGE_TYPE), @@ -225,9 +225,9 @@ static struct power_supply_attr power_supply_attrs[] = { #define POWER_SUPPLY_ATTR_CNT ARRAY_SIZE(power_supply_attrs) static struct attribute * -__power_supply_attrs[POWER_SUPPLY_ATTR_CNT + 1]; +__power_supply_attrs[POWER_SUPPLY_ATTR_CNT + 1] __ro_after_init; -static struct power_supply_attr *to_ps_attr(struct device_attribute *attr) +static const struct power_supply_attr *to_ps_attr(struct device_attribute *attr) { return container_of(attr, struct power_supply_attr, dev_attr); } @@ -273,7 +273,7 @@ static ssize_t power_supply_show_property(struct device *dev, char *buf) { ssize_t ret; struct power_supply *psy = dev_get_drvdata(dev); - struct power_supply_attr *ps_attr = to_ps_attr(attr); + const struct power_supply_attr *ps_attr = to_ps_attr(attr); enum power_supply_property psp = dev_attr_psp(attr); union power_supply_propval value; @@ -326,7 +326,7 @@ static ssize_t power_supply_store_property(struct device *dev, const char *buf, size_t count) { ssize_t ret; struct power_supply *psy = dev_get_drvdata(dev); - struct power_supply_attr *ps_attr = to_ps_attr(attr); + const struct power_supply_attr *ps_attr = to_ps_attr(attr); enum power_supply_property psp = dev_attr_psp(attr); union power_supply_propval value; @@ -401,7 +401,7 @@ const struct attribute_group *power_supply_attr_groups[] = { NULL }; -void power_supply_init_attrs(void) +void __init power_supply_init_attrs(void) { int i; From patchwork Sat Oct 5 10:06:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 833167 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 5F12A136349; Sat, 5 Oct 2024 10:06:33 +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=1728122794; cv=none; b=HmevpeV1wbwnNQpUM7iwmwUsEtWgjZbwFpwGCyZ2c0/4MGnSnn1/GsbYkxFHKukBxrEFLIpxNvpAJSzWhThz7p0FfPMcYlbyXIgzEO+naxOQrGVRVxjg6c2UGF0WAh4WkjlmzVn/IlDeel19nZEG/GIRMZ8wVWzal1eE8ZswLkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728122794; c=relaxed/simple; bh=bp8YF7paCLm/RvDn/3zn9PMgwl2X0VG26YtAWU1mujA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RABPJ3031J2X/4y5f5hglXdj6oR/xK309CsV3FYHGYzFcwB1qDLFzeD2PGo7bzYuc62G7U8Kx/RctrMr+5qO+1BWbVh4X7BT2rGpC8jCh9Y2CXdC+PdaD2nblgjjmAD1ETbEt7/+V9JPfXJWnNyRNvxhk5ME+aFp8Qdn+WAGK6M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine 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=hlwLF6jW; arc=none smtp.client-ip=159.69.126.157 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=weissschuh.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=weissschuh.net header.i=@weissschuh.net header.b="hlwLF6jW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1728122791; bh=bp8YF7paCLm/RvDn/3zn9PMgwl2X0VG26YtAWU1mujA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hlwLF6jWQlw4oV3ojO3Xn8/kjOpAucA3XhZ1dpgkV2Wu9c0EJ/QDyAcghHeliHVFo 81zgu2JFqh11fKzAfDLozLQ6lKbWib5YHcYhNlAAIDmy6IVUnCEMwUaCB/vrMyY7pK fLOl6zjbI5FgOdKo16ccoJgvjD4md8JQZZ07qzgo= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sat, 05 Oct 2024 12:06:18 +0200 Subject: [PATCH 4/4] power: supply: hwmon: move interface to private header Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241005-power-supply-cleanups-v1-4-45303b2d0a4d@weissschuh.net> References: <20241005-power-supply-cleanups-v1-0-45303b2d0a4d@weissschuh.net> In-Reply-To: <20241005-power-supply-cleanups-v1-0-45303b2d0a4d@weissschuh.net> To: Sebastian Reichel Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thomas?= =?utf-8?q?_Wei=C3=9Fschuh?= X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1728122791; l=2714; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=bp8YF7paCLm/RvDn/3zn9PMgwl2X0VG26YtAWU1mujA=; b=48AkzMo+dKj7vs/k8ZubFmHBHA1FfhdCzmZr2McYD7vhswHU07iIm+E/rCjGtK3+hoz39uH/J PltiCQNeQB0DX0IPG6cljtsPNP5QaiN3uu8QVxZirsYJKBYNcTXEjOw X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The interface of power_supply_hwmon.c is only meant to be used by the psy core. Remove it from the public header file and use the private one instead. Signed-off-by: Thomas Weißschuh --- drivers/power/supply/power_supply.h | 17 +++++++++++++++++ drivers/power/supply/power_supply_hwmon.c | 2 ++ include/linux/power_supply.h | 13 ------------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/drivers/power/supply/power_supply.h b/drivers/power/supply/power_supply.h index 4c558fb3db7211a610134960292790ea3584b363..7434a6f2477504ee6c0a3c7420e1444387b41180 100644 --- a/drivers/power/supply/power_supply.h +++ b/drivers/power/supply/power_supply.h @@ -44,3 +44,20 @@ static inline int power_supply_create_triggers(struct power_supply *psy) static inline void power_supply_remove_triggers(struct power_supply *psy) {} #endif /* CONFIG_LEDS_TRIGGERS */ + +#ifdef CONFIG_POWER_SUPPLY_HWMON + +int power_supply_add_hwmon_sysfs(struct power_supply *psy); +void power_supply_remove_hwmon_sysfs(struct power_supply *psy); + +#else + +static inline int power_supply_add_hwmon_sysfs(struct power_supply *psy) +{ + return 0; +} + +static inline +void power_supply_remove_hwmon_sysfs(struct power_supply *psy) {} + +#endif /* CONFIG_POWER_SUPPLY_HWMON */ diff --git a/drivers/power/supply/power_supply_hwmon.c b/drivers/power/supply/power_supply_hwmon.c index 01be04903d7d2465ae2acb9eeb0b55a87868bb87..9b30175ba9aefb0ebc0fbe73fdd158fcefc3bdda 100644 --- a/drivers/power/supply/power_supply_hwmon.c +++ b/drivers/power/supply/power_supply_hwmon.c @@ -9,6 +9,8 @@ #include #include "power_supply.h" +#include "power_supply.h" + struct power_supply_hwmon { struct power_supply *psy; unsigned long *props; diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h index ea0ba149f296644bd18717d91f338172602eb6d6..58264343fb8a1590d02ec18a2d7fe9d874e3bc31 100644 --- a/include/linux/power_supply.h +++ b/include/linux/power_supply.h @@ -943,19 +943,6 @@ static inline bool power_supply_is_watt_property(enum power_supply_property psp) return false; } -#ifdef CONFIG_POWER_SUPPLY_HWMON -int power_supply_add_hwmon_sysfs(struct power_supply *psy); -void power_supply_remove_hwmon_sysfs(struct power_supply *psy); -#else -static inline int power_supply_add_hwmon_sysfs(struct power_supply *psy) -{ - return 0; -} - -static inline -void power_supply_remove_hwmon_sysfs(struct power_supply *psy) {} -#endif - #ifdef CONFIG_SYSFS ssize_t power_supply_charge_behaviour_show(struct device *dev, unsigned int available_behaviours,