scsi: target: usb: 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-8-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>
This commit is contained in:
Dmitry Bogdanov 2021-09-10 11:41:33 +03:00 committed by Martin K. Petersen
parent d7e2932bba
commit 5384ee089d
1 changed files with 6 additions and 25 deletions

View File

@ -1495,42 +1495,24 @@ static struct configfs_attribute *usbg_wwn_attrs[] = {
NULL,
};
static ssize_t tcm_usbg_tpg_enable_show(struct config_item *item, char *page)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg);
return snprintf(page, PAGE_SIZE, "%u\n", tpg->gadget_connect);
}
static int usbg_attach(struct usbg_tpg *);
static void usbg_detach(struct usbg_tpg *);
static ssize_t tcm_usbg_tpg_enable_store(struct config_item *item,
const char *page, size_t count)
static int usbg_enable_tpg(struct se_portal_group *se_tpg, bool enable)
{
struct se_portal_group *se_tpg = to_tpg(item);
struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg);
bool op;
ssize_t ret;
int ret = 0;
ret = strtobool(page, &op);
if (ret)
return ret;
if ((op && tpg->gadget_connect) || (!op && !tpg->gadget_connect))
return -EINVAL;
if (op)
if (enable)
ret = usbg_attach(tpg);
else
usbg_detach(tpg);
if (ret)
return ret;
tpg->gadget_connect = op;
tpg->gadget_connect = enable;
return count;
return 0;
}
static ssize_t tcm_usbg_tpg_nexus_show(struct config_item *item, char *page)
@ -1673,11 +1655,9 @@ static ssize_t tcm_usbg_tpg_nexus_store(struct config_item *item,
return count;
}
CONFIGFS_ATTR(tcm_usbg_tpg_, enable);
CONFIGFS_ATTR(tcm_usbg_tpg_, nexus);
static struct configfs_attribute *usbg_base_attrs[] = {
&tcm_usbg_tpg_attr_enable,
&tcm_usbg_tpg_attr_nexus,
NULL,
};
@ -1730,6 +1710,7 @@ static const struct target_core_fabric_ops usbg_ops = {
.fabric_make_wwn = usbg_make_tport,
.fabric_drop_wwn = usbg_drop_tport,
.fabric_make_tpg = usbg_make_tpg,
.fabric_enable_tpg = usbg_enable_tpg,
.fabric_drop_tpg = usbg_drop_tpg,
.fabric_post_link = usbg_port_link,
.fabric_pre_unlink = usbg_port_unlink,