]> Pileus Git - ~andy/linux/commitdiff
Staging: hv: vmbus: Cleanup vmbus_uevent() code
authorK. Y. Srinivasan <kys@microsoft.com>
Thu, 25 Aug 2011 16:48:38 +0000 (09:48 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 25 Aug 2011 21:08:23 +0000 (14:08 -0700)
Now generate appropriate uevent based on the modalias string. As part of this,
cleanup the existing uevent code.

[gregkh - fixed code to handle driver_data portion of struct
hv_vmbus_device_id]

Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/staging/hv/vmbus_drv.c

index b651968177a532ca3627d7d35974426d0a5ba01e..afb16704221cb23ef4f2436d365e41ff6fdf5da9 100644 (file)
@@ -237,58 +237,22 @@ static struct device_attribute vmbus_device_attrs[] = {
  * This routine is invoked when a device is added or removed on the vmbus to
  * generate a uevent to udev in the userspace. The udev will then look at its
  * rule and the uevent generated here to load the appropriate driver
+ *
+ * The alias string will be of the form vmbus:guid where guid is the string
+ * representation of the device guid (each byte of the guid will be
+ * represented with two hex characters.
  */
 static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
 {
        struct hv_device *dev = device_to_hv_device(device);
-       int ret;
-
-       ret = add_uevent_var(env, "VMBUS_DEVICE_CLASS_GUID={"
-                            "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-                            "%02x%02x%02x%02x%02x%02x%02x%02x}",
-                            dev->dev_type.b[3],
-                            dev->dev_type.b[2],
-                            dev->dev_type.b[1],
-                            dev->dev_type.b[0],
-                            dev->dev_type.b[5],
-                            dev->dev_type.b[4],
-                            dev->dev_type.b[7],
-                            dev->dev_type.b[6],
-                            dev->dev_type.b[8],
-                            dev->dev_type.b[9],
-                            dev->dev_type.b[10],
-                            dev->dev_type.b[11],
-                            dev->dev_type.b[12],
-                            dev->dev_type.b[13],
-                            dev->dev_type.b[14],
-                            dev->dev_type.b[15]);
-
-       if (ret)
-               return ret;
+       int i, ret;
+       char alias_name[((sizeof((struct hv_vmbus_device_id *)0)->guid) + 1) * 2];
 
-       ret = add_uevent_var(env, "VMBUS_DEVICE_DEVICE_GUID={"
-                            "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
-                            "%02x%02x%02x%02x%02x%02x%02x%02x}",
-                            dev->dev_instance.b[3],
-                            dev->dev_instance.b[2],
-                            dev->dev_instance.b[1],
-                            dev->dev_instance.b[0],
-                            dev->dev_instance.b[5],
-                            dev->dev_instance.b[4],
-                            dev->dev_instance.b[7],
-                            dev->dev_instance.b[6],
-                            dev->dev_instance.b[8],
-                            dev->dev_instance.b[9],
-                            dev->dev_instance.b[10],
-                            dev->dev_instance.b[11],
-                            dev->dev_instance.b[12],
-                            dev->dev_instance.b[13],
-                            dev->dev_instance.b[14],
-                            dev->dev_instance.b[15]);
-       if (ret)
-               return ret;
+       for (i = 0; i < ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2); i += 2)
+               sprintf(&alias_name[i], "%02x", dev->dev_type.b[i/2]);
 
-       return 0;
+       ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
+       return ret;
 }