Commit 1e4d09d2 authored by Alex Williamson's avatar Alex Williamson

mdev: Send uevents around parent device registration

This allows udev to trigger rules when a parent device is registered
or unregistered from mdev.
Reviewed-by: default avatarCornelia Huck <cohuck@redhat.com>
Reviewed-by: default avatarKirti Wankhede <kwankhede@nvidia.com>
Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
parent b46c820f
...@@ -143,6 +143,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops) ...@@ -143,6 +143,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
{ {
int ret; int ret;
struct mdev_parent *parent; struct mdev_parent *parent;
char *env_string = "MDEV_STATE=registered";
char *envp[] = { env_string, NULL };
/* check for mandatory ops */ /* check for mandatory ops */
if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups) if (!ops || !ops->create || !ops->remove || !ops->supported_type_groups)
...@@ -194,6 +196,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops) ...@@ -194,6 +196,8 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
mutex_unlock(&parent_list_lock); mutex_unlock(&parent_list_lock);
dev_info(dev, "MDEV: Registered\n"); dev_info(dev, "MDEV: Registered\n");
kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
return 0; return 0;
add_dev_err: add_dev_err:
...@@ -217,6 +221,8 @@ EXPORT_SYMBOL(mdev_register_device); ...@@ -217,6 +221,8 @@ EXPORT_SYMBOL(mdev_register_device);
void mdev_unregister_device(struct device *dev) void mdev_unregister_device(struct device *dev)
{ {
struct mdev_parent *parent; struct mdev_parent *parent;
char *env_string = "MDEV_STATE=unregistered";
char *envp[] = { env_string, NULL };
mutex_lock(&parent_list_lock); mutex_lock(&parent_list_lock);
parent = __find_parent_device(dev); parent = __find_parent_device(dev);
...@@ -240,6 +246,9 @@ void mdev_unregister_device(struct device *dev) ...@@ -240,6 +246,9 @@ void mdev_unregister_device(struct device *dev)
up_write(&parent->unreg_sem); up_write(&parent->unreg_sem);
mdev_put_parent(parent); mdev_put_parent(parent);
/* We still have the caller's reference to use for the uevent */
kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
} }
EXPORT_SYMBOL(mdev_unregister_device); EXPORT_SYMBOL(mdev_unregister_device);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment