hyper-v: Use UUID API for exporting the GUID (part 2)
Subsystems (2)
PATCH 1/4 hyper-v: Use UUID API for exporting the GUID (part 2)
This is a follow up to the commit 1d3c9c075462
("hyper-v: Use UUID API for exporting the GUID")
which starts the conversion.
There is export_guid() function which exports guid_t to the u8 array. Use it instead of open coding variant.
This allows to hide the uuid_t internals.
--- drivers/hv/hv_trace.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/hv/hv_trace.h +2 -4
@@ -44,10 +44,8 @@ TRACE_EVENT(vmbus_onoffer, __entry->monitorid = offer->monitorid; __entry->is_ddc_int = offer->is_dedicated_interrupt; __entry->connection_id = offer->connection_id; -memcpy (__entry->if_type, - &offer->offer.if_type.b,16 ); -memcpy (__entry->if_instance, - &offer->offer.if_instance.b,16 ); +export_guid (__entry->if_type, &offer->offer.if_type); +export_guid (__entry->if_instance, &offer->offer.if_instance); __entry->chn_flags = offer->offer.chn_flags; __entry->mmio_mb = offer->offer.mmio_megabytes; __entry->sub_idx = offer->offer.sub_channel_index;
Signature · 1 line
2.26.1
PATCH 2/4 hyper-v: Supply GUID pointer to printf() like functions
Drop dereference when printing the GUID with printf() like functions. This allows to hide the uuid_t internals.
--- drivers/hv/vmbus_drv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/hv/vmbus_drv.c +3 -3
@@ -201,7 +201,7 @@ static ssize_t class_id_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ;return sprintf (buf,"{%pUl}\n" , - hv_dev->channel->offermsg.offer.if_type.b); + &hv_dev->channel->offermsg.offer.if_type); }static DEVICE_ATTR_RO (class_id);
@@ -213,7 +213,7 @@ static ssize_t device_id_show(struct device *dev,if (!hv_dev->channel)return -ENODEV ;return sprintf (buf,"{%pUl}\n" , - hv_dev->channel->offermsg.offer.if_instance.b); + &hv_dev->channel->offermsg.offer.if_instance); }static DEVICE_ATTR_RO (device_id);
@@ -2005,7 +2005,7 @@ int vmbus_device_register(struct hv_device *child_device_obj)int ret;dev_set_name (&child_device_obj->device,"%pUl" , - child_device_obj->channel->offermsg.offer.if_instance.b); + &child_device_obj->channel->offermsg.offer.if_instance); child_device_obj->device.bus = &hv_bus; child_device_obj->device.parent = &hv_acpi_dev->dev;
Signature · 1 line
2.26.1
PATCH 3/4 hyper-v: Replace open-coded variant of %*phN specifier
In reply to Andy Shevchenkoprintf() like functions in the kernel have extensions, such as %*phN to dump small pieces of memory as hex values.
Replace print_alias_name() with the direct use of %*phN.
--- drivers/hv/vmbus_drv.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-)
drivers/hv/vmbus_drv.c +3 -16
@@ -117,14 +117,6 @@ static int vmbus_exists(void)return 0 ; } -#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2) -static void print_alias_name (struct hv_device *hv_dev,char *alias_name) -{ -int i; -for (i =0 ; i <VMBUS_ALIAS_LEN ; i +=2 ) -sprintf (&alias_name[i],"%02x" , hv_dev->dev_type.b[i/2 ]); -} -static u8 channel_monitor_group (const struct vmbus_channel *channel) {return (u8 )channel->offermsg.monitorid /32 ;
@@ -221,10 +213,8 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *dev_attr, char *buf) { struct hv_device *hv_dev = device_to_hv_device(dev); -char alias_name[VMBUS_ALIAS_LEN +1 ]; -print_alias_name (hv_dev, alias_name); -return sprintf (buf,"vmbus:%s\n" , alias_name); +return sprintf (buf,"vmbus:%*phN\n" ,UUID_SIZE , &hv_dev->dev_type); }static DEVICE_ATTR_RO (modalias);
@@ -693,12 +683,9 @@ __ATTRIBUTE_GROUPS(vmbus_dev);static int vmbus_uevent (struct device *device,struct kobj_uevent_env *env) {struct hv_device *dev =device_to_hv_device (device); -int ret; -char alias_name[VMBUS_ALIAS_LEN +1 ]; +const char *format ="MODALIAS=vmbus:%*phN" ; -print_alias_name (dev, alias_name); - ret =add_uevent_var (env,"MODALIAS=vmbus:%s" , alias_name); -return ret; +return add_uevent_var (env, format,UUID_SIZE , &dev->dev_type); } static const struct hv_vmbus_device_id *
Signature · 1 line
2.26.1
PATCH 4/4 hyper-v: Switch to use UUID types directly
In reply to Andy Shevchenkouuid_le is an alias for guid_t and is going to be removed in the future. Replace it with original type.
--- include/linux/mod_devicetable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mod_devicetable.h +1 -1
@@ -434,7 +434,7 @@ struct virtio_device_id {* For Hyper-V devices we use the device guid as the id. */ struct hv_vmbus_device_id { -uuid_le guid; +guid_t guid;kernel_ulong_t driver_data;/* Data private to the driver */ };
Signature · 1 line
2.26.1
Quoted 10 lines · Andy Shevchenko
This is a follow up to the commit
1d3c9c075462
("hyper-v: Use UUID API for exporting the GUID")
which starts the conversion.There is
export_guid()function which exportsguid_tto the u8 array. Use it instead of open coding variant.This allows to hide the
uuid_tinternals.Signed-off-by Andy Shevchenko <[email protected]>
Thanks.
I have queued the whole series to hyperv-next.
Wei.