Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] use default attributes for scsi_host

This patch removes the unused sysfs attibute overwriting logic for
the scsi host attibutes, and plugs them into the driver core default
attribute creation.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>

authored by

Hannes Reinecke and committed by
James Bottomley
f7120a4f 352f6bb4

+25 -61
+1
drivers/scsi/hosts.c
··· 398 398 shost->shost_dev.class = &shost_class; 399 399 snprintf(shost->shost_dev.bus_id, BUS_ID_SIZE, "host%d", 400 400 shost->host_no); 401 + shost->shost_dev.groups = scsi_sysfs_shost_attr_groups; 401 402 402 403 shost->ehandler = kthread_run(scsi_error_handler, shost, 403 404 "scsi_eh_%d", shost->host_no);
+1
drivers/scsi/scsi_priv.h
··· 121 121 extern void __scsi_remove_device(struct scsi_device *); 122 122 123 123 extern struct bus_type scsi_bus_type; 124 + extern struct attribute_group *scsi_sysfs_shost_attr_groups[]; 124 125 125 126 /* scsi_netlink.c */ 126 127 #ifdef CONFIG_SCSI_NETLINK
+23 -61
drivers/scsi/scsi_sysfs.c
··· 251 251 shost_rd_attr(unchecked_isa_dma, "%d\n"); 252 252 shost_rd_attr2(proc_name, hostt->proc_name, "%s\n"); 253 253 254 - static struct device_attribute *scsi_sysfs_shost_attrs[] = { 255 - &dev_attr_unique_id, 256 - &dev_attr_host_busy, 257 - &dev_attr_cmd_per_lun, 258 - &dev_attr_can_queue, 259 - &dev_attr_sg_tablesize, 260 - &dev_attr_unchecked_isa_dma, 261 - &dev_attr_proc_name, 262 - &dev_attr_scan, 263 - &dev_attr_hstate, 264 - &dev_attr_supported_mode, 265 - &dev_attr_active_mode, 254 + static struct attribute *scsi_sysfs_shost_attrs[] = { 255 + &dev_attr_unique_id.attr, 256 + &dev_attr_host_busy.attr, 257 + &dev_attr_cmd_per_lun.attr, 258 + &dev_attr_can_queue.attr, 259 + &dev_attr_sg_tablesize.attr, 260 + &dev_attr_unchecked_isa_dma.attr, 261 + &dev_attr_proc_name.attr, 262 + &dev_attr_scan.attr, 263 + &dev_attr_hstate.attr, 264 + &dev_attr_supported_mode.attr, 265 + &dev_attr_active_mode.attr, 266 + NULL 267 + }; 268 + 269 + struct attribute_group scsi_shost_attr_group = { 270 + .attrs = scsi_sysfs_shost_attrs, 271 + }; 272 + 273 + struct attribute_group *scsi_sysfs_shost_attr_groups[] = { 274 + &scsi_shost_attr_group, 266 275 NULL 267 276 }; 268 277 ··· 999 990 } 1000 991 EXPORT_SYMBOL(scsi_register_interface); 1001 992 1002 - 1003 - static struct device_attribute *class_attr_overridden( 1004 - struct device_attribute **attrs, 1005 - struct device_attribute *attr) 1006 - { 1007 - int i; 1008 - 1009 - if (!attrs) 1010 - return NULL; 1011 - for (i = 0; attrs[i]; i++) 1012 - if (!strcmp(attrs[i]->attr.name, attr->attr.name)) 1013 - return attrs[i]; 1014 - return NULL; 1015 - } 1016 - 1017 - static int class_attr_add(struct device *classdev, 1018 - struct device_attribute *attr) 1019 - { 1020 - struct device_attribute *base_attr; 1021 - 1022 - /* 1023 - * Spare the caller from having to copy things it's not interested in. 1024 - */ 1025 - base_attr = class_attr_overridden(scsi_sysfs_shost_attrs, attr); 1026 - if (base_attr) { 1027 - /* extend permissions */ 1028 - attr->attr.mode |= base_attr->attr.mode; 1029 - 1030 - /* override null show/store with default */ 1031 - if (!attr->show) 1032 - attr->show = base_attr->show; 1033 - if (!attr->store) 1034 - attr->store = base_attr->store; 1035 - } 1036 - 1037 - return device_create_file(classdev, attr); 1038 - } 1039 - 1040 993 /** 1041 994 * scsi_sysfs_add_host - add scsi host to subsystem 1042 995 * @shost: scsi host struct to add to subsystem ··· 1008 1037 { 1009 1038 int error, i; 1010 1039 1040 + /* add host specific attributes */ 1011 1041 if (shost->hostt->shost_attrs) { 1012 1042 for (i = 0; shost->hostt->shost_attrs[i]; i++) { 1013 - error = class_attr_add(&shost->shost_dev, 1014 - shost->hostt->shost_attrs[i]); 1015 - if (error) 1016 - return error; 1017 - } 1018 - } 1019 - 1020 - for (i = 0; scsi_sysfs_shost_attrs[i]; i++) { 1021 - if (!class_attr_overridden(shost->hostt->shost_attrs, 1022 - scsi_sysfs_shost_attrs[i])) { 1023 1043 error = device_create_file(&shost->shost_dev, 1024 - scsi_sysfs_shost_attrs[i]); 1044 + shost->hostt->shost_attrs[i]); 1025 1045 if (error) 1026 1046 return error; 1027 1047 }