From: jsmart2021@gmail.com (James Smart)
Subject: [PATCH v2 1/2] nvme_fc: create fc class and transport device
Date: Sat, 13 May 2017 12:05:58 -0700 [thread overview]
Message-ID: <20170513190559.25484-2-jsmart2021@gmail.com> (raw)
In-Reply-To: <20170513190559.25484-1-jsmart2021@gmail.com>
Added a new fc class, and a device node for the nvme_fc transport
under it. I expect the fc class will eventually be the location the
SCSI and FC transports merge in the future.
Signed-off-by: James Smart <james.smart at broadcom.com>
---
v2: cut on nvme-4.12
drivers/nvme/host/fc.c | 35 +++++++++++++++++++++++++++++++----
1 file changed, 31 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 8dd06e97736d..4ae99d546378 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -217,6 +217,9 @@ static DEFINE_IDA(nvme_fc_ctrl_cnt);
static struct workqueue_struct *nvme_fc_wq;
+static struct class *fc_class;
+static struct device *nvmefc_device;
+
/* *********************** FC-NVME Port Management ************************ */
@@ -2959,17 +2962,38 @@ static int __init nvme_fc_init_module(void)
{
int ret;
+ fc_class = class_create(THIS_MODULE, "fc");
+ if (IS_ERR(fc_class)) {
+ pr_err("couldn't register class fc\n");
+ return PTR_ERR(fc_class);
+ }
+
+ nvmefc_device = device_create(fc_class, NULL, MKDEV(0, 0), NULL,
+ "nvme_fc_transport");
+ if (IS_ERR(nvmefc_device)) {
+ pr_err("couldn't create nvme_fc device!\n");
+ ret = PTR_ERR(nvmefc_device);
+ goto out_destroy_class;
+ }
+
nvme_fc_wq = create_workqueue("nvme_fc_wq");
- if (!nvme_fc_wq)
- return -ENOMEM;
+ if (!nvme_fc_wq) {
+ ret = -ENOMEM;
+ goto out_destroy_device;
+ }
ret = nvmf_register_transport(&nvme_fc_transport);
if (ret)
- goto err;
+ goto out_destroy_workqueue;
return 0;
-err:
+
+out_destroy_workqueue:
destroy_workqueue(nvme_fc_wq);
+out_destroy_device:
+ device_destroy(fc_class, MKDEV(0, 0));
+out_destroy_class:
+ class_destroy(fc_class);
return ret;
}
@@ -2985,6 +3009,9 @@ static void __exit nvme_fc_exit_module(void)
ida_destroy(&nvme_fc_local_port_cnt);
ida_destroy(&nvme_fc_ctrl_cnt);
+
+ device_destroy(fc_class, MKDEV(0, 0));
+ class_destroy(fc_class);
}
module_init(nvme_fc_init_module);
--
2.11.0
next prev parent reply other threads:[~2017-05-13 19:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-13 19:05 [PATCH v2 0/2] nvme_fc: add uevent to allow dynamic connects James Smart
2017-05-13 19:05 ` James Smart [this message]
2017-05-30 8:36 ` [PATCH v2 1/2] nvme_fc: create fc class and transport device Christoph Hellwig
2017-05-13 19:05 ` [PATCH v2 2/2] nvme_fc: add uevent for auto-connect James Smart
2017-05-30 8:39 ` Christoph Hellwig
2017-05-22 23:56 ` [PATCH v2 0/2] nvme_fc: add uevent to allow dynamic connects James Smart
2017-05-23 7:17 ` Christoph Hellwig
2017-05-23 16:02 ` James Smart
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=20170513190559.25484-2-jsmart2021@gmail.com \
--to=jsmart2021@gmail.com \
/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