From daeb37ee4f209a44f412fbeddbb7fe65ba4ca9aa Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 27 Oct 2018 14:16:23 -0400 Subject: [PATCH] freebsd11_network: Cleanup haiku-module.h. * init_hardware is unnecessary and mostly a duplicate of init_driver; so just remove it in favor of that. * Deduplify some of the _DRIVER macros as possible * Don't include net_stack.h, we don't need it here; and fix callout.h following that. --- .../freebsd11_network/compat/sys/callout.h | 2 + .../compat/sys/haiku-module.h | 36 +++--------- src/libs/compat/freebsd11_network/driver.c | 56 ------------------- 3 files changed, 10 insertions(+), 84 deletions(-) diff --git a/src/libs/compat/freebsd11_network/compat/sys/callout.h b/src/libs/compat/freebsd11_network/compat/sys/callout.h index e78fb24e01..74a337b5b2 100644 --- a/src/libs/compat/freebsd11_network/compat/sys/callout.h +++ b/src/libs/compat/freebsd11_network/compat/sys/callout.h @@ -12,6 +12,8 @@ #include +#include + struct callout { struct list_link link; diff --git a/src/libs/compat/freebsd11_network/compat/sys/haiku-module.h b/src/libs/compat/freebsd11_network/compat/sys/haiku-module.h index 7b9f5e7107..581f591d52 100644 --- a/src/libs/compat/freebsd11_network/compat/sys/haiku-module.h +++ b/src/libs/compat/freebsd11_network/compat/sys/haiku-module.h @@ -11,7 +11,6 @@ #include #include -#include #undef __unused #define __unused @@ -64,7 +63,6 @@ typedef struct { #define DRIVER_MODULE_NAME(name, busname) \ __fbsd_ ## name ## _ ## busname -status_t _fbsd_init_hardware(driver_t *driver[]); status_t _fbsd_init_drivers(driver_t *driver[]); status_t _fbsd_uninit_drivers(driver_t *driver[]); @@ -85,15 +83,13 @@ status_t wlan_close(void*); * While gcc 2.95 packs everything from the static library onto * the final binary, gcc 4.x rightfuly doesn't. */ -#define HAIKU_FBSD_DRIVERS_GLUE(publicname) \ +#define HAIKU_FBSD_DRIVERS_CORE_GLUE(publicname) \ extern const char *gDeviceNameList[]; \ extern device_hooks gDeviceHooks; \ const char *gDriverName = #publicname; \ int32 api_version = B_CUR_DRIVER_API_VERSION; \ status_t init_hardware() \ - { \ - return __haiku_handle_fbsd_drivers_list(_fbsd_init_hardware); \ - } \ + { return B_OK; } \ status_t init_driver() \ { \ return __haiku_handle_fbsd_drivers_list(_fbsd_init_drivers); \ @@ -105,7 +101,10 @@ status_t wlan_close(void*); const char **publish_devices() \ { return gDeviceNameList; } \ device_hooks *find_device(const char *name) \ - { return &gDeviceHooks; } \ + { return &gDeviceHooks; } + +#define HAIKU_FBSD_DRIVERS_GLUE(publicname) \ + HAIKU_FBSD_DRIVERS_CORE_GLUE(publicname) \ status_t init_wlan_stack(void) \ { return B_OK; } \ void uninit_wlan_stack(void) {} \ @@ -120,7 +119,7 @@ status_t wlan_close(void*); { return B_OK; } #define HAIKU_FBSD_DRIVER_GLUE(publicname, name, busname) \ - extern driver_t *DRIVER_MODULE_NAME(name, busname); \ + extern driver_t* DRIVER_MODULE_NAME(name, busname); \ status_t __haiku_handle_fbsd_drivers_list(status_t (*proc)(driver_t *[])) {\ driver_t *drivers[] = { \ DRIVER_MODULE_NAME(name, busname), \ @@ -131,26 +130,7 @@ status_t wlan_close(void*); HAIKU_FBSD_DRIVERS_GLUE(publicname); #define HAIKU_FBSD_WLAN_DRIVERS_GLUE(publicname) \ - extern const char *gDeviceNameList[]; \ - extern device_hooks gDeviceHooks; \ - const char *gDriverName = #publicname; \ - int32 api_version = B_CUR_DRIVER_API_VERSION; \ - status_t init_hardware() \ - { \ - return __haiku_handle_fbsd_drivers_list(_fbsd_init_hardware); \ - } \ - status_t init_driver() \ - { \ - return __haiku_handle_fbsd_drivers_list(_fbsd_init_drivers); \ - } \ - void uninit_driver() \ - { \ - __haiku_handle_fbsd_drivers_list(_fbsd_uninit_drivers); \ - } \ - const char **publish_devices() \ - { return gDeviceNameList; } \ - device_hooks *find_device(const char *name) \ - { return &gDeviceHooks; } + HAIKU_FBSD_DRIVERS_CORE_GLUE(publicname) #define HAIKU_FBSD_WLAN_DRIVER_GLUE(publicname, name, busname) \ extern driver_t *DRIVER_MODULE_NAME(name, busname); \ diff --git a/src/libs/compat/freebsd11_network/driver.c b/src/libs/compat/freebsd11_network/driver.c index e99cc5acdc..2e231b69cd 100644 --- a/src/libs/compat/freebsd11_network/driver.c +++ b/src/libs/compat/freebsd11_network/driver.c @@ -96,62 +96,6 @@ get_pci_info(struct device *device) // #pragma mark - Haiku Driver API -status_t -_fbsd_init_hardware(driver_t *drivers[]) -{ - status_t status = B_ENTRY_NOT_FOUND; - device_t root; - pci_info *info; - driver_t *driver = NULL; - int i = 0; - - if (get_module(B_PCI_MODULE_NAME, (module_info **)&gPci) < B_OK) - return B_ERROR; - - status = init_root_device(&root); - if (status != B_OK) - goto err; - - for (info = get_pci_info(root); gPci->get_nth_pci_info(i, info) == B_OK; - i++) { - int index; - driver = NULL; - - for (index = 0; drivers[index] && gDeviceCount < MAX_DEVICES - && driver == NULL; index++) { - int result; - device_t device; - status = add_child_device(drivers[index], root, &device); - if (status < B_OK) - break; - - result = device->methods.probe(device); - if (result >= 0) { - TRACE(("%s, found %s at %d\n", gDriverName, - device_get_desc(device), i)); - driver = drivers[index]; - } - device_delete_child(root, device); - } - - if (driver != NULL) - break; - } - - device_delete_child(NULL, root); - - if (driver == NULL) { - status = B_ERROR; - TRACE(("%s: no hardware found.\n", gDriverName)); - } -err: - put_module(B_PCI_MODULE_NAME); - TRACE(("%s: status 0x%lx\n", gDriverName, status)); - - return status; -} - - status_t _fbsd_init_drivers(driver_t *drivers[]) {