diff mbox series

[3/5] powerpc/powernv/flash: Use BIN_ATTR_ADMIN_WO() for bin_attribute definition

Message ID 20241202-sysfs-const-bin_attr-admin_wo-v1-3-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>
---
 arch/powerpc/platforms/powernv/opal-flash.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/powernv/opal-flash.c b/arch/powerpc/platforms/powernv/opal-flash.c
index d5ea04e8e4c526b99ca8f1ab613266b385362d82..76e3818601e5610f48bb8a6fd325239d6ad39723 100644
--- a/arch/powerpc/platforms/powernv/opal-flash.c
+++ b/arch/powerpc/platforms/powernv/opal-flash.c
@@ -431,9 +431,9 @@  static int alloc_image_buf(char *buffer, size_t count)
  * Parse candidate image header to get total image size
  * and pre-allocate required memory.
  */
-static ssize_t image_data_write(struct file *filp, struct kobject *kobj,
-				struct bin_attribute *bin_attr,
-				char *buffer, loff_t pos, size_t count)
+static ssize_t image_write(struct file *filp, struct kobject *kobj,
+			   const struct bin_attribute *bin_attr,
+			   char *buffer, loff_t pos, size_t count)
 {
 	int rc;
 
@@ -490,11 +490,7 @@  static ssize_t image_data_write(struct file *filp, struct kobject *kobj,
  *   update_flash	: Flash new firmware image
  *
  */
-static const struct bin_attribute image_data_attr = {
-	.attr = {.name = "image", .mode = 0200},
-	.size = MAX_IMAGE_SIZE,	/* Limit image size */
-	.write = image_data_write,
-};
+static const BIN_ATTR_ADMIN_WO(image, MAX_IMAGE_SIZE);
 
 static struct kobj_attribute validate_attribute =
 	__ATTR(validate_flash, 0600, validate_show, validate_store);
@@ -544,7 +540,7 @@  void __init opal_flash_update_init(void)
 		goto nokobj;
 	}
 
-	ret = sysfs_create_bin_file(opal_kobj, &image_data_attr);
+	ret = sysfs_create_bin_file(opal_kobj, &bin_attr_image);
 	if (ret) {
 		pr_warn("FLASH: Failed to create sysfs files\n");
 		goto nosysfs_file;