Skip to content

Commit 0027e3f

Browse files
andy-shevliuw
authored andcommitted
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: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wei Liu <[email protected]>
1 parent 458c447 commit 0027e3f

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

drivers/hv/vmbus_drv.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,6 @@ static int vmbus_exists(void)
117117
return 0;
118118
}
119119

120-
#define VMBUS_ALIAS_LEN ((sizeof((struct hv_vmbus_device_id *)0)->guid) * 2)
121-
static void print_alias_name(struct hv_device *hv_dev, char *alias_name)
122-
{
123-
int i;
124-
for (i = 0; i < VMBUS_ALIAS_LEN; i += 2)
125-
sprintf(&alias_name[i], "%02x", hv_dev->dev_type.b[i/2]);
126-
}
127-
128120
static u8 channel_monitor_group(const struct vmbus_channel *channel)
129121
{
130122
return (u8)channel->offermsg.monitorid / 32;
@@ -221,10 +213,8 @@ static ssize_t modalias_show(struct device *dev,
221213
struct device_attribute *dev_attr, char *buf)
222214
{
223215
struct hv_device *hv_dev = device_to_hv_device(dev);
224-
char alias_name[VMBUS_ALIAS_LEN + 1];
225216

226-
print_alias_name(hv_dev, alias_name);
227-
return sprintf(buf, "vmbus:%s\n", alias_name);
217+
return sprintf(buf, "vmbus:%*phN\n", UUID_SIZE, &hv_dev->dev_type);
228218
}
229219
static DEVICE_ATTR_RO(modalias);
230220

@@ -693,12 +683,9 @@ __ATTRIBUTE_GROUPS(vmbus_dev);
693683
static int vmbus_uevent(struct device *device, struct kobj_uevent_env *env)
694684
{
695685
struct hv_device *dev = device_to_hv_device(device);
696-
int ret;
697-
char alias_name[VMBUS_ALIAS_LEN + 1];
686+
const char *format = "MODALIAS=vmbus:%*phN";
698687

699-
print_alias_name(dev, alias_name);
700-
ret = add_uevent_var(env, "MODALIAS=vmbus:%s", alias_name);
701-
return ret;
688+
return add_uevent_var(env, format, UUID_SIZE, &dev->dev_type);
702689
}
703690

704691
static const struct hv_vmbus_device_id *

0 commit comments

Comments
 (0)