diff mbox series

[2/5] s390/sclp_config: use BIN_ATTR_ADMIN_WO() for bin_attribute definition

Message ID 20241202-sysfs-const-bin_attr-admin_wo-v1-2-f489116210bf@weissschuh.net (mailing list archive)
State New
Headers show
Series sysfs: introduce and use macro BIN_ATTR_ADMIN_WO() | expand

Commit Message

Thomas Weißschuh Dec. 2, 2024, 7 p.m. UTC
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@weissschuh.net>
---
 drivers/s390/char/sclp_config.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

Comments

Tzung-Bi Shih Dec. 5, 2024, 9:20 a.m. UTC | #1
On Mon, Dec 02, 2024 at 08:00:37PM +0100, Thomas Weißschuh wrote:
> 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@weissschuh.net>

Reviewed-by: Tzung-Bi Shih <tzungbi@kernel.org>
diff mbox series

Patch

diff --git a/drivers/s390/char/sclp_config.c b/drivers/s390/char/sclp_config.c
index f56ea9b60e08e817652a9b7d19d420e9977c6552..0fe0782ccd325c1c3907e5d6272f770477e9ea46 100644
--- a/drivers/s390/char/sclp_config.c
+++ b/drivers/s390/char/sclp_config.c
@@ -127,9 +127,9 @@  static int sclp_ofb_send_req(char *ev_data, size_t len)
 	return rc;
 }
 
-static ssize_t sysfs_ofb_data_write(struct file *filp, struct kobject *kobj,
-				    struct bin_attribute *bin_attr,
-				    char *buf, loff_t off, size_t count)
+static ssize_t event_data_write(struct file *filp, struct kobject *kobj,
+				const struct bin_attribute *bin_attr,
+				char *buf, loff_t off, size_t count)
 {
 	int rc;
 
@@ -137,13 +137,7 @@  static ssize_t sysfs_ofb_data_write(struct file *filp, struct kobject *kobj,
 	return rc ?: count;
 }
 
-static const struct bin_attribute ofb_bin_attr = {
-	.attr = {
-		.name = "event_data",
-		.mode = S_IWUSR,
-	},
-	.write = sysfs_ofb_data_write,
-};
+static const BIN_ATTR_ADMIN_WO(event_data, 0);
 #endif
 
 static int __init sclp_ofb_setup(void)
@@ -155,7 +149,7 @@  static int __init sclp_ofb_setup(void)
 	ofb_kset = kset_create_and_add("ofb", NULL, firmware_kobj);
 	if (!ofb_kset)
 		return -ENOMEM;
-	rc = sysfs_create_bin_file(&ofb_kset->kobj, &ofb_bin_attr);
+	rc = sysfs_create_bin_file(&ofb_kset->kobj, &bin_attr_event_data);
 	if (rc) {
 		kset_unregister(ofb_kset);
 		return rc;