There is not a way to specify an attribute that applies to only one
target or target driver. This patch provides such an interface.

Copyright (C) 2013  Emulex.  All rights reserved.

This software is provided as-is, without any express or implied warranty.  In
no event will Emulex be held liable for any damages arising from the use of
this software. Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and redistribute it
freely. If you use this software in a product, an acknowledgment in the
product documentation would be appreciated, but is not required. This notice
may be removed from any source code distribution that includes all or any part
of the original software.



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4970 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2013-08-15 05:34:33 +00:00
parent 886ae66326
commit f8f2580fcd
2 changed files with 41 additions and 0 deletions

View File

@@ -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 */

View File

@@ -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.