提交 352f6bb4 编写于 作者: J James Bottomley

[SCSI] scsi_transport_spi: fix the attribute settings

We now take advantage of the mode_t return of is_valid, and also
update the attributes when the target is configured.
Signed-off-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
上级 0f423895
...@@ -1374,11 +1374,11 @@ static int spi_host_configure(struct transport_container *tc, ...@@ -1374,11 +1374,11 @@ static int spi_host_configure(struct transport_container *tc,
* overloads the return by setting 1<<1 if the attribute should * overloads the return by setting 1<<1 if the attribute should
* be writeable */ * be writeable */
#define TARGET_ATTRIBUTE_HELPER(name) \ #define TARGET_ATTRIBUTE_HELPER(name) \
(si->f->show_##name ? 1 : 0) + \ (si->f->show_##name ? S_IRUGO : 0) | \
(si->f->set_##name ? 2 : 0) (si->f->set_##name ? S_IWUSR : 0)
static int target_attribute_is_visible(struct kobject *kobj, static mode_t target_attribute_is_visible(struct kobject *kobj,
struct attribute *attr, int i) struct attribute *attr, int i)
{ {
struct device *cdev = container_of(kobj, struct device, kobj); struct device *cdev = container_of(kobj, struct device, kobj);
struct scsi_target *starget = transport_class_to_starget(cdev); struct scsi_target *starget = transport_class_to_starget(cdev);
...@@ -1428,7 +1428,7 @@ static int target_attribute_is_visible(struct kobject *kobj, ...@@ -1428,7 +1428,7 @@ static int target_attribute_is_visible(struct kobject *kobj,
spi_support_ius(starget)) spi_support_ius(starget))
return TARGET_ATTRIBUTE_HELPER(hold_mcs); return TARGET_ATTRIBUTE_HELPER(hold_mcs);
else if (attr == &dev_attr_revalidate.attr) else if (attr == &dev_attr_revalidate.attr)
return 1; return S_IWUSR;
return 0; return 0;
} }
...@@ -1462,25 +1462,9 @@ static int spi_target_configure(struct transport_container *tc, ...@@ -1462,25 +1462,9 @@ static int spi_target_configure(struct transport_container *tc,
struct device *cdev) struct device *cdev)
{ {
struct kobject *kobj = &cdev->kobj; struct kobject *kobj = &cdev->kobj;
int i;
struct attribute *attr; /* force an update based on parameters read from the device */
int rc; sysfs_update_group(kobj, &target_attribute_group);
for (i = 0; (attr = target_attributes[i]) != NULL; i++) {
int j = target_attribute_group.is_visible(kobj, attr, i);
/* FIXME: as well as returning -EEXIST, which we'd like
* to ignore, sysfs also does a WARN_ON and dumps a trace,
* which is bad, so temporarily, skip attributes that are
* already visible (the revalidate one) */
if (j && attr != &dev_attr_revalidate.attr)
rc = sysfs_add_file_to_group(kobj, attr,
target_attribute_group.name);
/* and make the attribute writeable if we have a set
* function */
if ((j & 1))
rc = sysfs_chmod_file(kobj, attr, attr->mode | S_IWUSR);
}
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册