hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/xen/xen-acpi-processor.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright 2012 by Oracle Inc
34 * Author: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
....@@ -5,16 +6,6 @@
56 * This code borrows ideas from https://lkml.org/lkml/2011/11/30/249
67 * so many thanks go to Kevin Tian <kevin.tian@intel.com>
78 * and Yu Ke <ke.yu@intel.com>.
8
- *
9
- * This program is free software; you can redistribute it and/or modify it
10
- * under the terms and conditions of the GNU General Public License,
11
- * version 2, as published by the Free Software Foundation.
12
- *
13
- * This program is distributed in the hope it will be useful, but WITHOUT
14
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16
- * more details.
17
- *
189 */
1910
2011 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -410,21 +401,21 @@
410401 /* All online CPUs have been processed at this stage. Now verify
411402 * whether in fact "online CPUs" == physical CPUs.
412403 */
413
- acpi_id_present = kcalloc(BITS_TO_LONGS(nr_acpi_bits), sizeof(unsigned long), GFP_KERNEL);
404
+ acpi_id_present = bitmap_zalloc(nr_acpi_bits, GFP_KERNEL);
414405 if (!acpi_id_present)
415406 return -ENOMEM;
416407
417
- acpi_id_cst_present = kcalloc(BITS_TO_LONGS(nr_acpi_bits), sizeof(unsigned long), GFP_KERNEL);
408
+ acpi_id_cst_present = bitmap_zalloc(nr_acpi_bits, GFP_KERNEL);
418409 if (!acpi_id_cst_present) {
419
- kfree(acpi_id_present);
410
+ bitmap_free(acpi_id_present);
420411 return -ENOMEM;
421412 }
422413
423414 acpi_psd = kcalloc(nr_acpi_bits, sizeof(struct acpi_psd_package),
424415 GFP_KERNEL);
425416 if (!acpi_psd) {
426
- kfree(acpi_id_present);
427
- kfree(acpi_id_cst_present);
417
+ bitmap_free(acpi_id_present);
418
+ bitmap_free(acpi_id_cst_present);
428419 return -ENOMEM;
429420 }
430421
....@@ -533,14 +524,14 @@
533524 return -ENODEV;
534525
535526 nr_acpi_bits = get_max_acpi_id() + 1;
536
- acpi_ids_done = kcalloc(BITS_TO_LONGS(nr_acpi_bits), sizeof(unsigned long), GFP_KERNEL);
527
+ acpi_ids_done = bitmap_zalloc(nr_acpi_bits, GFP_KERNEL);
537528 if (!acpi_ids_done)
538529 return -ENOMEM;
539530
540531 acpi_perf_data = alloc_percpu(struct acpi_processor_performance);
541532 if (!acpi_perf_data) {
542533 pr_debug("Memory allocation error for acpi_perf_data\n");
543
- kfree(acpi_ids_done);
534
+ bitmap_free(acpi_ids_done);
544535 return -ENOMEM;
545536 }
546537 for_each_possible_cpu(i) {
....@@ -584,7 +575,7 @@
584575 err_out:
585576 /* Freeing a NULL pointer is OK: alloc_percpu zeroes. */
586577 free_acpi_perf_data();
587
- kfree(acpi_ids_done);
578
+ bitmap_free(acpi_ids_done);
588579 return rc;
589580 }
590581 static void __exit xen_acpi_processor_exit(void)
....@@ -592,9 +583,9 @@
592583 int i;
593584
594585 unregister_syscore_ops(&xap_syscore_ops);
595
- kfree(acpi_ids_done);
596
- kfree(acpi_id_present);
597
- kfree(acpi_id_cst_present);
586
+ bitmap_free(acpi_ids_done);
587
+ bitmap_free(acpi_id_present);
588
+ bitmap_free(acpi_id_cst_present);
598589 kfree(acpi_psd);
599590 for_each_possible_cpu(i)
600591 acpi_processor_unregister_performance(i);