[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241202-sysfs-const-bin_attr-admin_wo-v1-4-f489116210bf@weissschuh.net>
Date: Mon, 02 Dec 2024 20:00:39 +0100
From: Thomas Weißschuh <linux@...ssschuh.net>
To: Heiko Carstens <hca@...ux.ibm.com>, Vasily Gorbik <gor@...ux.ibm.com>,
Alexander Gordeev <agordeev@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>,
Sven Schnelle <svens@...ux.ibm.com>, Michael Ellerman <mpe@...erman.id.au>,
Nicholas Piggin <npiggin@...il.com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Naveen N Rao <naveen@...nel.org>, Madhavan Srinivasan <maddy@...ux.ibm.com>,
Tzung-Bi Shih <tzungbi@...nel.org>, Brian Norris <briannorris@...omium.org>,
Julius Werner <jwerner@...omium.org>,
"James E.J. Bottomley" <James.Bottomley@...senPartnership.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>
Cc: linux-kernel@...r.kernel.org, linux-s390@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org, chrome-platform@...ts.linux.dev,
linux-scsi@...r.kernel.org,
Thomas Weißschuh <linux@...ssschuh.net>
Subject: [PATCH 4/5] firmware: google: gsmi: Use BIN_ATTR_ADMIN_WO() for
bin_attribute definition
Using the macro saves some lines of code and prepares the attribute for
the general constifications of struct bin_attributes.
While at it also constify the callback parameter.
Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
---
drivers/firmware/google/gsmi.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/drivers/firmware/google/gsmi.c b/drivers/firmware/google/gsmi.c
index 24e666d5c3d1a231d611ad3c20816c1d223a0dc5..cd946633ef727e826449a7b307a15a2c9f07d655 100644
--- a/drivers/firmware/google/gsmi.c
+++ b/drivers/firmware/google/gsmi.c
@@ -487,9 +487,9 @@ static const struct efivar_operations efivar_ops = {
#endif /* CONFIG_EFI */
-static ssize_t eventlog_write(struct file *filp, struct kobject *kobj,
- struct bin_attribute *bin_attr,
- char *buf, loff_t pos, size_t count)
+static ssize_t append_to_eventlog_write(struct file *filp, struct kobject *kobj,
+ const struct bin_attribute *bin_attr,
+ char *buf, loff_t pos, size_t count)
{
struct gsmi_set_eventlog_param param = {
.data_ptr = gsmi_dev.data_buf->address,
@@ -528,10 +528,7 @@ static ssize_t eventlog_write(struct file *filp, struct kobject *kobj,
}
-static struct bin_attribute eventlog_bin_attr = {
- .attr = {.name = "append_to_eventlog", .mode = 0200},
- .write = eventlog_write,
-};
+static const BIN_ATTR_ADMIN_WO(append_to_eventlog, 0);
static ssize_t gsmi_clear_eventlog_store(struct kobject *kobj,
struct kobj_attribute *attr,
@@ -1017,7 +1014,7 @@ static __init int gsmi_init(void)
}
/* Setup eventlog access */
- ret = sysfs_create_bin_file(gsmi_kobj, &eventlog_bin_attr);
+ ret = sysfs_create_bin_file(gsmi_kobj, &bin_attr_append_to_eventlog);
if (ret) {
printk(KERN_INFO "gsmi: Failed to setup eventlog");
goto out_err;
@@ -1049,7 +1046,7 @@ static __init int gsmi_init(void)
return 0;
out_remove_bin_file:
- sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr);
+ sysfs_remove_bin_file(gsmi_kobj, &bin_attr_append_to_eventlog);
out_err:
kobject_put(gsmi_kobj);
gsmi_buf_free(gsmi_dev.param_buf);
@@ -1076,7 +1073,7 @@ static void __exit gsmi_exit(void)
#endif
sysfs_remove_files(gsmi_kobj, gsmi_attrs);
- sysfs_remove_bin_file(gsmi_kobj, &eventlog_bin_attr);
+ sysfs_remove_bin_file(gsmi_kobj, &bin_attr_append_to_eventlog);
kobject_put(gsmi_kobj);
gsmi_buf_free(gsmi_dev.param_buf);
gsmi_buf_free(gsmi_dev.data_buf);
--
2.47.1
Powered by blists - more mailing lists