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 <[email protected]>
---
 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


Reply via email to