From 849c9ec8015785c2e38453f897e2683f6d5fe0a5 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 15 Dec 2010 12:01:41 +0000 Subject: [PATCH] Eliminated two more forward declarations. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@3069 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_sysfs.c | 154 ++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 80 deletions(-) diff --git a/scst/src/scst_sysfs.c b/scst/src/scst_sysfs.c index 0c094a3a2..753aad355 100644 --- a/scst/src/scst_sysfs.c +++ b/scst/src/scst_sysfs.c @@ -301,12 +301,6 @@ static ssize_t scst_luns_mgmt_show(struct kobject *kobj, static ssize_t scst_luns_mgmt_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count); -static ssize_t scst_tgt_addr_method_show(struct kobject *kobj, - struct kobj_attribute *attr, - char *buf); -static ssize_t scst_tgt_addr_method_store(struct kobject *kobj, - struct kobj_attribute *attr, - const char *buf, size_t count); static ssize_t scst_tgt_io_grouping_type_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf); @@ -1166,6 +1160,80 @@ static struct kobj_type acg_ktype = { .release = scst_acg_release, }; +static ssize_t __scst_acg_addr_method_show(struct scst_acg *acg, char *buf) +{ + int res; + + switch (acg->addr_method) { + case SCST_LUN_ADDR_METHOD_FLAT: + res = sprintf(buf, "FLAT\n"); + break; + case SCST_LUN_ADDR_METHOD_PERIPHERAL: + res = sprintf(buf, "PERIPHERAL\n"); + break; + case SCST_LUN_ADDR_METHOD_LUN: + res = sprintf(buf, "LUN\n"); + break; + default: + res = sprintf(buf, "UNKNOWN\n"); + break; + } + + if (acg->addr_method != acg->tgt->tgtt->preferred_addr_method) + res += sprintf(&buf[res], "%s\n", SCST_SYSFS_KEY_MARK); + + return res; +} + +static ssize_t __scst_acg_addr_method_store(struct scst_acg *acg, + const char *buf, size_t count) +{ + int res = count; + + if (strncasecmp(buf, "FLAT", min_t(int, 4, count)) == 0) + acg->addr_method = SCST_LUN_ADDR_METHOD_FLAT; + else if (strncasecmp(buf, "PERIPHERAL", min_t(int, 10, count)) == 0) + acg->addr_method = SCST_LUN_ADDR_METHOD_PERIPHERAL; + else if (strncasecmp(buf, "LUN", min_t(int, 3, count)) == 0) + acg->addr_method = SCST_LUN_ADDR_METHOD_LUN; + else { + PRINT_ERROR("Unknown address method %s", buf); + res = -EINVAL; + } + + TRACE_DBG("acg %p, addr_method %d", acg, acg->addr_method); + + return res; +} + +static ssize_t scst_tgt_addr_method_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct scst_acg *acg; + struct scst_tgt *tgt; + + tgt = container_of(kobj, struct scst_tgt, tgt_kobj); + acg = tgt->default_acg; + + return __scst_acg_addr_method_show(acg, buf); +} + +static ssize_t scst_tgt_addr_method_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + int res; + struct scst_acg *acg; + struct scst_tgt *tgt; + + tgt = container_of(kobj, struct scst_tgt, tgt_kobj); + acg = tgt->default_acg; + + res = __scst_acg_addr_method_store(acg, buf, count); + + TRACE_EXIT_RES(res); + return res; +} + static struct kobj_attribute scst_luns_mgmt = __ATTR(mgmt, S_IRUGO | S_IWUSR, scst_luns_mgmt_show, scst_luns_mgmt_store); @@ -3152,80 +3220,6 @@ static ssize_t scst_luns_mgmt_store(struct kobject *kobj, return res; } -static ssize_t __scst_acg_addr_method_show(struct scst_acg *acg, char *buf) -{ - int res; - - switch (acg->addr_method) { - case SCST_LUN_ADDR_METHOD_FLAT: - res = sprintf(buf, "FLAT\n"); - break; - case SCST_LUN_ADDR_METHOD_PERIPHERAL: - res = sprintf(buf, "PERIPHERAL\n"); - break; - case SCST_LUN_ADDR_METHOD_LUN: - res = sprintf(buf, "LUN\n"); - break; - default: - res = sprintf(buf, "UNKNOWN\n"); - break; - } - - if (acg->addr_method != acg->tgt->tgtt->preferred_addr_method) - res += sprintf(&buf[res], "%s\n", SCST_SYSFS_KEY_MARK); - - return res; -} - -static ssize_t __scst_acg_addr_method_store(struct scst_acg *acg, - const char *buf, size_t count) -{ - int res = count; - - if (strncasecmp(buf, "FLAT", min_t(int, 4, count)) == 0) - acg->addr_method = SCST_LUN_ADDR_METHOD_FLAT; - else if (strncasecmp(buf, "PERIPHERAL", min_t(int, 10, count)) == 0) - acg->addr_method = SCST_LUN_ADDR_METHOD_PERIPHERAL; - else if (strncasecmp(buf, "LUN", min_t(int, 3, count)) == 0) - acg->addr_method = SCST_LUN_ADDR_METHOD_LUN; - else { - PRINT_ERROR("Unknown address method %s", buf); - res = -EINVAL; - } - - TRACE_DBG("acg %p, addr_method %d", acg, acg->addr_method); - - return res; -} - -static ssize_t scst_tgt_addr_method_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) -{ - struct scst_acg *acg; - struct scst_tgt *tgt; - - tgt = container_of(kobj, struct scst_tgt, tgt_kobj); - acg = tgt->default_acg; - - return __scst_acg_addr_method_show(acg, buf); -} - -static ssize_t scst_tgt_addr_method_store(struct kobject *kobj, - struct kobj_attribute *attr, const char *buf, size_t count) -{ - int res; - struct scst_acg *acg; - struct scst_tgt *tgt; - - tgt = container_of(kobj, struct scst_tgt, tgt_kobj); - acg = tgt->default_acg; - - res = __scst_acg_addr_method_store(acg, buf, count); - - TRACE_EXIT_RES(res); - return res; -} - static ssize_t __scst_acg_io_grouping_type_show(struct scst_acg *acg, char *buf) { int res;