From 0257ac8c1f85ef5e9ba270b878a5130d43ae50b8 Mon Sep 17 00:00:00 2001 From: Travis Geiselbrecht Date: Tue, 9 Nov 2021 00:44:55 -0800 Subject: [PATCH] [dev][pcnet32] get the pcnet32 driver building and working again Not enabled by default since it uses the experimental driver api and depends on lwip. But, builds and works if selected. --- dev/include/dev/driver.h | 2 +- dev/net/pcnet/pcnet.c | 11 ++++++++--- external/lib/lwip/sys_arch.c | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dev/include/dev/driver.h b/dev/include/dev/driver.h index a27b74fd..dcba6717 100644 --- a/dev/include/dev/driver.h +++ b/dev/include/dev/driver.h @@ -76,7 +76,7 @@ struct driver { } #define DEVICE_INSTANCE(type_, name_, config_, flags_) \ - extern struct driver concat(__driver_, type_); \ + extern const struct driver concat(__driver_, type_); \ struct device concat(__device_, concat(type_, concat(_, name_))) \ __ALIGNED(sizeof(void *)) __SECTION("devices") = { \ .name = #name_, \ diff --git a/dev/net/pcnet/pcnet.c b/dev/net/pcnet/pcnet.c index db97820b..0d89ef51 100644 --- a/dev/net/pcnet/pcnet.c +++ b/dev/net/pcnet/pcnet.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include @@ -136,8 +136,10 @@ static status_t pcnet_init(struct device *dev) { if (!config) return ERR_NOT_CONFIGURED; - if (pci_find_pci_device(&loc, config->device_id, config->vendor_id, config->index) != _PCI_SUCCESSFUL) + if (pci_find_pci_device(&loc, config->device_id, config->vendor_id, config->index) != _PCI_SUCCESSFUL) { + TRACEF("device not found\n"); return ERR_NOT_FOUND; + } struct pcnet_state *state = calloc(1, sizeof(struct pcnet_state)); if (!state) @@ -598,7 +600,10 @@ static const struct platform_pcnet_config pcnet0_config = { DEVICE_INSTANCE(netif, pcnet0, &pcnet0_config, 0); static void pcnet_init_hook(uint level) { - device_init(device_get_by_name(netif, pcnet0)); + status_t err = device_init(device_get_by_name(netif, pcnet0)); + if (err < 0) + return; + class_netif_add(device_get_by_name(netif, pcnet0)); } diff --git a/external/lib/lwip/sys_arch.c b/external/lib/lwip/sys_arch.c index dbc41fe1..d272b3fb 100644 --- a/external/lib/lwip/sys_arch.c +++ b/external/lib/lwip/sys_arch.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include