Commit f7120a4f75168df3c02efacd10403a4ba0bcb29d
Committed by
James Bottomley
1 parent
352f6bb422
Exists in
master
and in
4 other branches
[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>
Showing 3 changed files with 25 additions and 61 deletions Side-by-side Diff
drivers/scsi/hosts.c
... | ... | @@ -398,6 +398,7 @@ |
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); |
drivers/scsi/scsi_priv.h
drivers/scsi/scsi_sysfs.c
... | ... | @@ -251,21 +251,30 @@ |
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 | 266 | NULL |
267 | 267 | }; |
268 | 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, | |
275 | + NULL | |
276 | +}; | |
277 | + | |
269 | 278 | static void scsi_device_cls_release(struct device *class_dev) |
270 | 279 | { |
271 | 280 | struct scsi_device *sdev; |
... | ... | @@ -990,44 +999,6 @@ |
990 | 999 | } |
991 | 1000 | EXPORT_SYMBOL(scsi_register_interface); |
992 | 1001 | |
993 | - | |
994 | -static struct device_attribute *class_attr_overridden( | |
995 | - struct device_attribute **attrs, | |
996 | - struct device_attribute *attr) | |
997 | -{ | |
998 | - int i; | |
999 | - | |
1000 | - if (!attrs) | |
1001 | - return NULL; | |
1002 | - for (i = 0; attrs[i]; i++) | |
1003 | - if (!strcmp(attrs[i]->attr.name, attr->attr.name)) | |
1004 | - return attrs[i]; | |
1005 | - return NULL; | |
1006 | -} | |
1007 | - | |
1008 | -static int class_attr_add(struct device *classdev, | |
1009 | - struct device_attribute *attr) | |
1010 | -{ | |
1011 | - struct device_attribute *base_attr; | |
1012 | - | |
1013 | - /* | |
1014 | - * Spare the caller from having to copy things it's not interested in. | |
1015 | - */ | |
1016 | - base_attr = class_attr_overridden(scsi_sysfs_shost_attrs, attr); | |
1017 | - if (base_attr) { | |
1018 | - /* extend permissions */ | |
1019 | - attr->attr.mode |= base_attr->attr.mode; | |
1020 | - | |
1021 | - /* override null show/store with default */ | |
1022 | - if (!attr->show) | |
1023 | - attr->show = base_attr->show; | |
1024 | - if (!attr->store) | |
1025 | - attr->store = base_attr->store; | |
1026 | - } | |
1027 | - | |
1028 | - return device_create_file(classdev, attr); | |
1029 | -} | |
1030 | - | |
1031 | 1002 | /** |
1032 | 1003 | * scsi_sysfs_add_host - add scsi host to subsystem |
1033 | 1004 | * @shost: scsi host struct to add to subsystem |
1034 | 1005 | |
1035 | 1006 | |
... | ... | @@ -1037,20 +1008,11 @@ |
1037 | 1008 | { |
1038 | 1009 | int error, i; |
1039 | 1010 | |
1011 | + /* add host specific attributes */ | |
1040 | 1012 | if (shost->hostt->shost_attrs) { |
1041 | 1013 | for (i = 0; shost->hostt->shost_attrs[i]; i++) { |
1042 | - error = class_attr_add(&shost->shost_dev, | |
1043 | - shost->hostt->shost_attrs[i]); | |
1044 | - if (error) | |
1045 | - return error; | |
1046 | - } | |
1047 | - } | |
1048 | - | |
1049 | - for (i = 0; scsi_sysfs_shost_attrs[i]; i++) { | |
1050 | - if (!class_attr_overridden(shost->hostt->shost_attrs, | |
1051 | - scsi_sysfs_shost_attrs[i])) { | |
1052 | 1014 | error = device_create_file(&shost->shost_dev, |
1053 | - scsi_sysfs_shost_attrs[i]); | |
1015 | + shost->hostt->shost_attrs[i]); | |
1054 | 1016 | if (error) |
1055 | 1017 | return error; |
1056 | 1018 | } |