Skip to content

Commit a6fe043

Browse files
Kameron Carrliuw
authored andcommitted
Drivers: hv: Change hv_free_hyperv_page() to take void * argument
Currently hv_free_hyperv_page() takes an unsigned long argument, which is inconsistent with the void * return value from the corresponding hv_alloc_hyperv_page() function and variants. This creates unnecessary extra casting. Change the hv_free_hyperv_page() argument type to void *. Also remove redundant casts from invocations of hv_alloc_hyperv_page() and variants. Signed-off-by: Kameron Carr <kameroncarr@linux.microsoft.com> Reviewed-by: Nuno Das Neves <nunodasneves@linux.microsoft.com> Reviewed-by: Dexuan Cui <decui@microsoft.com> Link: https://lore.kernel.org/r/1687558189-19734-1-git-send-email-kameroncarr@linux.microsoft.com Signed-off-by: Wei Liu <wei.liu@kernel.org>
1 parent 6995e2d commit a6fe043

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

drivers/hv/connection.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ int vmbus_connect(void)
209209
* Setup the vmbus event connection for channel interrupt
210210
* abstraction stuff
211211
*/
212-
vmbus_connection.int_page =
213-
(void *)hv_alloc_hyperv_zeroed_page();
212+
vmbus_connection.int_page = hv_alloc_hyperv_zeroed_page();
214213
if (vmbus_connection.int_page == NULL) {
215214
ret = -ENOMEM;
216215
goto cleanup;
@@ -225,8 +224,8 @@ int vmbus_connect(void)
225224
* Setup the monitor notification facility. The 1st page for
226225
* parent->child and the 2nd page for child->parent
227226
*/
228-
vmbus_connection.monitor_pages[0] = (void *)hv_alloc_hyperv_page();
229-
vmbus_connection.monitor_pages[1] = (void *)hv_alloc_hyperv_page();
227+
vmbus_connection.monitor_pages[0] = hv_alloc_hyperv_page();
228+
vmbus_connection.monitor_pages[1] = hv_alloc_hyperv_page();
230229
if ((vmbus_connection.monitor_pages[0] == NULL) ||
231230
(vmbus_connection.monitor_pages[1] == NULL)) {
232231
ret = -ENOMEM;
@@ -333,15 +332,15 @@ void vmbus_disconnect(void)
333332
destroy_workqueue(vmbus_connection.work_queue);
334333

335334
if (vmbus_connection.int_page) {
336-
hv_free_hyperv_page((unsigned long)vmbus_connection.int_page);
335+
hv_free_hyperv_page(vmbus_connection.int_page);
337336
vmbus_connection.int_page = NULL;
338337
}
339338

340339
set_memory_encrypted((unsigned long)vmbus_connection.monitor_pages[0], 1);
341340
set_memory_encrypted((unsigned long)vmbus_connection.monitor_pages[1], 1);
342341

343-
hv_free_hyperv_page((unsigned long)vmbus_connection.monitor_pages[0]);
344-
hv_free_hyperv_page((unsigned long)vmbus_connection.monitor_pages[1]);
342+
hv_free_hyperv_page(vmbus_connection.monitor_pages[0]);
343+
hv_free_hyperv_page(vmbus_connection.monitor_pages[1]);
345344
vmbus_connection.monitor_pages[0] = NULL;
346345
vmbus_connection.monitor_pages[1] = NULL;
347346
}

drivers/hv/hv_common.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ void *hv_alloc_hyperv_zeroed_page(void)
115115
}
116116
EXPORT_SYMBOL_GPL(hv_alloc_hyperv_zeroed_page);
117117

118-
void hv_free_hyperv_page(unsigned long addr)
118+
void hv_free_hyperv_page(void *addr)
119119
{
120120
if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
121-
free_page(addr);
121+
free_page((unsigned long)addr);
122122
else
123-
kfree((void *)addr);
123+
kfree(addr);
124124
}
125125
EXPORT_SYMBOL_GPL(hv_free_hyperv_page);
126126

@@ -253,7 +253,7 @@ static void hv_kmsg_dump_unregister(void)
253253
atomic_notifier_chain_unregister(&panic_notifier_list,
254254
&hyperv_panic_report_block);
255255

256-
hv_free_hyperv_page((unsigned long)hv_panic_page);
256+
hv_free_hyperv_page(hv_panic_page);
257257
hv_panic_page = NULL;
258258
}
259259

@@ -270,7 +270,7 @@ static void hv_kmsg_dump_register(void)
270270
ret = kmsg_dump_register(&hv_kmsg_dumper);
271271
if (ret) {
272272
pr_err("Hyper-V: kmsg dump register error 0x%x\n", ret);
273-
hv_free_hyperv_page((unsigned long)hv_panic_page);
273+
hv_free_hyperv_page(hv_panic_page);
274274
hv_panic_page = NULL;
275275
}
276276
}

include/asm-generic/mshyperv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ int hv_common_cpu_die(unsigned int cpu);
190190

191191
void *hv_alloc_hyperv_page(void);
192192
void *hv_alloc_hyperv_zeroed_page(void);
193-
void hv_free_hyperv_page(unsigned long addr);
193+
void hv_free_hyperv_page(void *addr);
194194

195195
/**
196196
* hv_cpu_number_to_vp_number() - Map CPU to VP.

0 commit comments

Comments
 (0)