[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241202-sysfs-const-bin_attr-admin_wo-v1-3-f489116210bf@weissschuh.net>
Date: Mon, 02 Dec 2024 20:00:38 +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 3/5] powerpc/powernv/flash: 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>
---
arch/powerpc/platforms/powernv/opal-flash.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
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;
--
2.47.1
Powered by blists - more mailing lists