From 2eafd72939fda6118e27d3ee859684987f43921b Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 3 Oct 2015 15:32:55 +0200 Subject: [PATCH] target: use per-attribute show and store methods This also allows to remove the target-specific old configfs macros, and gets rid of the target_core_fabric_configfs.h header which only had one function declaration left that could be moved to a better place. Signed-off-by: Christoph Hellwig Reviewed-by: Nicholas Bellinger Acked-by: Nicholas Bellinger Signed-off-by: Nicholas Bellinger [[ stefanr: only sbp part included here ]] --- Documentation/target/tcm_mod_builder.py | 17 - drivers/infiniband/ulp/srpt/ib_srpt.c | 78 +- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 153 ++-- drivers/target/iscsi/iscsi_target_configfs.c | 791 ++++++----------- drivers/target/iscsi/iscsi_target_stat.c | 666 ++++++-------- drivers/target/loopback/tcm_loop.c | 60 +- drivers/target/sbp/sbp_target.c | 87 +- drivers/target/target_core_configfs.c | 1209 ++++++++++---------------- drivers/target/target_core_fabric_configfs.c | 275 ++---- drivers/target/target_core_internal.h | 3 + drivers/target/target_core_stat.c | 918 ++++++++----------- drivers/target/tcm_fc/tfc_cmd.c | 1 - drivers/target/tcm_fc/tfc_conf.c | 44 +- drivers/target/tcm_fc/tfc_io.c | 1 - drivers/target/tcm_fc/tfc_sess.c | 1 - drivers/usb/gadget/legacy/tcm_usb_gadget.c | 44 +- drivers/vhost/scsi.c | 41 +- drivers/xen/xen-scsiback.c | 32 +- include/target/configfs_macros.h | 147 ---- include/target/target_core_base.h | 60 ++ include/target/target_core_fabric_configfs.h | 122 --- 21 files changed, 1689 insertions(+), 3061 deletions(-) delete mode 100644 include/target/configfs_macros.h delete mode 100644 include/target/target_core_fabric_configfs.h --- a/drivers/target/sbp/sbp_target.c +++ b/drivers/target/sbp/sbp_target.c @@ -35,8 +35,6 @@ #include #include #include -#include -#include #include #include "sbp_target.h" @@ -2111,24 +2109,21 @@ static void sbp_drop_tport(struct se_wwn *wwn) kfree(tport); } -static ssize_t sbp_wwn_show_attr_version( - struct target_fabric_configfs *tf, - char *page) +static ssize_t sbp_wwn_version_show(struct config_item *item, char *page) { return sprintf(page, "FireWire SBP fabric module %s\n", SBP_VERSION); } -TF_WWN_ATTR_RO(sbp, version); +CONFIGFS_ATTR_RO(sbp_wwn_, version); static struct configfs_attribute *sbp_wwn_attrs[] = { - &sbp_wwn_version.attr, + &sbp_wwn_attr_version, NULL, }; -static ssize_t sbp_tpg_show_directory_id( - struct se_portal_group *se_tpg, - char *page) +static ssize_t sbp_tpg_directory_id_show(struct config_item *item, char *page) { + struct se_portal_group *se_tpg = to_tpg(item); struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); struct sbp_tport *tport = tpg->tport; @@ -2138,11 +2133,10 @@ static ssize_t sbp_tpg_show_directory_id( return sprintf(page, "%06x\n", tport->directory_id); } -static ssize_t sbp_tpg_store_directory_id( - struct se_portal_group *se_tpg, - const char *page, - size_t count) +static ssize_t sbp_tpg_directory_id_store(struct config_item *item, + const char *page, size_t count) { + struct se_portal_group *se_tpg = to_tpg(item); struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); struct sbp_tport *tport = tpg->tport; unsigned long val; @@ -2166,20 +2160,18 @@ static ssize_t sbp_tpg_store_directory_id( return count; } -static ssize_t sbp_tpg_show_enable( - struct se_portal_group *se_tpg, - char *page) +static ssize_t sbp_tpg_enable_show(struct config_item *item, char *page) { + struct se_portal_group *se_tpg = to_tpg(item); struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); struct sbp_tport *tport = tpg->tport; return sprintf(page, "%d\n", tport->enable); } -static ssize_t sbp_tpg_store_enable( - struct se_portal_group *se_tpg, - const char *page, - size_t count) +static ssize_t sbp_tpg_enable_store(struct config_item *item, + const char *page, size_t count) { + struct se_portal_group *se_tpg = to_tpg(item); struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); struct sbp_tport *tport = tpg->tport; unsigned long val; @@ -2219,29 +2211,28 @@ static ssize_t sbp_tpg_store_enable( return count; } -TF_TPG_BASE_ATTR(sbp, directory_id, S_IRUGO | S_IWUSR); -TF_TPG_BASE_ATTR(sbp, enable, S_IRUGO | S_IWUSR); +CONFIGFS_ATTR(sbp_tpg_, directory_id); +CONFIGFS_ATTR(sbp_tpg_, enable); static struct configfs_attribute *sbp_tpg_base_attrs[] = { - &sbp_tpg_directory_id.attr, - &sbp_tpg_enable.attr, + &sbp_tpg_attr_directory_id, + &sbp_tpg_attr_enable, NULL, }; -static ssize_t sbp_tpg_attrib_show_mgt_orb_timeout( - struct se_portal_group *se_tpg, +static ssize_t sbp_tpg_attrib_mgt_orb_timeout_show(struct config_item *item, char *page) { + struct se_portal_group *se_tpg = attrib_to_tpg(item); struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); struct sbp_tport *tport = tpg->tport; return sprintf(page, "%d\n", tport->mgt_orb_timeout); } -static ssize_t sbp_tpg_attrib_store_mgt_orb_timeout( - struct se_portal_group *se_tpg, - const char *page, - size_t count) +static ssize_t sbp_tpg_attrib_mgt_orb_timeout_store(struct config_item *item, + const char *page, size_t count) { + struct se_portal_group *se_tpg = attrib_to_tpg(item); struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); struct sbp_tport *tport = tpg->tport; unsigned long val; @@ -2264,20 +2255,19 @@ static ssize_t sbp_tpg_attrib_store_mgt_orb_timeout( return count; } -static ssize_t sbp_tpg_attrib_show_max_reconnect_timeout( - struct se_portal_group *se_tpg, +static ssize_t sbp_tpg_attrib_max_reconnect_timeout_show(struct config_item *item, char *page) { + struct se_portal_group *se_tpg = attrib_to_tpg(item); struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); struct sbp_tport *tport = tpg->tport; return sprintf(page, "%d\n", tport->max_reconnect_timeout); } -static ssize_t sbp_tpg_attrib_store_max_reconnect_timeout( - struct se_portal_group *se_tpg, - const char *page, - size_t count) +static ssize_t sbp_tpg_attrib_max_reconnect_timeout_store(struct config_item *item, + const char *page, size_t count) { + struct se_portal_group *se_tpg = attrib_to_tpg(item); struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); struct sbp_tport *tport = tpg->tport; unsigned long val; @@ -2300,20 +2290,19 @@ static ssize_t sbp_tpg_attrib_store_max_reconnect_timeout( return count; } -static ssize_t sbp_tpg_attrib_show_max_logins_per_lun( - struct se_portal_group *se_tpg, +static ssize_t sbp_tpg_attrib_max_logins_per_lun_show(struct config_item *item, char *page) { + struct se_portal_group *se_tpg = attrib_to_tpg(item); struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); struct sbp_tport *tport = tpg->tport; return sprintf(page, "%d\n", tport->max_logins_per_lun); } -static ssize_t sbp_tpg_attrib_store_max_logins_per_lun( - struct se_portal_group *se_tpg, - const char *page, - size_t count) +static ssize_t sbp_tpg_attrib_max_logins_per_lun_store(struct config_item *item, + const char *page, size_t count) { + struct se_portal_group *se_tpg = attrib_to_tpg(item); struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); struct sbp_tport *tport = tpg->tport; unsigned long val; @@ -2330,14 +2319,14 @@ static ssize_t sbp_tpg_attrib_store_max_logins_per_lun( return count; } -TF_TPG_ATTRIB_ATTR(sbp, mgt_orb_timeout, S_IRUGO | S_IWUSR); -TF_TPG_ATTRIB_ATTR(sbp, max_reconnect_timeout, S_IRUGO | S_IWUSR); -TF_TPG_ATTRIB_ATTR(sbp, max_logins_per_lun, S_IRUGO | S_IWUSR); +CONFIGFS_ATTR(sbp_tpg_attrib_, mgt_orb_timeout); +CONFIGFS_ATTR(sbp_tpg_attrib_, max_reconnect_timeout); +CONFIGFS_ATTR(sbp_tpg_attrib_, max_logins_per_lun); static struct configfs_attribute *sbp_tpg_attrib_attrs[] = { - &sbp_tpg_attrib_mgt_orb_timeout.attr, - &sbp_tpg_attrib_max_reconnect_timeout.attr, - &sbp_tpg_attrib_max_logins_per_lun.attr, + &sbp_tpg_attrib_attr_mgt_orb_timeout, + &sbp_tpg_attrib_attr_max_reconnect_timeout, + &sbp_tpg_attrib_attr_max_logins_per_lun, NULL, };