Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Drivers: hv: vmbus: Convert acpi_device to more generic platform_device

VMBus driver code currently has direct dependency on ACPI and struct
acpi_device. As a staging step toward optionally configuring based on
Devicetree instead of ACPI, use a more generic platform device to reduce
the dependency on ACPI where possible, though the dependency on ACPI
is not completely removed. Also rename the function vmbus_acpi_remove()
to the more generic vmbus_mmio_remove().

Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Link: https://lore.kernel.org/r/1679298460-11855-4-git-send-email-ssengar@linux.microsoft.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>

authored by

Saurabh Sengar and committed by
Wei Liu
9c843423 1f6277bf

+35 -23
+35 -23
drivers/hv/vmbus_drv.c
··· 12 12 #include <linux/init.h> 13 13 #include <linux/module.h> 14 14 #include <linux/device.h> 15 + #include <linux/platform_device.h> 15 16 #include <linux/interrupt.h> 16 17 #include <linux/sysctl.h> 17 18 #include <linux/slab.h> ··· 45 44 struct hv_vmbus_device_id id; 46 45 }; 47 46 48 - static struct acpi_device *hv_acpi_dev; 47 + static struct device *hv_dev; 49 48 50 49 static int hyperv_cpuhp_online; 51 50 ··· 144 143 145 144 static int vmbus_exists(void) 146 145 { 147 - if (hv_acpi_dev == NULL) 146 + if (hv_dev == NULL) 148 147 return -ENODEV; 149 148 150 149 return 0; ··· 933 932 * On x86/x64 coherence is assumed and these calls have no effect. 934 933 */ 935 934 hv_setup_dma_ops(child_device, 936 - device_get_dma_attr(&hv_acpi_dev->dev) == DEV_DMA_COHERENT); 935 + device_get_dma_attr(hv_dev) == DEV_DMA_COHERENT); 937 936 return 0; 938 937 } 939 938 ··· 2091 2090 &child_device_obj->channel->offermsg.offer.if_instance); 2092 2091 2093 2092 child_device_obj->device.bus = &hv_bus; 2094 - child_device_obj->device.parent = &hv_acpi_dev->dev; 2093 + child_device_obj->device.parent = hv_dev; 2095 2094 child_device_obj->device.release = vmbus_device_release; 2096 2095 2097 2096 child_device_obj->device.dma_parms = &child_device_obj->dma_parms; ··· 2263 2262 return AE_OK; 2264 2263 } 2265 2264 2266 - static void vmbus_acpi_remove(struct acpi_device *device) 2265 + static void vmbus_mmio_remove(void) 2267 2266 { 2268 2267 struct resource *cur_res; 2269 2268 struct resource *next_res; ··· 2442 2441 } 2443 2442 EXPORT_SYMBOL_GPL(vmbus_free_mmio); 2444 2443 2445 - static int vmbus_acpi_add(struct acpi_device *device) 2444 + static int vmbus_acpi_add(struct platform_device *pdev) 2446 2445 { 2447 2446 acpi_status result; 2448 2447 int ret_val = -ENODEV; 2449 2448 struct acpi_device *ancestor; 2449 + struct acpi_device *device = ACPI_COMPANION(&pdev->dev); 2450 2450 2451 - hv_acpi_dev = device; 2451 + hv_dev = &device->dev; 2452 2452 2453 2453 /* 2454 2454 * Older versions of Hyper-V for ARM64 fail to include the _CCA ··· 2491 2489 2492 2490 acpi_walk_err: 2493 2491 if (ret_val) 2494 - vmbus_acpi_remove(device); 2492 + vmbus_mmio_remove(); 2495 2493 return ret_val; 2494 + } 2495 + 2496 + static int vmbus_platform_driver_probe(struct platform_device *pdev) 2497 + { 2498 + return vmbus_acpi_add(pdev); 2499 + } 2500 + 2501 + static int vmbus_platform_driver_remove(struct platform_device *pdev) 2502 + { 2503 + vmbus_mmio_remove(); 2504 + return 0; 2496 2505 } 2497 2506 2498 2507 #ifdef CONFIG_PM_SLEEP ··· 2671 2658 .restore_noirq = vmbus_bus_resume 2672 2659 }; 2673 2660 2674 - static struct acpi_driver vmbus_acpi_driver = { 2675 - .name = "vmbus", 2676 - .ids = vmbus_acpi_device_ids, 2677 - .ops = { 2678 - .add = vmbus_acpi_add, 2679 - .remove = vmbus_acpi_remove, 2680 - }, 2681 - .drv.pm = &vmbus_bus_pm, 2682 - .drv.probe_type = PROBE_FORCE_SYNCHRONOUS, 2661 + static struct platform_driver vmbus_platform_driver = { 2662 + .probe = vmbus_platform_driver_probe, 2663 + .remove = vmbus_platform_driver_remove, 2664 + .driver = { 2665 + .name = "vmbus", 2666 + .acpi_match_table = ACPI_PTR(vmbus_acpi_device_ids), 2667 + .pm = &vmbus_bus_pm, 2668 + .probe_type = PROBE_FORCE_SYNCHRONOUS, 2669 + } 2683 2670 }; 2684 2671 2685 2672 static void hv_kexec_handler(void) ··· 2763 2750 /* 2764 2751 * Get ACPI resources first. 2765 2752 */ 2766 - ret = acpi_bus_register_driver(&vmbus_acpi_driver); 2767 - 2753 + ret = platform_driver_register(&vmbus_platform_driver); 2768 2754 if (ret) 2769 2755 return ret; 2770 2756 2771 - if (!hv_acpi_dev) { 2757 + if (!hv_dev) { 2772 2758 ret = -ENODEV; 2773 2759 goto cleanup; 2774 2760 } ··· 2797 2785 return 0; 2798 2786 2799 2787 cleanup: 2800 - acpi_bus_unregister_driver(&vmbus_acpi_driver); 2801 - hv_acpi_dev = NULL; 2788 + platform_driver_unregister(&vmbus_platform_driver); 2789 + hv_dev = NULL; 2802 2790 return ret; 2803 2791 } 2804 2792 ··· 2851 2839 2852 2840 cpuhp_remove_state(hyperv_cpuhp_online); 2853 2841 hv_synic_free(); 2854 - acpi_bus_unregister_driver(&vmbus_acpi_driver); 2842 + platform_driver_unregister(&vmbus_platform_driver); 2855 2843 } 2856 2844 2857 2845