From patchwork Sun Jun 9 07:27:12 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: 803034 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 40F9B1B94F; Sun, 9 Jun 2024 07:27:18 +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=1717918041; cv=none; b=QlIVOkQfyIgA1Ci+ofgmiUdTLhCp1rKnz9x30RoVzeA0CUo6zQOSpV/xj4V5N6mdHzECm38WQvpzJ0DKxwvSUYR0+2cNixkYU/m+yRmIkrWEPP1/Yf+fmZPu96Zu+tntERLrJg8hf7Xt84OrFyI/OCXP0QY5ZErl+YRVmn+mKjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717918041; c=relaxed/simple; bh=YGPaK2ty3iBDd99SXk57m9Av56ArzbA+yUMUKB0P5Tw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lcHTzORsjCh+vZ9WfHoOiv5y9uqoiGtX6+auDJsQnDAiHQ2dCNnYXWvlkzGFGUB8JcIf9kZz0v5qScg3AVxASnKAN43eCISipPWv/ifRGk1t81x/GDMeek/DAOOaKK3sbBLDNNj7Z46ZXMQ6rjwQzYuej0+os/S9TuWw+f3FrSM= 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=qSvZ+Rjt; 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="qSvZ+Rjt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1717918035; bh=YGPaK2ty3iBDd99SXk57m9Av56ArzbA+yUMUKB0P5Tw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qSvZ+RjtSjMJgljIt8K1CmrtxZNjZnDsX385dI+fmnkMplux6Iof8ku4/j/OzHsD3 qHKrQMuPrb5UsN3MPpHdXwQ106glXsc/RQ7uv2NGAg0SMbji44cZRoYje5d3JblFGR NUvmKgk/e6qBMBRZ41bosK2mT0bMUaySUb4b/osA= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 09 Jun 2024 09:27:12 +0200 Subject: [PATCH 1/5] ACPI: AC: constify powersupply properties Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240609-acpi-battery-cleanup-v1-1-344517bdca73@weissschuh.net> References: <20240609-acpi-battery-cleanup-v1-0-344517bdca73@weissschuh.net> In-Reply-To: <20240609-acpi-battery-cleanup-v1-0-344517bdca73@weissschuh.net> To: "Rafael J. Wysocki" , Len Brown Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thom?= =?utf-8?q?as_Wei=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717918035; l=583; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=YGPaK2ty3iBDd99SXk57m9Av56ArzbA+yUMUKB0P5Tw=; b=vxRtPe6Mh2CMvsigAcdubidfoU9BAsg0tWsyUi2DHVlv8FqNavnLrRm3dP/Eo3jOngNusELVY gq/eIEw34g1APlHuOR4Or+1ociquwNvDU7moZ/uo4wmqdXBJNY6ifwU X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The array is never modified, make it const. Signed-off-by: Thomas Weißschuh --- drivers/acpi/ac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index 09a87fa222c7..eaa70b23dd0b 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c @@ -112,7 +112,7 @@ static int get_ac_property(struct power_supply *psy, return 0; } -static enum power_supply_property ac_props[] = { +static const enum power_supply_property ac_props[] = { POWER_SUPPLY_PROP_ONLINE, }; From patchwork Sun Jun 9 07:27:13 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: 802822 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 2300118C3D; Sun, 9 Jun 2024 07:27:17 +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=1717918041; cv=none; b=OE1aybK3b68RLPw6+sKmRmHUwGInIAC+ZrCbGO+NL5VLSaRZwcnDd7zOIdPP9pL2EHr2+dKnfRxmMoDeqn+Y62xsEKJEXuV+WzSDrVECWl4yLDs+QfFjgOmMUlN6wakTFkMRxhyIjCHchlGJNKsbIVmIMGtxqeNlsAoIk5o0BzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717918041; c=relaxed/simple; bh=9X9E0iPzjMX5HXPIZVXXhzNHMsBF2nq1d13kKi6GrZo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GLocO8qIsM0Ke1H85LZwOdGYCTXEuXRBUavt+UdYV2kbi4rZRPkwBJkc9Ssernbkc0MUHG7oALc55IhH1EA+Pwrzyi7RX5bm8pstEUj2t7ZoKq8OvQvPefWDmXl0rfp/nLA0S9AxT45QQlAslxMcrROX3iFqCiiBgvSK96CnPRA= 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=PwavMIqt; 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="PwavMIqt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1717918035; bh=9X9E0iPzjMX5HXPIZVXXhzNHMsBF2nq1d13kKi6GrZo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PwavMIqtPyB328UWGLX7Ga2bMGPkKqkD/DHR8DeYW1128Dzohc9JHLvw+2ErmBAZ5 LNPLzVq+d1qaI6HN3rCqIWKi//STYTKvPZDqOQwg5Ib/MxXrsvDbnUJ6R4niOdU2Ln 2igEvZGX2DhQnPc4a91784vjDSg5V5ySEdpPxvTw= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 09 Jun 2024 09:27:13 +0200 Subject: [PATCH 2/5] ACPI: SBS: constify powersupply properties Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240609-acpi-battery-cleanup-v1-2-344517bdca73@weissschuh.net> References: <20240609-acpi-battery-cleanup-v1-0-344517bdca73@weissschuh.net> In-Reply-To: <20240609-acpi-battery-cleanup-v1-0-344517bdca73@weissschuh.net> To: "Rafael J. Wysocki" , Len Brown Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thom?= =?utf-8?q?as_Wei=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717918035; l=1215; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=9X9E0iPzjMX5HXPIZVXXhzNHMsBF2nq1d13kKi6GrZo=; b=3EAwR4Ckbm989qU4jNHQMG4Ws6kMJaRPp23/innoYxEMDXJv2YffoDLEUFAvV5OiGZjlokp7U zVI+WwB+Rd2BZ8h4VxwXZXb5ontQ2KusUlp21aUNC7sw2EOj3by+3AR X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The arrays are never modified, make them const. Signed-off-by: Thomas Weißschuh --- drivers/acpi/sbs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c index dc8164b182dc..3d81ce3103c6 100644 --- a/drivers/acpi/sbs.c +++ b/drivers/acpi/sbs.c @@ -241,11 +241,11 @@ static int acpi_sbs_battery_get_property(struct power_supply *psy, return 0; } -static enum power_supply_property sbs_ac_props[] = { +static const enum power_supply_property sbs_ac_props[] = { POWER_SUPPLY_PROP_ONLINE, }; -static enum power_supply_property sbs_charge_battery_props[] = { +static const enum power_supply_property sbs_charge_battery_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, @@ -263,7 +263,7 @@ static enum power_supply_property sbs_charge_battery_props[] = { POWER_SUPPLY_PROP_MANUFACTURER, }; -static enum power_supply_property sbs_energy_battery_props[] = { +static const enum power_supply_property sbs_energy_battery_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, From patchwork Sun Jun 9 07:27:14 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: 803033 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 22FC217997; Sun, 9 Jun 2024 07:27:17 +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=1717918041; cv=none; b=k6/K20b7QML5MX2UB06osxKDwEzEUWTHfIsDnF46e6C9NtNFJMEarNIU3AZEimj0YLLsRi1N3TRfjL59K7UhpiQ2D/31KN3rXQh6OqBn9jcqAgCq5x2CaPnpVKBH/8iLg3+APOjKR5u74SxTxIHyU2qhsQl6/q1vAPQq4eDH6yQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717918041; c=relaxed/simple; bh=RJZgnCB5BUCDv22+RPw4ZAtNO1sIx6+p/3RbQvlhnWs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rO6oB9frkvmb1DXgPccXSFEwtZInjBxF9GOmROmlEhKPBRrV1PKzXr5EbixN8iL6o4h0eZCXPPPCr80sgM9EnwCigvOx26vtIrtrrjWAb6sUgRTI9VJX4qhy4MMzP/CAj//fXFBQl8LZ3KyU/Uoj8s8hr/Lu60GkuimxpfMeCLY= 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=LnlR9jpB; 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="LnlR9jpB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1717918035; bh=RJZgnCB5BUCDv22+RPw4ZAtNO1sIx6+p/3RbQvlhnWs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LnlR9jpBQkNjBNVbOqnzzg1QcyeODyClP98zajH9iop3yd4v81XjLVaffExACQWww fLvzIQvDchYk8p7PibGOJDpkSYX9i6ZTok119Po3VmU74MrydbaHcPDYdMvD9/t3iv FT41UFIR88PLrYJWI7PjuJXbP3GlIwxYrYGLo7Os= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 09 Jun 2024 09:27:14 +0200 Subject: [PATCH 3/5] ACPI: battery: constify powersupply properties Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240609-acpi-battery-cleanup-v1-3-344517bdca73@weissschuh.net> References: <20240609-acpi-battery-cleanup-v1-0-344517bdca73@weissschuh.net> In-Reply-To: <20240609-acpi-battery-cleanup-v1-0-344517bdca73@weissschuh.net> To: "Rafael J. Wysocki" , Len Brown Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thom?= =?utf-8?q?as_Wei=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717918035; l=1841; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=RJZgnCB5BUCDv22+RPw4ZAtNO1sIx6+p/3RbQvlhnWs=; b=P4wUdzdC2tWG0jbHRMuRKjRLTtMm1Ac9HwtTuXg+7G0CROrZy2CZ090nUUBru8n4VJR88RPh2 riqFeGR8a3ZBImDfQ+rueWzfmOa7Q928VXzv9iQfDJT22IKOVjAGTkr X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= The arrays are never modified, make them const. Signed-off-by: Thomas Weißschuh --- drivers/acpi/battery.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index b379401ff1c2..984236b95dff 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -308,7 +308,7 @@ static int acpi_battery_get_property(struct power_supply *psy, return ret; } -static enum power_supply_property charge_battery_props[] = { +static const enum power_supply_property charge_battery_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, @@ -326,7 +326,7 @@ static enum power_supply_property charge_battery_props[] = { POWER_SUPPLY_PROP_SERIAL_NUMBER, }; -static enum power_supply_property charge_battery_full_cap_broken_props[] = { +static const enum power_supply_property charge_battery_full_cap_broken_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, @@ -340,7 +340,7 @@ static enum power_supply_property charge_battery_full_cap_broken_props[] = { POWER_SUPPLY_PROP_SERIAL_NUMBER, }; -static enum power_supply_property energy_battery_props[] = { +static const enum power_supply_property energy_battery_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, @@ -358,7 +358,7 @@ static enum power_supply_property energy_battery_props[] = { POWER_SUPPLY_PROP_SERIAL_NUMBER, }; -static enum power_supply_property energy_battery_full_cap_broken_props[] = { +static const enum power_supply_property energy_battery_full_cap_broken_props[] = { POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_TECHNOLOGY, From patchwork Sun Jun 9 07:27: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: 803032 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 230591B28D; Sun, 9 Jun 2024 07:27:17 +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=1717918042; cv=none; b=DTNbFbp7knIqMLeWNtnyB9FMMIg+VJrgtiHWO8vzIHJgZLaUvEmn1eH3UOeOKaZm4ZAvK0qgNJnqHShhbW1EIfJREdafRBjCIG90Zo6E++9jbicp29CeJEDorlvhPgVWQlUf5CgoE/QrYuoJp0HOG3ELdTm/Qaz5tzmkLVa7Gso= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717918042; c=relaxed/simple; bh=n1WQcr0Jjs8K54pWJ570AATvW6C/bMm/V7v5t/VuBkM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EdxS4mcnLsVrjLEOsf/FVj6BkmhkbOpS1MUgj/sCw4xF+ca9jCySkHtvf6AbsqUxJc6xSZDQ/3Rwww2GQWuozKO7n/aSRTqiWCnTflvRGTlPwElzAjBCg+wBkyz5tyqGRc4oHXdyMvKumDlu0zqERM6OnwSyOqJRnf1dhvQddJg= 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=o2vTTYa/; 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="o2vTTYa/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1717918035; bh=n1WQcr0Jjs8K54pWJ570AATvW6C/bMm/V7v5t/VuBkM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=o2vTTYa/52GfwDIH50bo5k56LhILhUQZSaJcau3u0IwZMqnCNwzTQFQILPKMokNS0 tz0ZOWTYzz3V5w2t4Pv7yxOIoJFmQOpZLjflPgserUW3sGgA2vNXCPBqnvU9tvBrsL aMvH+HUlkuA85AgpD0IqSPjNBJ1OAB+cvUn7wY7o= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 09 Jun 2024 09:27:15 +0200 Subject: [PATCH 4/5] ACPI: battery: use sysfs_emit over sprintf Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240609-acpi-battery-cleanup-v1-4-344517bdca73@weissschuh.net> References: <20240609-acpi-battery-cleanup-v1-0-344517bdca73@weissschuh.net> In-Reply-To: <20240609-acpi-battery-cleanup-v1-0-344517bdca73@weissschuh.net> To: "Rafael J. Wysocki" , Len Brown Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thom?= =?utf-8?q?as_Wei=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717918035; l=770; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=n1WQcr0Jjs8K54pWJ570AATvW6C/bMm/V7v5t/VuBkM=; b=X2WU9aZZtK2pcr/wgLdCSvmY+kM+VWNyNxvaxbW1JmfNI+WIBFdfdTXNF6HALMSrEv2Oqft3J SGIrh7Z6uVKCoHHhTQPP92w45mr+gvZFXv2ewccYpeN04fbA0iyPHOh X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= sysfs_emit validates assumptions made by sysfs and is the correct mechanism to format data for sysfs. Signed-off-by: Thomas Weißschuh --- drivers/acpi/battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 984236b95dff..5f47bd58aff3 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -661,7 +661,7 @@ static ssize_t acpi_battery_alarm_show(struct device *dev, { struct acpi_battery *battery = to_acpi_battery(dev_get_drvdata(dev)); - return sprintf(buf, "%d\n", battery->alarm * 1000); + return sysfs_emit(buf, "%d\n", battery->alarm * 1000); } static ssize_t acpi_battery_alarm_store(struct device *dev, From patchwork Sun Jun 9 07:27: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: 802820 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 03E22219FD; Sun, 9 Jun 2024 07:27:22 +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=1717918044; cv=none; b=fqci4wl9CTXgFqz9pdryBH0V1KcQLG9YukJoVZYeWT2t5LU0C+5n9Fn6MdzDbNdJSaOQ8x3KbOPNQs9BjsLi+JmQh6Esz+zN28zL/78+vzP8hS7Y7jxcLNboKMSeL5xjYrqaH4+IGQim12ZGAZIL9T4CEhRZIUG5hDTYBLWwSZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717918044; c=relaxed/simple; bh=crKUY1rY4xCPn07shXAjd8yyC8WWLChy41PfeTmkTLE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oer0+En97CiFwCbw6NO0S+w4/ioMnXr3QJdyqZa0JEM1YvejVZrFg1NKRoRKbhgPbQfMYJwpLw9/ic6LHpJ223zuJEaE0d0v38sLLWB2Q5yOF+ftLtTCQ6TkYjsGcXL/mpk/h0MXvwDfnP774liUgEvc6mAoPvbhTQ3CDfWPgcM= 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=eIfy82LF; 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="eIfy82LF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1717918036; bh=crKUY1rY4xCPn07shXAjd8yyC8WWLChy41PfeTmkTLE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eIfy82LF79CnPxY5a4+4mXzbxRUaYo9O4Rolis+0ggjr4mKPMj9hYi/ie0bDyqIPF C4/O1836cwGCmWXnOKa4ZjFCUBRLHWczfjX5L1s3SxQDUNm0ayrpD3OUX3uUeNThz1 JoTEq98oM59wSoDzrK/O/Q6lUCc5mXVsu4ZAea8E= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Sun, 09 Jun 2024 09:27:16 +0200 Subject: [PATCH 5/5] ACPI: battery: create alarm sysfs attribute atomically Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240609-acpi-battery-cleanup-v1-5-344517bdca73@weissschuh.net> References: <20240609-acpi-battery-cleanup-v1-0-344517bdca73@weissschuh.net> In-Reply-To: <20240609-acpi-battery-cleanup-v1-0-344517bdca73@weissschuh.net> To: "Rafael J. Wysocki" , Len Brown Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Thom?= =?utf-8?q?as_Wei=C3=9Fschuh?= X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1717918035; l=2012; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=crKUY1rY4xCPn07shXAjd8yyC8WWLChy41PfeTmkTLE=; b=fdI38Y5I3pGAfU1AoOjow1ssMuRGbzcNtkhpOEGqmmuWM9N3FwfjdQW62IZuTY09byfjbm44f DQiAHhiP1s0BZYLt1BVHULXa8hByYQ1HePR7ctc9dZQq4ZmxmfTANYt X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Let the power supply core register the attribute. This ensures that the attribute is created before the device is announced to userspace, avoid a race condition. Signed-off-by: Thomas Weißschuh --- drivers/acpi/battery.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 5f47bd58aff3..d289b98a2cca 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -678,12 +678,18 @@ static ssize_t acpi_battery_alarm_store(struct device *dev, return count; } -static const struct device_attribute alarm_attr = { +static struct device_attribute alarm_attr = { .attr = {.name = "alarm", .mode = 0644}, .show = acpi_battery_alarm_show, .store = acpi_battery_alarm_store, }; +static struct attribute *acpi_battery_attrs[] = { + &alarm_attr.attr, + NULL +}; +ATTRIBUTE_GROUPS(acpi_battery); + /* * The Battery Hooking API * @@ -823,7 +829,10 @@ static void __exit battery_hook_exit(void) static int sysfs_add_battery(struct acpi_battery *battery) { - struct power_supply_config psy_cfg = { .drv_data = battery, }; + struct power_supply_config psy_cfg = { + .drv_data = battery, + .attr_grp = acpi_battery_groups, + }; bool full_cap_broken = false; if (!ACPI_BATTERY_CAPACITY_VALID(battery->full_charge_capacity) && @@ -868,7 +877,7 @@ static int sysfs_add_battery(struct acpi_battery *battery) return result; } battery_hook_add_battery(battery); - return device_create_file(&battery->bat->dev, &alarm_attr); + return 0; } static void sysfs_remove_battery(struct acpi_battery *battery) @@ -879,7 +888,6 @@ static void sysfs_remove_battery(struct acpi_battery *battery) return; } battery_hook_remove_battery(battery); - device_remove_file(&battery->bat->dev, &alarm_attr); power_supply_unregister(battery->bat); battery->bat = NULL; mutex_unlock(&battery->sysfs_lock);