* [PATCH v1 1/4] hyper-v: Use UUID API for exporting the GUID (part 2)
@ 2020-04-23 13:45 Andy Shevchenko
2020-04-23 13:45 ` [PATCH v1 2/4] hyper-v: Supply GUID pointer to printf() like functions Andy Shevchenko
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-04-23 13:45 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
linux-hyperv
Cc: 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 exports guid_t to the u8 array.
Use it instead of open coding variant.
This allows to hide the uuid_t internals.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/hv/hv_trace.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/hv/hv_trace.h b/drivers/hv/hv_trace.h
index 579d19bdc0981b..6063bb21bb1371 100644
--- a/drivers/hv/hv_trace.h
+++ b/drivers/hv/hv_trace.h
@@ -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;
--
2.26.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 2/4] hyper-v: Supply GUID pointer to printf() like functions
2020-04-23 13:45 [PATCH v1 1/4] hyper-v: Use UUID API for exporting the GUID (part 2) Andy Shevchenko
@ 2020-04-23 13:45 ` Andy Shevchenko
2020-04-23 13:45 ` [PATCH v1 3/4] hyper-v: Replace open-coded variant of %*phN specifier Andy Shevchenko
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-04-23 13:45 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
linux-hyperv
Cc: Andy Shevchenko
Drop dereference when printing the GUID with printf() like functions.
This allows to hide the uuid_t internals.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/hv/vmbus_drv.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 84c9985d83918c..3d03a26216b7b8 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -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;
--
2.26.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 3/4] hyper-v: Replace open-coded variant of %*phN specifier
2020-04-23 13:45 [PATCH v1 1/4] hyper-v: Use UUID API for exporting the GUID (part 2) Andy Shevchenko
2020-04-23 13:45 ` [PATCH v1 2/4] hyper-v: Supply GUID pointer to printf() like functions Andy Shevchenko
@ 2020-04-23 13:45 ` Andy Shevchenko
2020-04-23 13:45 ` [PATCH v1 4/4] hyper-v: Switch to use UUID types directly Andy Shevchenko
2020-04-24 10:21 ` [PATCH v1 1/4] hyper-v: Use UUID API for exporting the GUID (part 2) Wei Liu
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-04-23 13:45 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
linux-hyperv
Cc: Andy Shevchenko
printf() 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.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/hv/vmbus_drv.c | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 3d03a26216b7b8..8651c58e892230 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -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 *
--
2.26.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v1 4/4] hyper-v: Switch to use UUID types directly
2020-04-23 13:45 [PATCH v1 1/4] hyper-v: Use UUID API for exporting the GUID (part 2) Andy Shevchenko
2020-04-23 13:45 ` [PATCH v1 2/4] hyper-v: Supply GUID pointer to printf() like functions Andy Shevchenko
2020-04-23 13:45 ` [PATCH v1 3/4] hyper-v: Replace open-coded variant of %*phN specifier Andy Shevchenko
@ 2020-04-23 13:45 ` Andy Shevchenko
2020-04-24 10:21 ` [PATCH v1 1/4] hyper-v: Use UUID API for exporting the GUID (part 2) Wei Liu
3 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2020-04-23 13:45 UTC (permalink / raw)
To: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
linux-hyperv
Cc: Andy Shevchenko
uuid_le is an alias for guid_t and is going to be removed in the future.
Replace it with original type.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/mod_devicetable.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 4b3d0a4945dfc6..c97195fe865852 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -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 */
};
--
2.26.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v1 1/4] hyper-v: Use UUID API for exporting the GUID (part 2)
2020-04-23 13:45 [PATCH v1 1/4] hyper-v: Use UUID API for exporting the GUID (part 2) Andy Shevchenko
` (2 preceding siblings ...)
2020-04-23 13:45 ` [PATCH v1 4/4] hyper-v: Switch to use UUID types directly Andy Shevchenko
@ 2020-04-24 10:21 ` Wei Liu
3 siblings, 0 replies; 5+ messages in thread
From: Wei Liu @ 2020-04-24 10:21 UTC (permalink / raw)
To: Andy Shevchenko
Cc: K. Y. Srinivasan, Haiyang Zhang, Stephen Hemminger, Wei Liu,
linux-hyperv
On Thu, Apr 23, 2020 at 04:45:02PM +0300, Andy Shevchenko wrote:
> 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.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Thanks.
I have queued the whole series to hyperv-next.
Wei.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-24 10:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-23 13:45 [PATCH v1 1/4] hyper-v: Use UUID API for exporting the GUID (part 2) Andy Shevchenko
2020-04-23 13:45 ` [PATCH v1 2/4] hyper-v: Supply GUID pointer to printf() like functions Andy Shevchenko
2020-04-23 13:45 ` [PATCH v1 3/4] hyper-v: Replace open-coded variant of %*phN specifier Andy Shevchenko
2020-04-23 13:45 ` [PATCH v1 4/4] hyper-v: Switch to use UUID types directly Andy Shevchenko
2020-04-24 10:21 ` [PATCH v1 1/4] hyper-v: Use UUID API for exporting the GUID (part 2) Wei Liu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.