Commit 0027e3fd authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Wei Liu

hyper-v: Replace open-coded variant of %*phN specifier

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20200423134505.78221-3-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarWei Liu <wei.liu@kernel.org>
parent 458c4475
...@@ -117,14 +117,6 @@ static int vmbus_exists(void) ...@@ -117,14 +117,6 @@ static int vmbus_exists(void)
return 0; 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) static u8 channel_monitor_group(const struct vmbus_channel *channel)
{ {
return (u8)channel->offermsg.monitorid / 32; return (u8)channel->offermsg.monitorid / 32;
...@@ -221,10 +213,8 @@ static ssize_t modalias_show(struct device *dev, ...@@ -221,10 +213,8 @@ static ssize_t modalias_show(struct device *dev,
struct device_attribute *dev_attr, char *buf) struct device_attribute *dev_attr, char *buf)
{ {
struct hv_device *hv_dev = device_to_hv_device(dev); 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:%*phN\n", UUID_SIZE, &hv_dev->dev_type);
return sprintf(buf, "vmbus:%s\n", alias_name);
} }
static DEVICE_ATTR_RO(modalias); static DEVICE_ATTR_RO(modalias);
...@@ -693,12 +683,9 @@ __ATTRIBUTE_GROUPS(vmbus_dev); ...@@ -693,12 +683,9 @@ __ATTRIBUTE_GROUPS(vmbus_dev);
static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env) static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
{ {
struct hv_device *dev = device_to_hv_device(device); struct hv_device *dev = device_to_hv_device(device);
int ret; const char *format = "MODALIAS=vmbus:%*phN";
char alias_name[VMBUS_ALIAS_LEN + 1];
print_alias_name(dev, alias_name); return add_uevent_var(env, format, UUID_SIZE, &dev->dev_type);
ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
return ret;
} }
static const struct hv_vmbus_device_id * static const struct hv_vmbus_device_id *
......
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