aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/scsi_transport_spi.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c
index bc12b5d5d676..3a26f7489b48 100644
--- a/drivers/scsi/scsi_transport_spi.c
+++ b/drivers/scsi/scsi_transport_spi.c
@@ -1374,11 +1374,11 @@ static int spi_host_configure(struct transport_container *tc,
1374 * overloads the return by setting 1<<1 if the attribute should 1374 * overloads the return by setting 1<<1 if the attribute should
1375 * be writeable */ 1375 * be writeable */
1376#define TARGET_ATTRIBUTE_HELPER(name) \ 1376#define TARGET_ATTRIBUTE_HELPER(name) \
1377 (si->f->show_##name ? 1 : 0) + \ 1377 (si->f->show_##name ? S_IRUGO : 0) | \
1378 (si->f->set_##name ? 2 : 0) 1378 (si->f->set_##name ? S_IWUSR : 0)
1379 1379
1380static int target_attribute_is_visible(struct kobject *kobj, 1380static mode_t target_attribute_is_visible(struct kobject *kobj,
1381 struct attribute *attr, int i) 1381 struct attribute *attr, int i)
1382{ 1382{
1383 struct device *cdev = container_of(kobj, struct device, kobj); 1383 struct device *cdev = container_of(kobj, struct device, kobj);
1384 struct scsi_target *starget = transport_class_to_starget(cdev); 1384 struct scsi_target *starget = transport_class_to_starget(cdev);
@@ -1428,7 +1428,7 @@ static int target_attribute_is_visible(struct kobject *kobj,
1428 spi_support_ius(starget)) 1428 spi_support_ius(starget))
1429 return TARGET_ATTRIBUTE_HELPER(hold_mcs); 1429 return TARGET_ATTRIBUTE_HELPER(hold_mcs);
1430 else if (attr == &dev_attr_revalidate.attr) 1430 else if (attr == &dev_attr_revalidate.attr)
1431 return 1; 1431 return S_IWUSR;
1432 1432
1433 return 0; 1433 return 0;
1434} 1434}
@@ -1462,25 +1462,9 @@ static int spi_target_configure(struct transport_container *tc,
1462 struct device *cdev) 1462 struct device *cdev)
1463{ 1463{
1464 struct kobject *kobj = &cdev->kobj; 1464 struct kobject *kobj = &cdev->kobj;
1465 int i; 1465
1466 struct attribute *attr; 1466 /* force an update based on parameters read from the device */
1467 int rc; 1467 sysfs_update_group(kobj, &target_attribute_group);
1468
1469 for (i = 0; (attr = target_attributes[i]) != NULL; i++) {
1470 int j = target_attribute_group.is_visible(kobj, attr, i);
1471
1472 /* FIXME: as well as returning -EEXIST, which we'd like
1473 * to ignore, sysfs also does a WARN_ON and dumps a trace,
1474 * which is bad, so temporarily, skip attributes that are
1475 * already visible (the revalidate one) */
1476 if (j && attr != &dev_attr_revalidate.attr)
1477 rc = sysfs_add_file_to_group(kobj, attr,
1478 target_attribute_group.name);
1479 /* and make the attribute writeable if we have a set
1480 * function */
1481 if ((j & 1))
1482 rc = sysfs_chmod_file(kobj, attr, attr->mode | S_IWUSR);
1483 }
1484 1468
1485 return 0; 1469 return 0;
1486} 1470}