From: Sjur Brændeland <sjur.brandel...@stericsson.com>

Add information so rproc-serial can be easily recogniced
from user space. Add the following information to uevent:
DRIVER=virtio_console|virtio_rproc_serial
INTERFACE=grand-parent/parent/name

Signed-off-by: Sjur Brændeland <sjur.brandel...@stericsson.com>
---
Hi,

I need some way to identify the major/minor number for
the rproc-serial device, given the udev event. 
Review comments are welcomed.

Thanks,
Sjur

 drivers/char/virtio_console.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 031be0b..96c5ed9 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -2190,6 +2190,27 @@ static struct virtio_driver virtio_rproc_serial = {
        .remove =       virtcons_remove,
 };
 
+int class_virtio_ports_uevent(struct device *_dev, struct kobj_uevent_env *env)
+{
+       struct port *port = dev_get_drvdata(_dev);
+       struct device *dev;
+       int err;
+
+       if (!port || !port->portdev || !port->portdev->vdev)
+               return 0;
+
+       dev = &port->portdev->vdev->dev;
+       err = add_uevent_var(env, "DRIVER=%s", dev->driver->name);
+       if (err)
+               return err;
+
+       return add_uevent_var(env, "INTERFACE=%s/%s/%s",
+                             dev->parent->parent ?
+                                       dev_name(dev->parent->parent) : "",
+                             dev->parent ? dev_name(dev->parent) : "",
+                             dev_name(dev));
+}
+
 static int __init init(void)
 {
        int err;
@@ -2201,6 +2222,7 @@ static int __init init(void)
                return err;
        }
 
+       pdrvdata.class->dev_uevent = class_virtio_ports_uevent;
        pdrvdata.debugfs_dir = debugfs_create_dir("virtio-ports", NULL);
        if (!pdrvdata.debugfs_dir) {
                pr_warning("Error %ld creating debugfs dir for virtio-ports\n",
-- 
1.7.5.4

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Reply via email to