Skip to content

Commit 9645e74

Browse files
mhklinuxliuw
authored andcommitted
Drivers: hv: vmbus: Update indentation in create_gpadl_header()
A previous commit left the indentation in create_gpadl_header() unchanged for ease of review. Update the indentation and remove line wrap in two places where it is no longer necessary. No functional change. Signed-off-by: Michael Kelley <mhklinux@outlook.com> Link: https://lore.kernel.org/r/20240111165451.269418-2-mhklinux@outlook.com Signed-off-by: Wei Liu <wei.liu@kernel.org> Message-ID: <20240111165451.269418-2-mhklinux@outlook.com>
1 parent 8db0edc commit 9645e74

1 file changed

Lines changed: 70 additions & 72 deletions

File tree

drivers/hv/channel.c

Lines changed: 70 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -327,85 +327,83 @@ static int create_gpadl_header(enum hv_gpadl_type type, void *kbuffer,
327327
sizeof(struct gpa_range);
328328
pfncount = umin(pagecount, pfnsize / sizeof(u64));
329329

330-
msgsize = sizeof(struct vmbus_channel_msginfo) +
331-
sizeof(struct vmbus_channel_gpadl_header) +
332-
sizeof(struct gpa_range) + pfncount * sizeof(u64);
333-
msgheader = kzalloc(msgsize, GFP_KERNEL);
334-
if (!msgheader)
335-
return -ENOMEM;
336-
337-
INIT_LIST_HEAD(&msgheader->submsglist);
338-
msgheader->msgsize = msgsize;
339-
340-
gpadl_header = (struct vmbus_channel_gpadl_header *)
341-
msgheader->msg;
342-
gpadl_header->rangecount = 1;
343-
gpadl_header->range_buflen = sizeof(struct gpa_range) +
344-
pagecount * sizeof(u64);
345-
gpadl_header->range[0].byte_offset = 0;
346-
gpadl_header->range[0].byte_count = hv_gpadl_size(type, size);
347-
for (i = 0; i < pfncount; i++)
348-
gpadl_header->range[0].pfn_array[i] = hv_gpadl_hvpfn(
349-
type, kbuffer, size, send_offset, i);
350-
*msginfo = msgheader;
351-
352-
pfnsum = pfncount;
353-
pfnleft = pagecount - pfncount;
354-
355-
/* how many pfns can we fit in a body message */
356-
pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
357-
sizeof(struct vmbus_channel_gpadl_body);
358-
pfncount = pfnsize / sizeof(u64);
330+
msgsize = sizeof(struct vmbus_channel_msginfo) +
331+
sizeof(struct vmbus_channel_gpadl_header) +
332+
sizeof(struct gpa_range) + pfncount * sizeof(u64);
333+
msgheader = kzalloc(msgsize, GFP_KERNEL);
334+
if (!msgheader)
335+
return -ENOMEM;
359336

360-
/*
361-
* If pfnleft is zero, everything fits in the header and no body
362-
* messages are needed
363-
*/
364-
while (pfnleft) {
365-
pfncurr = umin(pfncount, pfnleft);
366-
msgsize = sizeof(struct vmbus_channel_msginfo) +
367-
sizeof(struct vmbus_channel_gpadl_body) +
368-
pfncurr * sizeof(u64);
369-
msgbody = kzalloc(msgsize, GFP_KERNEL);
370-
371-
if (!msgbody) {
372-
struct vmbus_channel_msginfo *pos = NULL;
373-
struct vmbus_channel_msginfo *tmp = NULL;
374-
/*
375-
* Free up all the allocated messages.
376-
*/
377-
list_for_each_entry_safe(pos, tmp,
378-
&msgheader->submsglist,
379-
msglistentry) {
380-
381-
list_del(&pos->msglistentry);
382-
kfree(pos);
383-
}
384-
kfree(msgheader);
385-
return -ENOMEM;
386-
}
337+
INIT_LIST_HEAD(&msgheader->submsglist);
338+
msgheader->msgsize = msgsize;
339+
340+
gpadl_header = (struct vmbus_channel_gpadl_header *)
341+
msgheader->msg;
342+
gpadl_header->rangecount = 1;
343+
gpadl_header->range_buflen = sizeof(struct gpa_range) +
344+
pagecount * sizeof(u64);
345+
gpadl_header->range[0].byte_offset = 0;
346+
gpadl_header->range[0].byte_count = hv_gpadl_size(type, size);
347+
for (i = 0; i < pfncount; i++)
348+
gpadl_header->range[0].pfn_array[i] = hv_gpadl_hvpfn(
349+
type, kbuffer, size, send_offset, i);
350+
*msginfo = msgheader;
351+
352+
pfnsum = pfncount;
353+
pfnleft = pagecount - pfncount;
354+
355+
/* how many pfns can we fit in a body message */
356+
pfnsize = MAX_SIZE_CHANNEL_MESSAGE -
357+
sizeof(struct vmbus_channel_gpadl_body);
358+
pfncount = pfnsize / sizeof(u64);
387359

388-
msgbody->msgsize = msgsize;
389-
gpadl_body =
390-
(struct vmbus_channel_gpadl_body *)msgbody->msg;
360+
/*
361+
* If pfnleft is zero, everything fits in the header and no body
362+
* messages are needed
363+
*/
364+
while (pfnleft) {
365+
pfncurr = umin(pfncount, pfnleft);
366+
msgsize = sizeof(struct vmbus_channel_msginfo) +
367+
sizeof(struct vmbus_channel_gpadl_body) +
368+
pfncurr * sizeof(u64);
369+
msgbody = kzalloc(msgsize, GFP_KERNEL);
391370

371+
if (!msgbody) {
372+
struct vmbus_channel_msginfo *pos = NULL;
373+
struct vmbus_channel_msginfo *tmp = NULL;
392374
/*
393-
* Gpadl is u32 and we are using a pointer which could
394-
* be 64-bit
395-
* This is governed by the guest/host protocol and
396-
* so the hypervisor guarantees that this is ok.
375+
* Free up all the allocated messages.
397376
*/
398-
for (i = 0; i < pfncurr; i++)
399-
gpadl_body->pfn[i] = hv_gpadl_hvpfn(type,
400-
kbuffer, size, send_offset, pfnsum + i);
401-
402-
/* add to msg header */
403-
list_add_tail(&msgbody->msglistentry,
404-
&msgheader->submsglist);
405-
pfnsum += pfncurr;
406-
pfnleft -= pfncurr;
377+
list_for_each_entry_safe(pos, tmp,
378+
&msgheader->submsglist,
379+
msglistentry) {
380+
381+
list_del(&pos->msglistentry);
382+
kfree(pos);
383+
}
384+
kfree(msgheader);
385+
return -ENOMEM;
407386
}
408387

388+
msgbody->msgsize = msgsize;
389+
gpadl_body = (struct vmbus_channel_gpadl_body *)msgbody->msg;
390+
391+
/*
392+
* Gpadl is u32 and we are using a pointer which could
393+
* be 64-bit
394+
* This is governed by the guest/host protocol and
395+
* so the hypervisor guarantees that this is ok.
396+
*/
397+
for (i = 0; i < pfncurr; i++)
398+
gpadl_body->pfn[i] = hv_gpadl_hvpfn(type,
399+
kbuffer, size, send_offset, pfnsum + i);
400+
401+
/* add to msg header */
402+
list_add_tail(&msgbody->msglistentry, &msgheader->submsglist);
403+
pfnsum += pfncurr;
404+
pfnleft -= pfncurr;
405+
}
406+
409407
return 0;
410408
}
411409

0 commit comments

Comments
 (0)