lkml.org 
[lkml]   [2019]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] mdev: Send uevents around parent device registration
From
Date
This allows udev to trigger rules when a parent device is registered
or unregistered from mdev.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
drivers/vfio/mdev/mdev_core.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/vfio/mdev/mdev_core.c b/drivers/vfio/mdev/mdev_core.c
index ae23151442cb..ecec2a3b13cb 100644
--- a/drivers/vfio/mdev/mdev_core.c
+++ b/drivers/vfio/mdev/mdev_core.c
@@ -146,6 +146,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
{
int ret;
struct mdev_parent *parent;
+ char *env_string = "MDEV_STATE=registered";
+ char *envp[] = { env_string, NULL };

/* check for mandatory ops */
if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups)
@@ -196,7 +198,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
list_add(&parent->next, &parent_list);
mutex_unlock(&parent_list_lock);

- dev_info(dev, "MDEV: Registered\n");
+ kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
+
return 0;

add_dev_err:
@@ -220,6 +223,8 @@ EXPORT_SYMBOL(mdev_register_device);
void mdev_unregister_device(struct device *dev)
{
struct mdev_parent *parent;
+ char *env_string = "MDEV_STATE=unregistered";
+ char *envp[] = { env_string, NULL };

mutex_lock(&parent_list_lock);
parent = __find_parent_device(dev);
@@ -228,7 +233,6 @@ void mdev_unregister_device(struct device *dev)
mutex_unlock(&parent_list_lock);
return;
}
- dev_info(dev, "MDEV: Unregistering\n");

list_del(&parent->next);
mutex_unlock(&parent_list_lock);
@@ -243,6 +247,8 @@ void mdev_unregister_device(struct device *dev)
up_write(&parent->unreg_sem);

mdev_put_parent(parent);
+
+ kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
}
EXPORT_SYMBOL(mdev_unregister_device);

\
 
 \ /
  Last update: 2019-06-26 16:28    [W:0.084 / U:21.692 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site