[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241202-sysfs-const-bin_attr-admin_wo-v1-5-f489116210bf@weissschuh.net>
Date: Mon, 02 Dec 2024 20:00:40 +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 5/5] scsi: arcmsr: Use BIN_ATTR_ADMIN_WO() for
bin_attribute definitions
Using the macro saves some lines of code and prepares the attributes for
the general constifications of struct bin_attributes.
While at it also constify the callback parameters.
Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
---
drivers/scsi/arcmsr/arcmsr_attr.c | 73 ++++++++++++++-------------------------
1 file changed, 26 insertions(+), 47 deletions(-)
diff --git a/drivers/scsi/arcmsr/arcmsr_attr.c b/drivers/scsi/arcmsr/arcmsr_attr.c
index baeb5e79569026f1af6612705689219bb4a7052f..af7750b551910b06254e443c25bebf323e29f162 100644
--- a/drivers/scsi/arcmsr/arcmsr_attr.c
+++ b/drivers/scsi/arcmsr/arcmsr_attr.c
@@ -58,11 +58,11 @@
#include <scsi/scsi_transport.h>
#include "arcmsr.h"
-static ssize_t arcmsr_sysfs_iop_message_read(struct file *filp,
- struct kobject *kobj,
- struct bin_attribute *bin,
- char *buf, loff_t off,
- size_t count)
+static ssize_t mu_read_read(struct file *filp,
+ struct kobject *kobj,
+ const struct bin_attribute *bin,
+ char *buf, loff_t off,
+ size_t count)
{
struct device *dev = container_of(kobj,struct device,kobj);
struct Scsi_Host *host = class_to_shost(dev);
@@ -105,11 +105,11 @@ static ssize_t arcmsr_sysfs_iop_message_read(struct file *filp,
return allxfer_len;
}
-static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp,
- struct kobject *kobj,
- struct bin_attribute *bin,
- char *buf, loff_t off,
- size_t count)
+static ssize_t mu_write_write(struct file *filp,
+ struct kobject *kobj,
+ const struct bin_attribute *bin,
+ char *buf, loff_t off,
+ size_t count)
{
struct device *dev = container_of(kobj,struct device,kobj);
struct Scsi_Host *host = class_to_shost(dev);
@@ -153,11 +153,11 @@ static ssize_t arcmsr_sysfs_iop_message_write(struct file *filp,
}
}
-static ssize_t arcmsr_sysfs_iop_message_clear(struct file *filp,
- struct kobject *kobj,
- struct bin_attribute *bin,
- char *buf, loff_t off,
- size_t count)
+static ssize_t mu_clear_write(struct file *filp,
+ struct kobject *kobj,
+ const struct bin_attribute *bin,
+ char *buf, loff_t off,
+ size_t count)
{
struct device *dev = container_of(kobj,struct device,kobj);
struct Scsi_Host *host = class_to_shost(dev);
@@ -188,58 +188,37 @@ static ssize_t arcmsr_sysfs_iop_message_clear(struct file *filp,
return 1;
}
-static const struct bin_attribute arcmsr_sysfs_message_read_attr = {
- .attr = {
- .name = "mu_read",
- .mode = S_IRUSR ,
- },
- .size = ARCMSR_API_DATA_BUFLEN,
- .read = arcmsr_sysfs_iop_message_read,
-};
+static const BIN_ATTR_ADMIN_RO(mu_read, ARCMSR_API_DATA_BUFLEN);
-static const struct bin_attribute arcmsr_sysfs_message_write_attr = {
- .attr = {
- .name = "mu_write",
- .mode = S_IWUSR,
- },
- .size = ARCMSR_API_DATA_BUFLEN,
- .write = arcmsr_sysfs_iop_message_write,
-};
+static const BIN_ATTR_ADMIN_WO(mu_write, ARCMSR_API_DATA_BUFLEN);
-static const struct bin_attribute arcmsr_sysfs_message_clear_attr = {
- .attr = {
- .name = "mu_clear",
- .mode = S_IWUSR,
- },
- .size = 1,
- .write = arcmsr_sysfs_iop_message_clear,
-};
+static const BIN_ATTR_ADMIN_WO(mu_clear, 1);
int arcmsr_alloc_sysfs_attr(struct AdapterControlBlock *acb)
{
struct Scsi_Host *host = acb->host;
int error;
- error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr);
+ error = sysfs_create_bin_file(&host->shost_dev.kobj, &bin_attr_mu_read);
if (error) {
printk(KERN_ERR "arcmsr: alloc sysfs mu_read failed\n");
goto error_bin_file_message_read;
}
- error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr);
+ error = sysfs_create_bin_file(&host->shost_dev.kobj, &bin_attr_mu_write);
if (error) {
printk(KERN_ERR "arcmsr: alloc sysfs mu_write failed\n");
goto error_bin_file_message_write;
}
- error = sysfs_create_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr);
+ error = sysfs_create_bin_file(&host->shost_dev.kobj, &bin_attr_mu_clear);
if (error) {
printk(KERN_ERR "arcmsr: alloc sysfs mu_clear failed\n");
goto error_bin_file_message_clear;
}
return 0;
error_bin_file_message_clear:
- sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr);
+ sysfs_remove_bin_file(&host->shost_dev.kobj, &bin_attr_mu_write);
error_bin_file_message_write:
- sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr);
+ sysfs_remove_bin_file(&host->shost_dev.kobj, &bin_attr_mu_read);
error_bin_file_message_read:
return error;
}
@@ -248,9 +227,9 @@ void arcmsr_free_sysfs_attr(struct AdapterControlBlock *acb)
{
struct Scsi_Host *host = acb->host;
- sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_clear_attr);
- sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_write_attr);
- sysfs_remove_bin_file(&host->shost_dev.kobj, &arcmsr_sysfs_message_read_attr);
+ sysfs_remove_bin_file(&host->shost_dev.kobj, &bin_attr_mu_clear);
+ sysfs_remove_bin_file(&host->shost_dev.kobj, &bin_attr_mu_write);
+ sysfs_remove_bin_file(&host->shost_dev.kobj, &bin_attr_mu_read);
}
--
2.47.1
Powered by blists - more mailing lists