Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: target: qla2xxx: Replace enable attr with ops.enable

Remove tpg/enable attribute. Add fabric ops enable_tpg implementation
instead.

Link: https://lore.kernel.org/r/20210910084133.17956-4-d.bogdanov@yadro.com
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Dmitry Bogdanov and committed by
Martin K. Petersen
cb8717a7 382731ec

+12 -61
+12 -61
drivers/scsi/qla2xxx/tcm_qla2xxx.c
··· 915 915 916 916 /* End items for tcm_qla2xxx_tpg_attrib_cit */ 917 917 918 - static ssize_t tcm_qla2xxx_tpg_enable_show(struct config_item *item, 919 - char *page) 918 + static int tcm_qla2xxx_enable_tpg(struct se_portal_group *se_tpg, 919 + bool enable) 920 920 { 921 - struct se_portal_group *se_tpg = to_tpg(item); 922 - struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 923 - struct tcm_qla2xxx_tpg, se_tpg); 924 - 925 - return snprintf(page, PAGE_SIZE, "%d\n", 926 - atomic_read(&tpg->lport_tpg_enabled)); 927 - } 928 - 929 - static ssize_t tcm_qla2xxx_tpg_enable_store(struct config_item *item, 930 - const char *page, size_t count) 931 - { 932 - struct se_portal_group *se_tpg = to_tpg(item); 933 921 struct se_wwn *se_wwn = se_tpg->se_tpg_wwn; 934 922 struct tcm_qla2xxx_lport *lport = container_of(se_wwn, 935 923 struct tcm_qla2xxx_lport, lport_wwn); 936 924 struct scsi_qla_host *vha = lport->qla_vha; 937 925 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 938 926 struct tcm_qla2xxx_tpg, se_tpg); 939 - unsigned long op; 940 - int rc; 941 927 942 - rc = kstrtoul(page, 0, &op); 943 - if (rc < 0) { 944 - pr_err("kstrtoul() returned %d\n", rc); 945 - return -EINVAL; 946 - } 947 - if ((op != 1) && (op != 0)) { 948 - pr_err("Illegal value for tpg_enable: %lu\n", op); 949 - return -EINVAL; 950 - } 951 - if (op) { 928 + if (enable) { 952 929 if (atomic_read(&tpg->lport_tpg_enabled)) 953 930 return -EEXIST; 954 931 ··· 933 956 qlt_enable_vha(vha); 934 957 } else { 935 958 if (!atomic_read(&tpg->lport_tpg_enabled)) 936 - return count; 959 + return 0; 937 960 938 961 atomic_set(&tpg->lport_tpg_enabled, 0); 939 962 qlt_stop_phase1(vha->vha_tgt.qla_tgt); 940 963 qlt_stop_phase2(vha->vha_tgt.qla_tgt); 941 964 } 942 965 943 - return count; 966 + return 0; 944 967 } 945 968 946 969 static ssize_t tcm_qla2xxx_tpg_dynamic_sessions_show(struct config_item *item, ··· 981 1004 return sprintf(page, "%d\n", tpg->tpg_attrib.fabric_prot_type); 982 1005 } 983 1006 984 - CONFIGFS_ATTR(tcm_qla2xxx_tpg_, enable); 985 1007 CONFIGFS_ATTR_RO(tcm_qla2xxx_tpg_, dynamic_sessions); 986 1008 CONFIGFS_ATTR(tcm_qla2xxx_tpg_, fabric_prot_type); 987 1009 988 1010 static struct configfs_attribute *tcm_qla2xxx_tpg_attrs[] = { 989 - &tcm_qla2xxx_tpg_attr_enable, 990 1011 &tcm_qla2xxx_tpg_attr_dynamic_sessions, 991 1012 &tcm_qla2xxx_tpg_attr_fabric_prot_type, 992 1013 NULL, ··· 1058 1083 kfree(tpg); 1059 1084 } 1060 1085 1061 - static ssize_t tcm_qla2xxx_npiv_tpg_enable_show(struct config_item *item, 1062 - char *page) 1086 + static int tcm_qla2xxx_npiv_enable_tpg(struct se_portal_group *se_tpg, 1087 + bool enable) 1063 1088 { 1064 - return tcm_qla2xxx_tpg_enable_show(item, page); 1065 - } 1066 - 1067 - static ssize_t tcm_qla2xxx_npiv_tpg_enable_store(struct config_item *item, 1068 - const char *page, size_t count) 1069 - { 1070 - struct se_portal_group *se_tpg = to_tpg(item); 1071 1089 struct se_wwn *se_wwn = se_tpg->se_tpg_wwn; 1072 1090 struct tcm_qla2xxx_lport *lport = container_of(se_wwn, 1073 1091 struct tcm_qla2xxx_lport, lport_wwn); 1074 1092 struct scsi_qla_host *vha = lport->qla_vha; 1075 1093 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 1076 1094 struct tcm_qla2xxx_tpg, se_tpg); 1077 - unsigned long op; 1078 - int rc; 1079 1095 1080 - rc = kstrtoul(page, 0, &op); 1081 - if (rc < 0) { 1082 - pr_err("kstrtoul() returned %d\n", rc); 1083 - return -EINVAL; 1084 - } 1085 - if ((op != 1) && (op != 0)) { 1086 - pr_err("Illegal value for tpg_enable: %lu\n", op); 1087 - return -EINVAL; 1088 - } 1089 - if (op) { 1096 + if (enable) { 1090 1097 if (atomic_read(&tpg->lport_tpg_enabled)) 1091 1098 return -EEXIST; 1092 1099 ··· 1076 1119 qlt_enable_vha(vha); 1077 1120 } else { 1078 1121 if (!atomic_read(&tpg->lport_tpg_enabled)) 1079 - return count; 1122 + return 0; 1080 1123 1081 1124 atomic_set(&tpg->lport_tpg_enabled, 0); 1082 1125 qlt_stop_phase1(vha->vha_tgt.qla_tgt); 1083 1126 qlt_stop_phase2(vha->vha_tgt.qla_tgt); 1084 1127 } 1085 1128 1086 - return count; 1129 + return 0; 1087 1130 } 1088 - 1089 - CONFIGFS_ATTR(tcm_qla2xxx_npiv_tpg_, enable); 1090 - 1091 - static struct configfs_attribute *tcm_qla2xxx_npiv_tpg_attrs[] = { 1092 - &tcm_qla2xxx_npiv_tpg_attr_enable, 1093 - NULL, 1094 - }; 1095 1131 1096 1132 static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg(struct se_wwn *wwn, 1097 1133 const char *name) ··· 1828 1878 .fabric_make_wwn = tcm_qla2xxx_make_lport, 1829 1879 .fabric_drop_wwn = tcm_qla2xxx_drop_lport, 1830 1880 .fabric_make_tpg = tcm_qla2xxx_make_tpg, 1881 + .fabric_enable_tpg = tcm_qla2xxx_enable_tpg, 1831 1882 .fabric_drop_tpg = tcm_qla2xxx_drop_tpg, 1832 1883 .fabric_init_nodeacl = tcm_qla2xxx_init_nodeacl, 1833 1884 ··· 1869 1918 .fabric_make_wwn = tcm_qla2xxx_npiv_make_lport, 1870 1919 .fabric_drop_wwn = tcm_qla2xxx_npiv_drop_lport, 1871 1920 .fabric_make_tpg = tcm_qla2xxx_npiv_make_tpg, 1921 + .fabric_enable_tpg = tcm_qla2xxx_npiv_enable_tpg, 1872 1922 .fabric_drop_tpg = tcm_qla2xxx_drop_tpg, 1873 1923 .fabric_init_nodeacl = tcm_qla2xxx_init_nodeacl, 1874 1924 1875 1925 .tfc_wwn_attrs = tcm_qla2xxx_wwn_attrs, 1876 - .tfc_tpg_base_attrs = tcm_qla2xxx_npiv_tpg_attrs, 1877 1926 }; 1878 1927 1879 1928 static int tcm_qla2xxx_register_configfs(void)