[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cdi-devel] [PATCH 4/7] e1000: Introduce e1000_model



This patch converts the existing PCI ID list into a list of model
structs, which we will extend to store model-specific options and
function pointers.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 e1000/device.c | 12 +++++-------
 e1000/device.h |  7 +++++++
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/e1000/device.c b/e1000/device.c
index ca516cf..112f44a 100644
--- a/e1000/device.c
+++ b/e1000/device.c
@@ -345,10 +345,7 @@ static uint64_t get_mac_address(struct e1000_device* device)
 
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
 
-static struct {
-    uint16_t vendor_id;
-    uint16_t device_id;
-} pci_id_list[] = {
+static struct e1000_model models[] = {
     { 0x8086, 0x1004 },
     { 0x8086, 0x100f },
     { 0x8086, 0x100e },
@@ -361,9 +358,9 @@ struct cdi_device* e1000_init_device(struct cdi_bus_data* bus_data)
     struct cdi_mem_area* buf;
     int i;
 
-    for (i = 0; i < ARRAY_SIZE(pci_id_list); i++) {
-        if (pci->vendor_id == pci_id_list[i].vendor_id
-            && pci->device_id == pci_id_list[i].device_id)
+    for (i = 0; i < ARRAY_SIZE(models); i++) {
+        if (pci->vendor_id == models[i].vendor_id
+            && pci->device_id == models[i].device_id)
         {
             goto found;
         }
@@ -380,6 +377,7 @@ found:
     netcard = buf->vaddr;
     memset(netcard, 0, sizeof(*netcard));
 
+    netcard->model = &models[i];
     netcard->phys = buf->paddr.items[0].start;
     netcard->net.dev.bus_data = (struct cdi_bus_data*) pci;
 
diff --git a/e1000/device.h b/e1000/device.h
index 7b0ae03..d424f19 100644
--- a/e1000/device.h
+++ b/e1000/device.h
@@ -161,6 +161,11 @@ struct e1000_rx_descriptor {
 } __attribute__((packed)) __attribute__((aligned (4)));
 CDI_BUILD_BUG_ON((sizeof(struct e1000_rx_descriptor) * RX_BUFFER_NUM) % 128);
 
+struct e1000_model {
+    uint16_t vendor_id;
+    uint16_t device_id;
+};
+
 struct e1000_device {
     struct cdi_net_device       net;
 
@@ -176,6 +181,8 @@ struct e1000_device {
 
     void*                       mem_base;
     uint8_t                     revision;
+
+    struct e1000_model*         model;
 };
 
 struct cdi_device* e1000_init_device(struct cdi_bus_data* bus_data);
-- 
2.1.4