From: Yi Wang <wang.yi59@zte.com.cn>
To: mst@redhat.com
Cc: sgarzare@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org,
virtualization@lists.linux-foundation.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
xue.zhihong@zte.com.cn, wang.yi59@zte.com.cn,
wang.liang82@zte.com.cn, Zhang Min <zhang.min9@zte.com.cn>
Subject: [PATCH v2] vdpa: regist vhost-vdpa dev class
Date: Fri, 24 Dec 2021 15:04:04 +0800 [thread overview]
Message-ID: <20211224070404.54840-1-wang.yi59@zte.com.cn> (raw)
From: Zhang Min <zhang.min9@zte.com.cn>
Some applications like kata-containers need to acquire MAJOR/MINOR/DEVNAME
for devInfo [1], so regist vhost-vdpa dev class to expose uevent.
1. https://github.com/kata-containers/kata-containers/blob/main/src/runtime/virtcontainers/device/config/config.go
Signed-off-by: Zhang Min <zhang.min9@zte.com.cn>
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
---
v2: remove redundant vhost_vdpa_class reset and pr_warn, adjust location
of *vhost_vdpa_class impl and class_destroy.
drivers/vhost/vdpa.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index e3c4f059b21a..55e966c508c8 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -53,6 +53,7 @@ struct vhost_vdpa {
static DEFINE_IDA(vhost_vdpa_ida);
static dev_t vhost_vdpa_major;
+static struct class *vhost_vdpa_class;
static void handle_vq_kick(struct vhost_work *work)
{
@@ -1140,6 +1141,7 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa)
v->dev.release = vhost_vdpa_release_dev;
v->dev.parent = &vdpa->dev;
v->dev.devt = MKDEV(MAJOR(vhost_vdpa_major), minor);
+ v->dev.class = vhost_vdpa_class;
v->vqs = kmalloc_array(v->nvqs, sizeof(struct vhost_virtqueue),
GFP_KERNEL);
if (!v->vqs) {
@@ -1197,6 +1199,10 @@ static int __init vhost_vdpa_init(void)
{
int r;
+ vhost_vdpa_class = class_create(THIS_MODULE, "vhost-vdpa");
+ if (IS_ERR(vhost_vdpa_class))
+ return PTR_ERR(vhost_vdpa_class);
+
r = alloc_chrdev_region(&vhost_vdpa_major, 0, VHOST_VDPA_DEV_MAX,
"vhost-vdpa");
if (r)
@@ -1211,6 +1217,7 @@ static int __init vhost_vdpa_init(void)
err_vdpa_register_driver:
unregister_chrdev_region(vhost_vdpa_major, VHOST_VDPA_DEV_MAX);
err_alloc_chrdev:
+ class_destroy(vhost_vdpa_class);
return r;
}
module_init(vhost_vdpa_init);
@@ -1219,6 +1226,7 @@ static void __exit vhost_vdpa_exit(void)
{
vdpa_unregister_driver(&vhost_vdpa_driver);
unregister_chrdev_region(vhost_vdpa_major, VHOST_VDPA_DEV_MAX);
+ class_destroy(vhost_vdpa_class);
}
module_exit(vhost_vdpa_exit);
--
2.27.0
next reply other threads:[~2021-12-24 7:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-24 7:04 Yi Wang [this message]
2022-01-04 3:44 ` Jason Wang
2022-01-11 7:09 ` wang.yi59
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=20211224070404.54840-1-wang.yi59@zte.com.cn \
--to=wang.yi59@zte.com.cn \
--cc=jasowang@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=sgarzare@redhat.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=wang.liang82@zte.com.cn \
--cc=xue.zhihong@zte.com.cn \
--cc=zhang.min9@zte.com.cn \
/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
all inboxes | Powered by JetHome®