diff --git a/scst/include/scst.h b/scst/include/scst.h index d6fb7ff05..4e4420fdd 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -4191,6 +4191,9 @@ static inline struct kobject *scst_sysfs_get_tgtt_kobj( return &tgtt->tgtt_kobj; } +int scst_create_tgtt_attr(struct scst_tgt_template *tgtt, + struct kobj_attribute *attribute); + /* * Returns target's root sysfs kobject. * The driver can create own files/directories/links here. @@ -4201,6 +4204,9 @@ static inline struct kobject *scst_sysfs_get_tgt_kobj( return &tgt->tgt_kobj; } +int scst_create_tgt_attr(struct scst_tgt *tgt, + struct kobj_attribute *attribute); + /* * Returns device handler's root sysfs kobject. * The driver can create own files/directories/links here. @@ -4211,6 +4217,9 @@ static inline struct kobject *scst_sysfs_get_devt_kobj( return &devt->devt_kobj; } +int scst_create_devt_attr(struct scst_dev_type *devt, + struct kobj_attribute *attribute); + /* * Returns device's root sysfs kobject. * The driver can create own files/directories/links here. @@ -4221,6 +4230,9 @@ static inline struct kobject *scst_sysfs_get_dev_kobj( return &dev->dev_kobj; } +int scst_create_dev_attr(struct scst_device *dev, + struct kobj_attribute *attribute); + /* * Returns session's root sysfs kobject. * The driver can create own files/directories/links here. @@ -4474,9 +4486,6 @@ 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 354e65dee..64551ce7e 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -984,6 +984,26 @@ static struct kobj_attribute scst_tgtt_mgmt = __ATTR(mgmt, S_IRUGO | S_IWUSR, scst_tgtt_mgmt_show, scst_tgtt_mgmt_store); +/* + * Creates an attribute entry for target driver. + */ +int scst_create_tgtt_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); + goto out; + } + +out: + return res; +} +EXPORT_SYMBOL(scst_create_tgtt_attr); + int scst_tgtt_sysfs_create(struct scst_tgt_template *tgtt) { int res = 0; @@ -2284,10 +2304,9 @@ out: 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. + * create an attribute that is not for every target. */ int scst_create_tgt_attr(struct scst_tgt *tgt, struct kobj_attribute *attribute) { @@ -2305,26 +2324,6 @@ out: } 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); - goto out; - } - -out: - 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. @@ -2812,6 +2811,27 @@ static void scst_sysfs_dev_release(struct kobject *kobj) return; } +/* + * Creates an attribute entry for one SCST device. Allows for dev handlers to + * create an attribute that is not for every device. + */ +int scst_create_dev_attr(struct scst_device *dev, + struct kobj_attribute *attribute) +{ + int res; + + res = sysfs_create_file(&dev->dev_kobj, &attribute->attr); + if (res != 0) { + PRINT_ERROR("Can't add attribute %s for dev %s", + attribute->attr.name, dev->virt_name); + goto out; + } + +out: + return res; +} +EXPORT_SYMBOL(scst_create_dev_attr); + int scst_devt_dev_sysfs_create(struct scst_device *dev) { int res = 0; @@ -4797,6 +4817,26 @@ static struct kobj_attribute scst_devt_pass_through_mgmt = __ATTR(mgmt, S_IRUGO | S_IWUSR, scst_devt_pass_through_mgmt_show, scst_devt_pass_through_mgmt_store); +/* + * Creates an attribute entry for dev handler. + */ +int scst_create_devt_attr(struct scst_dev_type *devt, + struct kobj_attribute *attribute) +{ + int res; + + res = sysfs_create_file(&devt->devt_kobj, &attribute->attr); + if (res != 0) { + PRINT_ERROR("Can't add attribute %s for dev handler %s", + attribute->attr.name, devt->name); + goto out; + } + +out: + return res; +} +EXPORT_SYMBOL(scst_create_devt_attr); + int scst_devt_sysfs_create(struct scst_dev_type *devt) { int res;