platform_set_drvdata(pdev, dev);
- sp = dev->priv;
+ sp = netdev_priv(dev);
sp->dev = dev;
sp->cfg = pdev->dev.platform_data;
dev->stop = &ar2313_close;
dev->hard_start_xmit = &ar2313_start_xmit;
- dev->get_stats = &ar2313_get_stats;
dev->set_multicast_list = &ar2313_multicast_list;
#ifdef TX_TIMEOUT
dev->tx_timeout = ar2313_tx_timeout;
static void ar2313_dump_regs(struct net_device *dev)
{
unsigned int *ptr, i;
- struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
ptr = (unsigned int *) sp->eth_regs;
for (i = 0; i < (sizeof(ETHERNET_STRUCT) / sizeof(unsigned int));
#ifdef TX_TIMEOUT
static void ar2313_tx_timeout(struct net_device *dev)
{
- struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
unsigned long flags;
#if DEBUG_TX
* Always listen to broadcasts and
* treat IFF bits independently
*/
- struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
unsigned int recognise;
recognise = sp->eth_regs->mac_control;
static void rx_tasklet_cleanup(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
/*
* Tasklet may be scheduled. Need to get it removed from the list
static void ar2313_free_descriptors(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
if (sp->rx_ring != NULL) {
kfree((void *) KSEG0ADDR(sp->rx_ring));
sp->rx_ring = NULL;
static int ar2313_allocate_descriptors(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
int size;
int j;
ar2313_descr_t *space;
*/
static void ar2313_init_cleanup(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
struct sk_buff *skb;
int j;
static int ar2313_setup_timer(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
init_timer(&sp->link_timer);
static void ar2313_link_timer_fn(unsigned long data)
{
struct net_device *dev = (struct net_device *) data;
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
// see if the link status changed
// This was needed to make sure we set the PHY to the
static void ar2313_check_link(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
u16 phyData;
phyData = mdiobus_read(&sp->mii_bus, sp->phy, MII_BMSR);
static int ar2313_reset_reg(struct net_device *dev)
{
- struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
unsigned int ethsal, ethsah;
unsigned int flags;
static int ar2313_init(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
int ecode = 0;
/*
/*
* Zero the stats before starting the interface
*/
- memset(&sp->stats, 0, sizeof(sp->stats));
+ memset(&dev->stats, 0, sizeof(dev->stats));
/*
* We load the ring here as there seem to be no way to tell the
static void ar2313_load_rx_ring(struct net_device *dev, int nr_bufs)
{
- struct ar2313_private *sp = ((struct net_device *) dev)->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
short i, idx;
idx = sp->rx_skbprd;
static int ar2313_rx_int(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
struct sk_buff *skb, *skb_new;
ar2313_descr_t *rxdesc;
unsigned int status;
#if DEBUG_RX
printk("%s: rx ERROR %08x\n", __FUNCTION__, status);
#endif
- sp->stats.rx_errors++;
- sp->stats.rx_dropped++;
+ dev->stats.rx_errors++;
+ dev->stats.rx_dropped++;
/* add statistics counters */
if (status & DMA_RX_ERR_CRC)
- sp->stats.rx_crc_errors++;
+ dev->stats.rx_crc_errors++;
if (status & DMA_RX_ERR_COL)
- sp->stats.rx_over_errors++;
+ dev->stats.rx_over_errors++;
if (status & DMA_RX_ERR_LENGTH)
- sp->stats.rx_length_errors++;
+ dev->stats.rx_length_errors++;
if (status & DMA_RX_ERR_RUNT)
- sp->stats.rx_over_errors++;
+ dev->stats.rx_over_errors++;
if (status & DMA_RX_ERR_DESC)
- sp->stats.rx_over_errors++;
+ dev->stats.rx_over_errors++;
} else {
/* alloc new buffer. */
skb_put(skb,
((status >> DMA_RX_LEN_SHIFT) & 0x3fff) - CRC_LEN);
- sp->stats.rx_bytes += skb->len;
+ dev->stats.rx_bytes += skb->len;
skb->protocol = eth_type_trans(skb, dev);
/* pass the packet to upper layers */
netif_rx(skb);
/* reset descriptor's curr_addr */
rxdesc->addr = virt_to_phys(skb_new->data);
- sp->stats.rx_packets++;
+ dev->stats.rx_packets++;
sp->rx_skb[idx] = skb_new;
} else {
- sp->stats.rx_dropped++;
+ dev->stats.rx_dropped++;
}
}
static void ar2313_tx_int(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
u32 idx;
struct sk_buff *skb;
ar2313_descr_t *txdesc;
txdesc->status = 0;
if (status & DMA_TX_ERROR) {
- sp->stats.tx_errors++;
- sp->stats.tx_dropped++;
+ dev->stats.tx_errors++;
+ dev->stats.tx_dropped++;
if (status & DMA_TX_ERR_UNDER)
- sp->stats.tx_fifo_errors++;
+ dev->stats.tx_fifo_errors++;
if (status & DMA_TX_ERR_HB)
- sp->stats.tx_heartbeat_errors++;
+ dev->stats.tx_heartbeat_errors++;
if (status & (DMA_TX_ERR_LOSS | DMA_TX_ERR_LINK))
- sp->stats.tx_carrier_errors++;
+ dev->stats.tx_carrier_errors++;
if (status & (DMA_TX_ERR_LATE |
DMA_TX_ERR_COL |
DMA_TX_ERR_JABBER | DMA_TX_ERR_DEFER))
- sp->stats.tx_aborted_errors++;
+ dev->stats.tx_aborted_errors++;
} else {
/* transmit OK */
- sp->stats.tx_packets++;
+ dev->stats.tx_packets++;
}
skb = sp->tx_skb[idx];
sp->tx_skb[idx] = NULL;
idx = DSC_NEXT(idx);
- sp->stats.tx_bytes += skb->len;
+ dev->stats.tx_bytes += skb->len;
dev_kfree_skb_irq(skb);
}
static void rx_tasklet_func(unsigned long data)
{
struct net_device *dev = (struct net_device *) data;
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
if (sp->unloading) {
return;
static void rx_schedule(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
sp->dma_regs->intr_ena &= ~DMA_STATUS_RI;
static irqreturn_t ar2313_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
unsigned int status, enabled;
/* clear interrupt */
static int ar2313_open(struct net_device *dev)
{
- struct ar2313_private *sp;
-
- sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
dev->mtu = 1500;
netif_start_queue(dev);
static void ar2313_halt(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
int j;
tasklet_disable(&sp->rx_tasklet);
static int ar2313_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
ar2313_descr_t *td;
u32 idx;
printk("%s: No space left to Tx\n", __FUNCTION__);
#endif
/* free skbuf and lie to the caller that we sent it out */
- sp->stats.tx_dropped++;
+ dev->stats.tx_dropped++;
dev_kfree_skb(skb);
/* restart transmitter in case locked */
static int ar2313_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
struct mii_ioctl_data *data = (struct mii_ioctl_data *) &ifr->ifr_data;
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
int ret;
switch (cmd) {
return -EOPNOTSUPP;
}
-static struct net_device_stats *ar2313_get_stats(struct net_device *dev)
-{
- struct ar2313_private *sp = dev->priv;
- return &sp->stats;
-}
-
-
static void ar2313_adjust_link(struct net_device *dev)
{
- struct ar2313_private *sp = dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
unsigned int mc;
if (!sp->phy_dev->link)
mdiobus_read(struct mii_bus *bus, int phy_addr, int regnum)
{
struct net_device *const dev = bus->priv;
- struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
volatile ETHERNET_STRUCT *ethernet = sp->phy_regs;
ethernet->mii_addr = MII_ADDR(phy_addr, regnum);
u16 value)
{
struct net_device *const dev = bus->priv;
- struct ar2313_private *sp = (struct ar2313_private *) dev->priv;
+ struct ar2313_private *sp = netdev_priv(dev);
volatile ETHERNET_STRUCT *ethernet = sp->phy_regs;
while (ethernet->mii_addr & MII_ADDR_BUSY);
static int mdiobus_probe (struct net_device *dev)
{
- struct ar2313_private *const sp = (struct ar2313_private *) dev->priv;
+ struct ar2313_private *const sp = netdev_priv(dev);
struct phy_device *phydev = NULL;
int phy_addr;