diff --git a/scst/include/scst.h b/scst/include/scst.h index e3b0bbdb9..0f3095638 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -4467,6 +4467,9 @@ int scst_alloc_sysfs_work(int (*sysfs_work_fn)(struct scst_sysfs_work_item *), int scst_sysfs_queue_wait_work(struct scst_sysfs_work_item *work); void scst_sysfs_work_get(struct scst_sysfs_work_item *work); void scst_sysfs_work_put(struct scst_sysfs_work_item *work); +int scst_create_tgt_attr(struct scst_tgt *tgt, struct kobj_attribute *attribute); +int scst_create_tgt_driver_attr(struct scst_tgt_template *tgtt, + struct kobj_attribute *attribute); #endif /* CONFIG_SCST_PROC */ diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 30933f95a..3e474120c 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -2285,6 +2285,44 @@ static struct kobj_attribute scst_tgt_comment = __ATTR(comment, S_IRUGO | S_IWUSR, scst_tgt_comment_show, scst_tgt_comment_store); +/* + * Creates an attribute entry for one target. Allows for target driver to + * specify an attribute that is not for every target. + */ +int scst_create_tgt_attr(struct scst_tgt *tgt, struct kobj_attribute *attribute) +{ + int res; + + res = sysfs_create_file(&tgt->tgt_kobj, &attribute->attr); + if (res != 0) { + PRINT_ERROR("Can't add attribute %s for tgt %s", + attribute->attr.name, tgt->tgt_name); + res = -ENOMEM; + } + + return res; +} +EXPORT_SYMBOL(scst_create_tgt_attr); + +/* + * Creates an attribute entry for target driver. + */ +int scst_create_tgt_driver_attr(struct scst_tgt_template *tgtt, + struct kobj_attribute *attribute) +{ + int res; + + res = sysfs_create_file(&tgtt->tgtt_kobj, &attribute->attr); + if (res != 0) { + PRINT_ERROR("Can't add attribute %s for target driver %s", + attribute->attr.name, tgtt->name); + res = -ENOMEM; + } + + return res; +} +EXPORT_SYMBOL(scst_create_tgt_driver_attr); + /* * Supposed to be called under scst_mutex. In case of error will drop, * then reacquire it.