Skip to content
Permalink
Browse files
target: usb: replace enable attr to ops.enable
Remove tpg/enable attribute.
Add fabric ops enable_tpg implementation instead.

Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com>
  • Loading branch information
logost authored and intel-lab-lkp committed Apr 9, 2021
1 parent 76811cf commit 8e8e5665329866acf6ace2b3e349e4a0449b8044
Showing 1 changed file with 6 additions and 25 deletions.
@@ -1499,42 +1499,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;

ret = strtobool(page, &op);
if (ret)
return ret;

if ((op && tpg->gadget_connect) || (!op && !tpg->gadget_connect))
return -EINVAL;
int ret;

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)
@@ -1677,11 +1659,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,
};
@@ -1734,6 +1714,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,

0 comments on commit 8e8e566

Please sign in to comment.