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:
parent
d7e2932bba
commit
5384ee089d
|
@ -1495,42 +1495,24 @@ static struct configfs_attribute *usbg_wwn_attrs[] = {
|
||||||
NULL,
|
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 int usbg_attach(struct usbg_tpg *);
|
||||||
static void usbg_detach(struct usbg_tpg *);
|
static void usbg_detach(struct usbg_tpg *);
|
||||||
|
|
||||||
static ssize_t tcm_usbg_tpg_enable_store(struct config_item *item,
|
static int usbg_enable_tpg(struct se_portal_group *se_tpg, bool enable)
|
||||||
const char *page, size_t count)
|
|
||||||
{
|
{
|
||||||
struct se_portal_group *se_tpg = to_tpg(item);
|
|
||||||
struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg);
|
struct usbg_tpg *tpg = container_of(se_tpg, struct usbg_tpg, se_tpg);
|
||||||
bool op;
|
int ret = 0;
|
||||||
ssize_t ret;
|
|
||||||
|
|
||||||
ret = strtobool(page, &op);
|
if (enable)
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
if ((op && tpg->gadget_connect) || (!op && !tpg->gadget_connect))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (op)
|
|
||||||
ret = usbg_attach(tpg);
|
ret = usbg_attach(tpg);
|
||||||
else
|
else
|
||||||
usbg_detach(tpg);
|
usbg_detach(tpg);
|
||||||
if (ret)
|
if (ret)
|
||||||
return 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)
|
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;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIGFS_ATTR(tcm_usbg_tpg_, enable);
|
|
||||||
CONFIGFS_ATTR(tcm_usbg_tpg_, nexus);
|
CONFIGFS_ATTR(tcm_usbg_tpg_, nexus);
|
||||||
|
|
||||||
static struct configfs_attribute *usbg_base_attrs[] = {
|
static struct configfs_attribute *usbg_base_attrs[] = {
|
||||||
&tcm_usbg_tpg_attr_enable,
|
|
||||||
&tcm_usbg_tpg_attr_nexus,
|
&tcm_usbg_tpg_attr_nexus,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
@ -1730,6 +1710,7 @@ static const struct target_core_fabric_ops usbg_ops = {
|
||||||
.fabric_make_wwn = usbg_make_tport,
|
.fabric_make_wwn = usbg_make_tport,
|
||||||
.fabric_drop_wwn = usbg_drop_tport,
|
.fabric_drop_wwn = usbg_drop_tport,
|
||||||
.fabric_make_tpg = usbg_make_tpg,
|
.fabric_make_tpg = usbg_make_tpg,
|
||||||
|
.fabric_enable_tpg = usbg_enable_tpg,
|
||||||
.fabric_drop_tpg = usbg_drop_tpg,
|
.fabric_drop_tpg = usbg_drop_tpg,
|
||||||
.fabric_post_link = usbg_port_link,
|
.fabric_post_link = usbg_port_link,
|
||||||
.fabric_pre_unlink = usbg_port_unlink,
|
.fabric_pre_unlink = usbg_port_unlink,
|
||||||
|
|
Loading…
Reference in New Issue