[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cdi-devel] [PATCH 3/3] Initialise PCI devices in the CDI library
* Instead of implementing the PCI scan in each driver, we can simply
move the logic into the CDI library. It enumerates all PCI devices and
calls init_device on all known drivers until it finds a driver that
can handle the device.
Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
e1000/main.c | 22 ----------------------
ne2k/main.c | 18 ------------------
pcnet/main.c | 18 ------------------
rtl8139/main.c | 18 ------------------
sis900/main.c | 21 ---------------------
5 files changed, 0 insertions(+), 97 deletions(-)
diff --git a/e1000/main.c b/e1000/main.c
index 229ec3f..faf6f2e 100644
--- a/e1000/main.c
+++ b/e1000/main.c
@@ -49,28 +49,6 @@ static int e1000_driver_init(void)
// Konstruktor der Vaterklasse
cdi_net_driver_init(&driver);
- // Passende PCI-Geraete suchen
- cdi_list_t pci_devices = cdi_list_create();
- cdi_pci_get_all_devices(pci_devices);
-
- struct cdi_device* device;
- struct cdi_pci_device* dev;
- int i;
- for (i = 0; (dev = cdi_list_get(pci_devices, i)); i++) {
- device = e1000_init_device((struct cdi_bus_data*) dev);
- if (device != NULL) {
- // TODO
- cdi_list_push(driver.drv.devices, device);
- } else {
- cdi_pci_device_destroy(dev);
- }
- }
-
- printf("e1000: %d Karten gefunden.\n",
- cdi_list_size(driver.drv.devices));
-
- cdi_list_destroy(pci_devices);
-
return 0;
}
diff --git a/ne2k/main.c b/ne2k/main.c
index e46e866..35f31b4 100644
--- a/ne2k/main.c
+++ b/ne2k/main.c
@@ -44,24 +44,6 @@ static int ne2k_driver_init(void)
// Konstruktor der Vaterklasse
cdi_net_driver_init(&ne2k_driver);
- // Passende PCI-Geraete suchen
- cdi_list_t pci_devices = cdi_list_create();
- cdi_pci_get_all_devices(pci_devices);
-
- struct cdi_pci_device* dev;
- struct cdi_device* device;
- int i;
- for (i = 0; (dev = cdi_list_get(pci_devices, i)); i++) {
- device = ne2k_init_device((struct cdi_bus_data*) dev);
- if (device != NULL) {
- cdi_list_push(ne2k_driver.drv.devices, device);
- } else {
- cdi_pci_device_destroy(dev);
- }
- }
-
- cdi_list_destroy(pci_devices);
-
return 0;
}
diff --git a/pcnet/main.c b/pcnet/main.c
index de05930..685d281 100644
--- a/pcnet/main.c
+++ b/pcnet/main.c
@@ -48,24 +48,6 @@ static int pcnet_driver_init(void)
// Konstruktor der Vaterklasse
cdi_net_driver_init(&pcnet_driver);
- // Passende PCI-Geraete suchen
- cdi_list_t pci_devices = cdi_list_create();
- cdi_pci_get_all_devices(pci_devices);
-
- struct cdi_pci_device* dev;
- struct cdi_device* device;
- int i;
- for (i = 0; (dev = cdi_list_get(pci_devices, i)); i++) {
- device = pcnet_init_device((struct cdi_bus_data*) dev);
- if (device) {
- cdi_list_push(pcnet_driver.drv.devices, device);
- } else {
- cdi_pci_device_destroy(dev);
- }
- }
-
- cdi_list_destroy(pci_devices);
-
return 0;
}
diff --git a/rtl8139/main.c b/rtl8139/main.c
index 3459e1f..b3eb095 100644
--- a/rtl8139/main.c
+++ b/rtl8139/main.c
@@ -47,24 +47,6 @@ static int rtl8139_driver_init(void)
// Konstruktor der Vaterklasse
cdi_net_driver_init(&rtl8139_driver);
- // Passende PCI-Geraete suchen
- cdi_list_t pci_devices = cdi_list_create();
- cdi_pci_get_all_devices(pci_devices);
-
- struct cdi_pci_device* dev;
- struct cdi_device* device;
- int i;
- for (i = 0; (dev = cdi_list_get(pci_devices, i)); i++) {
- device = rtl8139_init_device((struct cdi_bus_data*) dev);
- if (device != NULL) {
- cdi_list_push(rtl8139_driver.drv.devices, device);
- } else {
- cdi_pci_device_destroy(dev);
- }
- }
-
- cdi_list_destroy(pci_devices);
-
return 0;
}
diff --git a/sis900/main.c b/sis900/main.c
index f4f6a2c..93cb4dd 100644
--- a/sis900/main.c
+++ b/sis900/main.c
@@ -49,27 +49,6 @@ static int sis900_driver_init(void)
// Konstruktor der Vaterklasse
cdi_net_driver_init(&sis900_driver);
- // Passende PCI-Geraete suchen
- cdi_list_t pci_devices = cdi_list_create();
- cdi_pci_get_all_devices(pci_devices);
-
- struct cdi_pci_device* dev;
- struct cdi_device* device;
- int i;
- for (i = 0; (dev = cdi_list_get(pci_devices, i)); i++) {
- device = sis900_init_device((struct cdi_bus_data*) dev);
- if (device != NULL) {
- cdi_list_push(sis900_driver.drv.devices, device);
- } else {
- cdi_pci_device_destroy(dev);
- }
- }
-
- printf("sis900: %d Karten gefunden.\n",
- cdi_list_size(sis900_driver.drv.devices));
-
- cdi_list_destroy(pci_devices);
-
return 0;
}
--
1.6.0.2