From: Denis Benato <denis.benato@linux.dev>
To: platform-driver-x86@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Hans de Goede" <hansg@kernel.org>,
"Corentin Chary" <corentin.chary@gmail.com>,
"Luke Jones" <luke@ljones.dev>, busybox11 <busybox11th@gmail.com>,
"Denis Benato" <benato.denis96@gmail.com>,
"Denis Benato" <denis.benato@linux.dev>
Subject: [PATCH v3 4/4] platform/x86: asus-armoury: use sysfs_create_groups() and sysfs_remove_groups()
Date: Fri, 25 Sep 2026 14:42:28 +0000 [thread overview]
Message-ID: <20260925144229.3693-5-denis.benato@linux.dev> (raw)
In-Reply-To: <20260925144229.3693-1-denis.benato@linux.dev>
NULL-terminate the attribute group list and let sysfs_create_groups()
create it so that sysfs_remove_groups() can be used to rollback in case
of errors and on module removal.
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Denis Benato <denis.benato@linux.dev>
---
drivers/platform/x86/asus-armoury.c | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/drivers/platform/x86/asus-armoury.c b/drivers/platform/x86/asus-armoury.c
index 7c54f616d701..5d74a2322f4b 100644
--- a/drivers/platform/x86/asus-armoury.c
+++ b/drivers/platform/x86/asus-armoury.c
@@ -909,11 +909,12 @@ static const struct attribute_group *armoury_attr_groups[] = {
&panel_od_attr_group,
&panel_hd_mode_attr_group,
&screen_auto_brightness_attr_group,
+ NULL
};
static int asus_fw_attr_add(void)
{
- int err, i;
+ int err;
asus_armoury.fw_attr_dev = device_create(&firmware_attributes_class, NULL, MKDEV(0, 0),
NULL, "%s", DRIVER_NAME);
@@ -953,22 +954,16 @@ static int asus_fw_attr_add(void)
else if (armoury_has_devstate(ASUS_WMI_DEVID_GPU_MODE))
asus_armoury.dgpu_disable_dev_id = ASUS_WMI_DEVID_GPU_MODE;
- for (i = 0; i < ARRAY_SIZE(armoury_attr_groups); i++) {
- err = sysfs_create_group(&asus_armoury.fw_attr_kset->kobj,
- armoury_attr_groups[i]);
- if (err) {
- pr_err("Failed to create sysfs-group for %s\n",
- armoury_attr_groups[i]->name);
- goto err_remove_groups;
- }
+ err = sysfs_create_groups(&asus_armoury.fw_attr_kset->kobj,
+ armoury_attr_groups);
+ if (err) {
+ pr_err("Failed to create firmware attributes groups\n");
+ goto err_remove_file;
}
return 0;
-err_remove_groups:
- while (i--)
- sysfs_remove_group(&asus_armoury.fw_attr_kset->kobj,
- armoury_attr_groups[i]);
+err_remove_file:
sysfs_remove_file(&asus_armoury.fw_attr_kset->kobj, &pending_reboot.attr);
err_destroy_kset:
kset_unregister(asus_armoury.fw_attr_kset);
@@ -1138,11 +1133,8 @@ static int __init asus_fw_init(void)
static void __exit asus_fw_exit(void)
{
- int i;
-
- for (i = ARRAY_SIZE(armoury_attr_groups) - 1; i >= 0; i--)
- sysfs_remove_group(&asus_armoury.fw_attr_kset->kobj,
- armoury_attr_groups[i]);
+ sysfs_remove_groups(&asus_armoury.fw_attr_kset->kobj,
+ armoury_attr_groups);
sysfs_remove_file(&asus_armoury.fw_attr_kset->kobj, &pending_reboot.attr);
kset_unregister(asus_armoury.fw_attr_kset);
--
2.47.3
prev parent reply other threads:[~2026-09-25 14:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 14:42 [PATCH v3 0/4] platform/x86: asus-armoury: reorganize visibility and extend dgpu_disable Denis Benato
2026-09-25 14:42 ` [PATCH v3 1/4] platform/x86: asus-armoury: move has_valid_limit() above the attribute declarations Denis Benato
2026-09-25 14:42 ` [PATCH v3 2/4] platform/x86: asus-armoury: let attribute groups decide their own visibility Denis Benato
2026-09-25 14:42 ` [PATCH v3 3/4] platform/x86: asus-armoury: add dGPU disable fallback DEVID for ProArt H7606 series Denis Benato
2026-09-25 14:42 ` Denis Benato [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260925144229.3693-5-denis.benato@linux.dev \
--to=denis.benato@linux.dev \
--cc=benato.denis96@gmail.com \
--cc=busybox11th@gmail.com \
--cc=corentin.chary@gmail.com \
--cc=hansg@kernel.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luke@ljones.dev \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®