aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx/tcm_qla2xxx.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-10-03 09:32:55 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2015-10-14 01:17:49 -0400
commit2eafd72939fda6118e27d3ee859684987f43921b (patch)
treea00a1f5686ec852e04b52ea5fb1ce37c05564dc9 /drivers/scsi/qla2xxx/tcm_qla2xxx.c
parent64c6be0e6df5b5804613863ca4fb05961948c999 (diff)
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 <hch@lst.de> Reviewed-by: Nicholas Bellinger <nab@linux-iscsi.org> Acked-by: Nicholas Bellinger <nab@linux-iscsi.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/scsi/qla2xxx/tcm_qla2xxx.c')
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.c153
1 files changed, 51 insertions, 102 deletions
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index ac65cb7b4886..3ba2e9564b9a 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -43,8 +43,6 @@
43#include <scsi/scsi_cmnd.h> 43#include <scsi/scsi_cmnd.h>
44#include <target/target_core_base.h> 44#include <target/target_core_base.h>
45#include <target/target_core_fabric.h> 45#include <target/target_core_fabric.h>
46#include <target/target_core_fabric_configfs.h>
47#include <target/configfs_macros.h>
48 46
49#include "qla_def.h" 47#include "qla_def.h"
50#include "qla_target.h" 48#include "qla_target.h"
@@ -729,23 +727,23 @@ static int tcm_qla2xxx_init_nodeacl(struct se_node_acl *se_nacl,
729 727
730#define DEF_QLA_TPG_ATTRIB(name) \ 728#define DEF_QLA_TPG_ATTRIB(name) \
731 \ 729 \
732static ssize_t tcm_qla2xxx_tpg_attrib_show_##name( \ 730static ssize_t tcm_qla2xxx_tpg_attrib_##name##_show( \
733 struct se_portal_group *se_tpg, \ 731 struct config_item *item, char *page) \
734 char *page) \
735{ \ 732{ \
733 struct se_portal_group *se_tpg = attrib_to_tpg(item); \
736 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \ 734 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \
737 struct tcm_qla2xxx_tpg, se_tpg); \ 735 struct tcm_qla2xxx_tpg, se_tpg); \
738 \ 736 \
739 return sprintf(page, "%u\n", tpg->tpg_attrib.name); \ 737 return sprintf(page, "%u\n", tpg->tpg_attrib.name); \
740} \ 738} \
741 \ 739 \
742static ssize_t tcm_qla2xxx_tpg_attrib_store_##name( \ 740static ssize_t tcm_qla2xxx_tpg_attrib_##name##_store( \
743 struct se_portal_group *se_tpg, \ 741 struct config_item *item, const char *page, size_t count) \
744 const char *page, \
745 size_t count) \
746{ \ 742{ \
743 struct se_portal_group *se_tpg = attrib_to_tpg(item); \
747 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \ 744 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, \
748 struct tcm_qla2xxx_tpg, se_tpg); \ 745 struct tcm_qla2xxx_tpg, se_tpg); \
746 struct tcm_qla2xxx_tpg_attrib *a = &tpg->tpg_attrib; \
749 unsigned long val; \ 747 unsigned long val; \
750 int ret; \ 748 int ret; \
751 \ 749 \
@@ -755,81 +753,39 @@ static ssize_t tcm_qla2xxx_tpg_attrib_store_##name( \
755 " ret: %d\n", ret); \ 753 " ret: %d\n", ret); \
756 return -EINVAL; \ 754 return -EINVAL; \
757 } \ 755 } \
758 ret = tcm_qla2xxx_set_attrib_##name(tpg, val); \
759 \
760 return (!ret) ? count : -EINVAL; \
761}
762
763#define DEF_QLA_TPG_ATTR_BOOL(_name) \
764 \
765static int tcm_qla2xxx_set_attrib_##_name( \
766 struct tcm_qla2xxx_tpg *tpg, \
767 unsigned long val) \
768{ \
769 struct tcm_qla2xxx_tpg_attrib *a = &tpg->tpg_attrib; \
770 \ 756 \
771 if ((val != 0) && (val != 1)) { \ 757 if ((val != 0) && (val != 1)) { \
772 pr_err("Illegal boolean value %lu\n", val); \ 758 pr_err("Illegal boolean value %lu\n", val); \
773 return -EINVAL; \ 759 return -EINVAL; \
774 } \ 760 } \
775 \ 761 \
776 a->_name = val; \ 762 a->name = val; \
777 return 0; \ 763 \
778} 764 return count; \
779 765} \
780#define QLA_TPG_ATTR(_name, _mode) \ 766CONFIGFS_ATTR(tcm_qla2xxx_tpg_attrib_, name)
781 TF_TPG_ATTRIB_ATTR(tcm_qla2xxx, _name, _mode);
782 767
783/*
784 * Define tcm_qla2xxx_tpg_attrib_s_generate_node_acls
785 */
786DEF_QLA_TPG_ATTR_BOOL(generate_node_acls);
787DEF_QLA_TPG_ATTRIB(generate_node_acls); 768DEF_QLA_TPG_ATTRIB(generate_node_acls);
788QLA_TPG_ATTR(generate_node_acls, S_IRUGO | S_IWUSR);
789
790/*
791 Define tcm_qla2xxx_attrib_s_cache_dynamic_acls
792 */
793DEF_QLA_TPG_ATTR_BOOL(cache_dynamic_acls);
794DEF_QLA_TPG_ATTRIB(cache_dynamic_acls); 769DEF_QLA_TPG_ATTRIB(cache_dynamic_acls);
795QLA_TPG_ATTR(cache_dynamic_acls, S_IRUGO | S_IWUSR);
796
797/*
798 * Define tcm_qla2xxx_tpg_attrib_s_demo_mode_write_protect
799 */
800DEF_QLA_TPG_ATTR_BOOL(demo_mode_write_protect);
801DEF_QLA_TPG_ATTRIB(demo_mode_write_protect); 770DEF_QLA_TPG_ATTRIB(demo_mode_write_protect);
802QLA_TPG_ATTR(demo_mode_write_protect, S_IRUGO | S_IWUSR);
803
804/*
805 * Define tcm_qla2xxx_tpg_attrib_s_prod_mode_write_protect
806 */
807DEF_QLA_TPG_ATTR_BOOL(prod_mode_write_protect);
808DEF_QLA_TPG_ATTRIB(prod_mode_write_protect); 771DEF_QLA_TPG_ATTRIB(prod_mode_write_protect);
809QLA_TPG_ATTR(prod_mode_write_protect, S_IRUGO | S_IWUSR);
810
811/*
812 * Define tcm_qla2xxx_tpg_attrib_s_demo_mode_login_only
813 */
814DEF_QLA_TPG_ATTR_BOOL(demo_mode_login_only);
815DEF_QLA_TPG_ATTRIB(demo_mode_login_only); 772DEF_QLA_TPG_ATTRIB(demo_mode_login_only);
816QLA_TPG_ATTR(demo_mode_login_only, S_IRUGO | S_IWUSR);
817 773
818static struct configfs_attribute *tcm_qla2xxx_tpg_attrib_attrs[] = { 774static struct configfs_attribute *tcm_qla2xxx_tpg_attrib_attrs[] = {
819 &tcm_qla2xxx_tpg_attrib_generate_node_acls.attr, 775 &tcm_qla2xxx_tpg_attrib_attr_generate_node_acls,
820 &tcm_qla2xxx_tpg_attrib_cache_dynamic_acls.attr, 776 &tcm_qla2xxx_tpg_attrib_attr_cache_dynamic_acls,
821 &tcm_qla2xxx_tpg_attrib_demo_mode_write_protect.attr, 777 &tcm_qla2xxx_tpg_attrib_attr_demo_mode_write_protect,
822 &tcm_qla2xxx_tpg_attrib_prod_mode_write_protect.attr, 778 &tcm_qla2xxx_tpg_attrib_attr_prod_mode_write_protect,
823 &tcm_qla2xxx_tpg_attrib_demo_mode_login_only.attr, 779 &tcm_qla2xxx_tpg_attrib_attr_demo_mode_login_only,
824 NULL, 780 NULL,
825}; 781};
826 782
827/* End items for tcm_qla2xxx_tpg_attrib_cit */ 783/* End items for tcm_qla2xxx_tpg_attrib_cit */
828 784
829static ssize_t tcm_qla2xxx_tpg_show_enable( 785static ssize_t tcm_qla2xxx_tpg_enable_show(struct config_item *item,
830 struct se_portal_group *se_tpg, 786 char *page)
831 char *page)
832{ 787{
788 struct se_portal_group *se_tpg = to_tpg(item);
833 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 789 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
834 struct tcm_qla2xxx_tpg, se_tpg); 790 struct tcm_qla2xxx_tpg, se_tpg);
835 791
@@ -865,11 +821,10 @@ static void tcm_qla2xxx_undepend_tpg(struct work_struct *work)
865 complete(&base_tpg->tpg_base_comp); 821 complete(&base_tpg->tpg_base_comp);
866} 822}
867 823
868static ssize_t tcm_qla2xxx_tpg_store_enable( 824static ssize_t tcm_qla2xxx_tpg_enable_store(struct config_item *item,
869 struct se_portal_group *se_tpg, 825 const char *page, size_t count)
870 const char *page,
871 size_t count)
872{ 826{
827 struct se_portal_group *se_tpg = to_tpg(item);
873 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 828 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
874 struct tcm_qla2xxx_tpg, se_tpg); 829 struct tcm_qla2xxx_tpg, se_tpg);
875 unsigned long op; 830 unsigned long op;
@@ -909,22 +864,16 @@ static ssize_t tcm_qla2xxx_tpg_store_enable(
909 return count; 864 return count;
910} 865}
911 866
912TF_TPG_BASE_ATTR(tcm_qla2xxx, enable, S_IRUGO | S_IWUSR); 867static ssize_t tcm_qla2xxx_tpg_dynamic_sessions_show(struct config_item *item,
913 868 char *page)
914static ssize_t tcm_qla2xxx_tpg_show_dynamic_sessions(
915 struct se_portal_group *se_tpg,
916 char *page)
917{ 869{
918 return target_show_dynamic_sessions(se_tpg, page); 870 return target_show_dynamic_sessions(to_tpg(item), page);
919} 871}
920 872
921TF_TPG_BASE_ATTR_RO(tcm_qla2xxx, dynamic_sessions); 873static ssize_t tcm_qla2xxx_tpg_fabric_prot_type_store(struct config_item *item,
922 874 const char *page, size_t count)
923static ssize_t tcm_qla2xxx_tpg_store_fabric_prot_type(
924 struct se_portal_group *se_tpg,
925 const char *page,
926 size_t count)
927{ 875{
876 struct se_portal_group *se_tpg = to_tpg(item);
928 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 877 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
929 struct tcm_qla2xxx_tpg, se_tpg); 878 struct tcm_qla2xxx_tpg, se_tpg);
930 unsigned long val; 879 unsigned long val;
@@ -943,21 +892,24 @@ static ssize_t tcm_qla2xxx_tpg_store_fabric_prot_type(
943 return count; 892 return count;
944} 893}
945 894
946static ssize_t tcm_qla2xxx_tpg_show_fabric_prot_type( 895static ssize_t tcm_qla2xxx_tpg_fabric_prot_type_show(struct config_item *item,
947 struct se_portal_group *se_tpg, 896 char *page)
948 char *page)
949{ 897{
898 struct se_portal_group *se_tpg = to_tpg(item);
950 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 899 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
951 struct tcm_qla2xxx_tpg, se_tpg); 900 struct tcm_qla2xxx_tpg, se_tpg);
952 901
953 return sprintf(page, "%d\n", tpg->tpg_attrib.fabric_prot_type); 902 return sprintf(page, "%d\n", tpg->tpg_attrib.fabric_prot_type);
954} 903}
955TF_TPG_BASE_ATTR(tcm_qla2xxx, fabric_prot_type, S_IRUGO | S_IWUSR); 904
905CONFIGFS_ATTR_WO(tcm_qla2xxx_tpg_, enable);
906CONFIGFS_ATTR_RO(tcm_qla2xxx_tpg_, dynamic_sessions);
907CONFIGFS_ATTR(tcm_qla2xxx_tpg_, fabric_prot_type);
956 908
957static struct configfs_attribute *tcm_qla2xxx_tpg_attrs[] = { 909static struct configfs_attribute *tcm_qla2xxx_tpg_attrs[] = {
958 &tcm_qla2xxx_tpg_enable.attr, 910 &tcm_qla2xxx_tpg_attr_enable,
959 &tcm_qla2xxx_tpg_dynamic_sessions.attr, 911 &tcm_qla2xxx_tpg_attr_dynamic_sessions,
960 &tcm_qla2xxx_tpg_fabric_prot_type.attr, 912 &tcm_qla2xxx_tpg_attr_fabric_prot_type,
961 NULL, 913 NULL,
962}; 914};
963 915
@@ -1030,18 +982,16 @@ static void tcm_qla2xxx_drop_tpg(struct se_portal_group *se_tpg)
1030 kfree(tpg); 982 kfree(tpg);
1031} 983}
1032 984
1033static ssize_t tcm_qla2xxx_npiv_tpg_show_enable( 985static ssize_t tcm_qla2xxx_npiv_tpg_enable_show(struct config_item *item,
1034 struct se_portal_group *se_tpg, 986 char *page)
1035 char *page)
1036{ 987{
1037 return tcm_qla2xxx_tpg_show_enable(se_tpg, page); 988 return tcm_qla2xxx_tpg_enable_show(item, page);
1038} 989}
1039 990
1040static ssize_t tcm_qla2xxx_npiv_tpg_store_enable( 991static ssize_t tcm_qla2xxx_npiv_tpg_enable_store(struct config_item *item,
1041 struct se_portal_group *se_tpg, 992 const char *page, size_t count)
1042 const char *page,
1043 size_t count)
1044{ 993{
994 struct se_portal_group *se_tpg = to_tpg(item);
1045 struct se_wwn *se_wwn = se_tpg->se_tpg_wwn; 995 struct se_wwn *se_wwn = se_tpg->se_tpg_wwn;
1046 struct tcm_qla2xxx_lport *lport = container_of(se_wwn, 996 struct tcm_qla2xxx_lport *lport = container_of(se_wwn,
1047 struct tcm_qla2xxx_lport, lport_wwn); 997 struct tcm_qla2xxx_lport, lport_wwn);
@@ -1077,10 +1027,10 @@ static ssize_t tcm_qla2xxx_npiv_tpg_store_enable(
1077 return count; 1027 return count;
1078} 1028}
1079 1029
1080TF_TPG_BASE_ATTR(tcm_qla2xxx_npiv, enable, S_IRUGO | S_IWUSR); 1030CONFIGFS_ATTR(tcm_qla2xxx_npiv_tpg_, enable);
1081 1031
1082static struct configfs_attribute *tcm_qla2xxx_npiv_tpg_attrs[] = { 1032static struct configfs_attribute *tcm_qla2xxx_npiv_tpg_attrs[] = {
1083 &tcm_qla2xxx_npiv_tpg_enable.attr, 1033 &tcm_qla2xxx_npiv_tpg_attr_enable,
1084 NULL, 1034 NULL,
1085}; 1035};
1086 1036
@@ -1783,9 +1733,8 @@ static void tcm_qla2xxx_npiv_drop_lport(struct se_wwn *wwn)
1783} 1733}
1784 1734
1785 1735
1786static ssize_t tcm_qla2xxx_wwn_show_attr_version( 1736static ssize_t tcm_qla2xxx_wwn_version_show(struct config_item *item,
1787 struct target_fabric_configfs *tf, 1737 char *page)
1788 char *page)
1789{ 1738{
1790 return sprintf(page, 1739 return sprintf(page,
1791 "TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on " 1740 "TCM QLOGIC QLA2XXX NPIV capable fabric module %s on %s/%s on "
@@ -1793,10 +1742,10 @@ static ssize_t tcm_qla2xxx_wwn_show_attr_version(
1793 utsname()->machine); 1742 utsname()->machine);
1794} 1743}
1795 1744
1796TF_WWN_ATTR_RO(tcm_qla2xxx, version); 1745CONFIGFS_ATTR_RO(tcm_qla2xxx_wwn_, version);
1797 1746
1798static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = { 1747static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = {
1799 &tcm_qla2xxx_wwn_version.attr, 1748 &tcm_qla2xxx_wwn_attr_version,
1800 NULL, 1749 NULL,
1801}; 1750};
1802 1751