@@ -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);
}
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@weissschuh.net> --- drivers/scsi/arcmsr/arcmsr_attr.c | 73 ++++++++++++++------------------------- 1 file changed, 26 insertions(+), 47 deletions(-)