Some more minor cleanups of em(4) driver:

- Destroy mutex in case of attach failure. [1]
  - Lock properly em_watchdog(). [1]
  - Lock properly em_sysctl_int_delay(). [1]
  - Remove unused global adapter linked list.
  - Remove unused dma_size field from struct em_dma_alloc.
  - Do not touch interface statistics, that must be edited
    only by upper layers. [1]

Submitted by:	yongari [1]
This commit is contained in:
glebius 2005-10-20 09:55:49 +00:00
parent dfc409a7f8
commit 8f54edce78
2 changed files with 10 additions and 36 deletions

View File

@ -44,13 +44,6 @@ POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/
int em_display_debug_stats = 0;
/*********************************************************************
* Linked list of board private structures for all NICs found
*********************************************************************/
struct adapter *em_adapter_list = NULL;
/*********************************************************************
* Driver version
*********************************************************************/
@ -326,11 +319,6 @@ em_attach(device_t dev)
adapter->unit = device_get_unit(dev);
EM_LOCK_INIT(adapter, device_get_nameunit(dev));
if (em_adapter_list != NULL)
em_adapter_list->prev = adapter;
adapter->next = em_adapter_list;
em_adapter_list = adapter;
/* SYSCTL stuff */
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
@ -511,6 +499,7 @@ err_rx_desc:
err_tx_desc:
err_pci:
em_free_pci_resources(adapter);
EM_LOCK_DESTROY(adapter);
return(error);
}
@ -561,14 +550,6 @@ em_detach(device_t dev)
adapter->rx_desc_base = NULL;
}
/* Remove from the adapter list */
if (em_adapter_list == adapter)
em_adapter_list = adapter->next;
if (adapter->next != NULL)
adapter->next->prev = adapter->prev;
if (adapter->prev != NULL)
adapter->prev->next = adapter->next;
EM_LOCK_DESTROY(adapter);
return(0);
@ -786,11 +767,13 @@ em_watchdog(struct ifnet *ifp)
struct adapter * adapter;
adapter = ifp->if_softc;
EM_LOCK(adapter);
/* If we are in this routine because of pause frames, then
* don't reset the hardware.
*/
if (E1000_READ_REG(&adapter->hw, STATUS) & E1000_STATUS_TXOFF) {
ifp->if_timer = EM_TX_TIMEOUT;
EM_UNLOCK(adapter);
return;
}
@ -798,11 +781,10 @@ em_watchdog(struct ifnet *ifp)
printf("em%d: watchdog timeout -- resetting\n", adapter->unit);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
em_init(adapter);
ifp->if_oerrors++;
return;
em_init_locked(adapter);
EM_UNLOCK(adapter);
}
/*********************************************************************
@ -2093,7 +2075,6 @@ em_dma_malloc(struct adapter *adapter, bus_size_t size,
goto fail_3;
}
dma->dma_size = size;
return (0);
fail_3:
@ -3193,10 +3174,6 @@ em_update_stats_counters(struct adapter *adapter)
}
ifp = adapter->ifp;
/* Fill out the OS statistics structure */
ifp->if_ibytes = adapter->stats.gorcl;
ifp->if_obytes = adapter->stats.gotcl;
ifp->if_imcasts = adapter->stats.mprc;
ifp->if_collisions = adapter->stats.colc;
/* Rx Errors */
@ -3358,10 +3335,8 @@ em_sysctl_int_delay(SYSCTL_HANDLER_ARGS)
int error;
int usecs;
int ticks;
int s;
info = (struct em_int_delay_info *)arg1;
adapter = info->adapter;
usecs = info->value;
error = sysctl_handle_int(oidp, &usecs, 0, req);
if (error != 0 || req->newptr == NULL)
@ -3370,8 +3345,10 @@ em_sysctl_int_delay(SYSCTL_HANDLER_ARGS)
return EINVAL;
info->value = usecs;
ticks = E1000_USECS_TO_TICKS(usecs);
adapter = info->adapter;
s = splimp();
EM_LOCK(adapter);
regval = E1000_READ_OFFSET(&adapter->hw, info->offset);
regval = (regval & ~0xffff) | (ticks & 0xffff);
/* Handle a few special cases. */
@ -3391,7 +3368,7 @@ em_sysctl_int_delay(SYSCTL_HANDLER_ARGS)
break;
}
E1000_WRITE_OFFSET(&adapter->hw, info->offset, regval);
splx(s);
EM_UNLOCK(adapter);
return 0;
}

View File

@ -282,7 +282,6 @@ struct em_dma_alloc {
bus_dma_tag_t dma_tag;
bus_dmamap_t dma_map;
bus_dma_segment_t dma_seg;
bus_size_t dma_size;
int dma_nseg;
};
@ -315,8 +314,6 @@ typedef struct _DESCRIPTOR_PAIR
/* Our adapter structure */
struct adapter {
struct ifnet *ifp;
struct adapter *next;
struct adapter *prev;
struct em_hw hw;
/* FreeBSD operating-system-specific structures */