@@ -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;
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(-)