Skip to content

Commit

Permalink
Replace linux_pci_(un)register_drm_driver calls with driver name change
Browse files Browse the repository at this point in the history
  • Loading branch information
wulf7 committed Jul 7, 2024
1 parent c25aa7e commit 74cd119
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 30 deletions.
13 changes: 4 additions & 9 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2901,7 +2901,11 @@ static const struct attribute_group *amdgpu_sysfs_groups[] = {
#endif

static struct pci_driver amdgpu_kms_pci_driver = {
#ifdef __linux__
.name = DRIVER_NAME,
#elif defined(__FreeBSD__)
.name = "drmn", /* LinuxKPI expects this name to enable drm support */
#endif
.id_table = pciidlist,
.probe = amdgpu_pci_probe,
.remove = amdgpu_pci_remove,
Expand Down Expand Up @@ -2935,13 +2939,8 @@ static int __init amdgpu_init(void)
/* Ignore KFD init failures. Normal when CONFIG_HSA_AMD is not set. */
amdgpu_amdkfd_init();

#ifdef __linux__
/* let modprobe override vga console setting */
return pci_register_driver(&amdgpu_kms_pci_driver);
#elif defined(__FreeBSD__)
amdgpu_kms_pci_driver.bsdclass = drm_devclass;
return linux_pci_register_drm_driver(&amdgpu_kms_pci_driver);
#endif

error_fence:
amdgpu_sync_fini();
Expand All @@ -2953,11 +2952,7 @@ static int __init amdgpu_init(void)
static void __exit amdgpu_exit(void)
{
amdgpu_amdkfd_fini();
#ifdef __linux__
pci_unregister_driver(&amdgpu_kms_pci_driver);
#elif defined(__FreeBSD__)
linux_pci_unregister_drm_driver(&amdgpu_kms_pci_driver);
#endif
amdgpu_unregister_atpx_handler();
amdgpu_acpi_release();
amdgpu_sync_fini();
Expand Down
2 changes: 0 additions & 2 deletions drivers/gpu/drm/drm_os_freebsd.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ __FBSDID("$FreeBSD$");
#undef fb_info
#undef cdev

devclass_t drm_devclass;

MALLOC_DEFINE(DRM_MEM_DRIVER, "drm_driver", "DRM DRIVER Data Structures");

SYSCTL_NODE(_dev, OID_AUTO, drm, CTLFLAG_RW, 0, "DRM args (compat)");
Expand Down
1 change: 0 additions & 1 deletion drivers/gpu/drm/drm_os_freebsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ __FBSDID("$FreeBSD$");

MALLOC_DECLARE(DRM_MEM_DRIVER);

extern devclass_t drm_devclass;
extern int skip_ddb;

struct drm_minor;
Expand Down
13 changes: 4 additions & 9 deletions drivers/gpu/drm/i915/i915_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,11 @@ static void i915_pci_shutdown(struct pci_dev *pdev)
}

static struct pci_driver i915_pci_driver = {
#ifdef __linux__
.name = DRIVER_NAME,
#elif defined(__FreeBSD__)
.name = "drmn", /* LinuxKPI expects this name to enable drm support */
#endif
.id_table = pciidlist,
.probe = i915_pci_probe,
.remove = i915_pci_remove,
Expand All @@ -1100,19 +1104,10 @@ static struct pci_driver i915_pci_driver = {

int i915_pci_register_driver(void)
{
#ifdef __linux__
return pci_register_driver(&i915_pci_driver);
#elif defined(__FreeBSD__)
i915_pci_driver.bsdclass = drm_devclass;
return linux_pci_register_drm_driver(&i915_pci_driver);
#endif
}

void i915_pci_unregister_driver(void)
{
#ifdef __linux__
pci_unregister_driver(&i915_pci_driver);
#elif defined(__FreeBSD__)
linux_pci_unregister_drm_driver(&i915_pci_driver);
#endif
}
13 changes: 4 additions & 9 deletions drivers/gpu/drm/radeon/radeon_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,11 @@ static const struct drm_driver kms_driver = {
};

static struct pci_driver radeon_kms_pci_driver = {
#ifdef __linux__
.name = DRIVER_NAME,
#elif defined(__FreeBSD__)
.name = "drmn", /* LinuxKPI expects this name to enable drm support */
#endif
.id_table = pciidlist,
.probe = radeon_pci_probe,
.remove = radeon_pci_remove,
Expand All @@ -621,21 +625,12 @@ static int __init radeon_module_init(void)
DRM_INFO("radeon kernel modesetting enabled.\n");
radeon_register_atpx_handler();

#ifdef __linux__
return pci_register_driver(&radeon_kms_pci_driver);
#elif defined(__FreeBSD__)
radeon_kms_pci_driver.bsdclass = drm_devclass;
return linux_pci_register_drm_driver(&radeon_kms_pci_driver);
#endif
}

static void __exit radeon_module_exit(void)
{
#ifdef __linux__
pci_unregister_driver(&radeon_kms_pci_driver);
#elif defined(__FreeBSD__)
linux_pci_unregister_drm_driver(&radeon_kms_pci_driver);
#endif
radeon_unregister_atpx_handler();
#ifdef __linux__
mmu_notifier_synchronize();
Expand Down

0 comments on commit 74cd119

Please sign in to comment.