From: Dmitry Bogdanov <d.bogdanov@yadro.com>
To: Martin Petersen <martin.petersen@oracle.com>,
<target-devel@vger.kernel.org>
Cc: <linux-scsi@vger.kernel.org>, <linux@yadro.com>,
Nilesh Javali <njavali@marvell.com>, Chris Boot <bootc@bootc.net>,
Bart Van Assche <bvanassche@acm.org>,
Michael Cyr <mikecyr@linux.ibm.com>,
Felipe Balbi <balbi@kernel.org>,
Dmitry Bogdanov <d.bogdanov@yadro.com>,
Roman Bolshakov <r.bolshakov@yadro.com>
Subject: [PATCH v2 7/7] target: usb: replace enable attr to ops.enable
Date: Mon, 22 Mar 2021 11:05:54 +0300 [thread overview]
Message-ID: <20210322080554.7611-8-d.bogdanov@yadro.com> (raw)
In-Reply-To: <20210322080554.7611-1-d.bogdanov@yadro.com>
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>
---
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 410fa89eae8f..6cfa5362bc8d 100644
--- a/drivers/usb/gadget/function/f_tcm.c
+++ b/drivers/usb/gadget/function/f_tcm.c
@@ -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,
--
2.25.1
next prev parent reply other threads:[~2021-03-22 8:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 8:05 [PATCH v2 0/7] target: make tpg/enable attribute Dmitry Bogdanov
2021-03-22 8:05 ` [PATCH v2 1/7] target: core: add common " Dmitry Bogdanov
2021-03-22 17:35 ` Mike Christie
2021-03-22 17:55 ` Dmitriy Bogdanov
2021-03-24 21:51 ` Konstantin Shelekhin
2021-03-22 8:05 ` [PATCH v2 2/7] target: iscsi: replace enable attr to ops.enable Dmitry Bogdanov
2021-03-22 17:43 ` Mike Christie
2021-03-22 8:05 ` [PATCH v2 3/7] target: qla2xx: " Dmitry Bogdanov
2021-03-22 8:05 ` [PATCH v2 4/7] target: sbp: " Dmitry Bogdanov
2021-03-22 8:05 ` [PATCH v2 5/7] target: srpt " Dmitry Bogdanov
2021-03-22 8:05 ` [PATCH v2 6/7] target: ibm_vscsi: " Dmitry Bogdanov
2021-03-22 8:05 ` Dmitry Bogdanov [this message]
2021-03-22 14:49 ` [PATCH v2 0/7] target: make tpg/enable attribute Himanshu Madhani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210322080554.7611-8-d.bogdanov@yadro.com \
--to=d.bogdanov@yadro.com \
--cc=balbi@kernel.org \
--cc=bootc@bootc.net \
--cc=bvanassche@acm.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux@yadro.com \
--cc=martin.petersen@oracle.com \
--cc=mikecyr@linux.ibm.com \
--cc=njavali@marvell.com \
--cc=r.bolshakov@yadro.com \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).