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

scsi: target: sbp: 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-5-d.bogdanov@yadro.com
Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
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
fb00af92 cb8717a7

+5 -25
+5 -25
drivers/target/sbp/sbp_target.c
··· 2125 2125 return count; 2126 2126 } 2127 2127 2128 - static ssize_t sbp_tpg_enable_show(struct config_item *item, char *page) 2128 + static int sbp_enable_tpg(struct se_portal_group *se_tpg, bool enable) 2129 2129 { 2130 - struct se_portal_group *se_tpg = to_tpg(item); 2131 2130 struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2132 2131 struct sbp_tport *tport = tpg->tport; 2133 - return sprintf(page, "%d\n", tport->enable); 2134 - } 2135 - 2136 - static ssize_t sbp_tpg_enable_store(struct config_item *item, 2137 - const char *page, size_t count) 2138 - { 2139 - struct se_portal_group *se_tpg = to_tpg(item); 2140 - struct sbp_tpg *tpg = container_of(se_tpg, struct sbp_tpg, se_tpg); 2141 - struct sbp_tport *tport = tpg->tport; 2142 - unsigned long val; 2143 2132 int ret; 2144 2133 2145 - if (kstrtoul(page, 0, &val) < 0) 2146 - return -EINVAL; 2147 - if ((val != 0) && (val != 1)) 2148 - return -EINVAL; 2149 - 2150 - if (tport->enable == val) 2151 - return count; 2152 - 2153 - if (val) { 2134 + if (enable) { 2154 2135 if (sbp_count_se_tpg_luns(&tpg->se_tpg) == 0) { 2155 2136 pr_err("Cannot enable a target with no LUNs!\n"); 2156 2137 return -EINVAL; ··· 2146 2165 spin_unlock_bh(&se_tpg->session_lock); 2147 2166 } 2148 2167 2149 - tport->enable = val; 2168 + tport->enable = enable; 2150 2169 2151 2170 ret = sbp_update_unit_directory(tport); 2152 2171 if (ret < 0) { ··· 2154 2173 return ret; 2155 2174 } 2156 2175 2157 - return count; 2176 + return 0; 2158 2177 } 2159 2178 2160 2179 CONFIGFS_ATTR(sbp_tpg_, directory_id); 2161 - CONFIGFS_ATTR(sbp_tpg_, enable); 2162 2180 2163 2181 static struct configfs_attribute *sbp_tpg_base_attrs[] = { 2164 2182 &sbp_tpg_attr_directory_id, 2165 - &sbp_tpg_attr_enable, 2166 2183 NULL, 2167 2184 }; 2168 2185 ··· 2298 2319 .fabric_make_wwn = sbp_make_tport, 2299 2320 .fabric_drop_wwn = sbp_drop_tport, 2300 2321 .fabric_make_tpg = sbp_make_tpg, 2322 + .fabric_enable_tpg = sbp_enable_tpg, 2301 2323 .fabric_drop_tpg = sbp_drop_tpg, 2302 2324 .fabric_post_link = sbp_post_link_lun, 2303 2325 .fabric_pre_unlink = sbp_pre_unlink_lun,