From 5384ee089d1f79b027bb62b0cfa729890ca71f8b Mon Sep 17 00:00:00 2001 From: Dmitry Bogdanov Date: Fri, 10 Sep 2021 11:41:33 +0300 Subject: [PATCH] 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 Reviewed-by: Mike Christie Signed-off-by: Dmitry Bogdanov Signed-off-by: Martin K. Petersen --- drivers/usb/gadget/function/f_tcm.c | 31 ++++++------------------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c index de161ee..8e17ac8 100644 --- a/drivers/usb/gadget/function/f_tcm.c +++ b/drivers/usb/gadget/function/f_tcm.c @@ -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; - - ret = strtobool(page, &op); - if (ret) - return ret; - - if ((op && tpg->gadget_connect) || (!op && !tpg->gadget_connect)) - return -EINVAL; + int ret = 0; - 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, -- 2.7.4