Skip to content

Commit

Permalink
WAN: Convert generic HDLC drivers to netdev_ops.
Browse files Browse the repository at this point in the history
Also remove unneeded last_rx update from Synclink drivers.
Synclink part mostly by Stephen Hemminger.

Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Krzysztof Hałasa authored and David S. Miller committed Jan 21, 2009
1 parent dff3fde commit 991990a
Show file tree
Hide file tree
Showing 25 changed files with 186 additions and 133 deletions.
18 changes: 11 additions & 7 deletions drivers/char/pcmcia/synclink_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4311,10 +4311,17 @@ static void hdlcdev_rx(MGSLPC_INFO *info, char *buf, int size)
dev->stats.rx_bytes += size;

netif_rx(skb);

dev->last_rx = jiffies;
}

static const struct net_device_ops hdlcdev_ops = {
.ndo_open = hdlcdev_open,
.ndo_stop = hdlcdev_close,
.ndo_change_mtu = hdlc_change_mtu,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_do_ioctl = hdlcdev_ioctl,
.ndo_tx_timeout = hdlcdev_tx_timeout,
};

/**
* called by device driver when adding device instance
* do generic HDLC initialization
Expand All @@ -4341,11 +4348,8 @@ static int hdlcdev_init(MGSLPC_INFO *info)
dev->irq = info->irq_level;

/* network layer callbacks and settings */
dev->do_ioctl = hdlcdev_ioctl;
dev->open = hdlcdev_open;
dev->stop = hdlcdev_close;
dev->tx_timeout = hdlcdev_tx_timeout;
dev->watchdog_timeo = 10*HZ;
dev->netdev_ops = &hdlcdev_ops;
dev->watchdog_timeo = 10 * HZ;
dev->tx_queue_len = 50;

/* generic HDLC layer callbacks and settings */
Expand Down
18 changes: 11 additions & 7 deletions drivers/char/synclink.c
Original file line number Diff line number Diff line change
Expand Up @@ -8007,10 +8007,17 @@ static void hdlcdev_rx(struct mgsl_struct *info, char *buf, int size)
dev->stats.rx_bytes += size;

netif_rx(skb);

dev->last_rx = jiffies;
}

static const struct net_device_ops hdlcdev_ops = {
.ndo_open = hdlcdev_open,
.ndo_stop = hdlcdev_close,
.ndo_change_mtu = hdlc_change_mtu,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_do_ioctl = hdlcdev_ioctl,
.ndo_tx_timeout = hdlcdev_tx_timeout,
};

/**
* called by device driver when adding device instance
* do generic HDLC initialization
Expand Down Expand Up @@ -8038,11 +8045,8 @@ static int hdlcdev_init(struct mgsl_struct *info)
dev->dma = info->dma_level;

/* network layer callbacks and settings */
dev->do_ioctl = hdlcdev_ioctl;
dev->open = hdlcdev_open;
dev->stop = hdlcdev_close;
dev->tx_timeout = hdlcdev_tx_timeout;
dev->watchdog_timeo = 10*HZ;
dev->netdev_ops = &hdlcdev_ops;
dev->watchdog_timeo = 10 * HZ;
dev->tx_queue_len = 50;

/* generic HDLC layer callbacks and settings */
Expand Down
18 changes: 11 additions & 7 deletions drivers/char/synclink_gt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1763,10 +1763,17 @@ static void hdlcdev_rx(struct slgt_info *info, char *buf, int size)
dev->stats.rx_bytes += size;

netif_rx(skb);

dev->last_rx = jiffies;
}

static const struct net_device_ops hdlcdev_ops = {
.ndo_open = hdlcdev_open,
.ndo_stop = hdlcdev_close,
.ndo_change_mtu = hdlc_change_mtu,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_do_ioctl = hdlcdev_ioctl,
.ndo_tx_timeout = hdlcdev_tx_timeout,
};

/**
* called by device driver when adding device instance
* do generic HDLC initialization
Expand Down Expand Up @@ -1794,11 +1801,8 @@ static int hdlcdev_init(struct slgt_info *info)
dev->irq = info->irq_level;

/* network layer callbacks and settings */
dev->do_ioctl = hdlcdev_ioctl;
dev->open = hdlcdev_open;
dev->stop = hdlcdev_close;
dev->tx_timeout = hdlcdev_tx_timeout;
dev->watchdog_timeo = 10*HZ;
dev->netdev_ops = &hdlcdev_ops;
dev->watchdog_timeo = 10 * HZ;
dev->tx_queue_len = 50;

/* generic HDLC layer callbacks and settings */
Expand Down
18 changes: 11 additions & 7 deletions drivers/char/synclinkmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1907,10 +1907,17 @@ static void hdlcdev_rx(SLMP_INFO *info, char *buf, int size)
dev->stats.rx_bytes += size;

netif_rx(skb);

dev->last_rx = jiffies;
}

static const struct net_device_ops hdlcdev_ops = {
.ndo_open = hdlcdev_open,
.ndo_stop = hdlcdev_close,
.ndo_change_mtu = hdlc_change_mtu,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_do_ioctl = hdlcdev_ioctl,
.ndo_tx_timeout = hdlcdev_tx_timeout,
};

/**
* called by device driver when adding device instance
* do generic HDLC initialization
Expand Down Expand Up @@ -1938,11 +1945,8 @@ static int hdlcdev_init(SLMP_INFO *info)
dev->irq = info->irq_level;

/* network layer callbacks and settings */
dev->do_ioctl = hdlcdev_ioctl;
dev->open = hdlcdev_open;
dev->stop = hdlcdev_close;
dev->tx_timeout = hdlcdev_tx_timeout;
dev->watchdog_timeo = 10*HZ;
dev->netdev_ops = &hdlcdev_ops;
dev->watchdog_timeo = 10 * HZ;
dev->tx_queue_len = 50;

/* generic HDLC layer callbacks and settings */
Expand Down
12 changes: 8 additions & 4 deletions drivers/net/wan/c101.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,13 @@ static void c101_destroy_card(card_t *card)
kfree(card);
}


static const struct net_device_ops c101_ops = {
.ndo_open = c101_open,
.ndo_stop = c101_close,
.ndo_change_mtu = hdlc_change_mtu,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_do_ioctl = c101_ioctl,
};

static int __init c101_run(unsigned long irq, unsigned long winbase)
{
Expand Down Expand Up @@ -367,9 +373,7 @@ static int __init c101_run(unsigned long irq, unsigned long winbase)
dev->mem_start = winbase;
dev->mem_end = winbase + C101_MAPPED_RAM_SIZE - 1;
dev->tx_queue_len = 50;
dev->do_ioctl = c101_ioctl;
dev->open = c101_open;
dev->stop = c101_close;
dev->netdev_ops = &c101_ops;
hdlc->attach = sca_attach;
hdlc->xmit = sca_xmit;
card->settings.clock_type = CLOCK_EXT;
Expand Down
14 changes: 10 additions & 4 deletions drivers/net/wan/cosa.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,15 @@ static void __exit cosa_exit(void)
}
module_exit(cosa_exit);

static const struct net_device_ops cosa_ops = {
.ndo_open = cosa_net_open,
.ndo_stop = cosa_net_close,
.ndo_change_mtu = hdlc_change_mtu,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_do_ioctl = cosa_net_ioctl,
.ndo_tx_timeout = cosa_net_timeout,
};

static int cosa_probe(int base, int irq, int dma)
{
struct cosa_data *cosa = cosa_cards+nr_cards;
Expand Down Expand Up @@ -575,10 +584,7 @@ static int cosa_probe(int base, int irq, int dma)
}
dev_to_hdlc(chan->netdev)->attach = cosa_net_attach;
dev_to_hdlc(chan->netdev)->xmit = cosa_net_tx;
chan->netdev->open = cosa_net_open;
chan->netdev->stop = cosa_net_close;
chan->netdev->do_ioctl = cosa_net_ioctl;
chan->netdev->tx_timeout = cosa_net_timeout;
chan->netdev->netdev_ops = &cosa_ops;
chan->netdev->watchdog_timeo = TX_TIMEOUT;
chan->netdev->base_addr = chan->cosa->datareg;
chan->netdev->irq = chan->cosa->irq;
Expand Down
18 changes: 11 additions & 7 deletions drivers/net/wan/dscc4.c
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,15 @@ static inline int dscc4_set_quartz(struct dscc4_dev_priv *dpriv, int hz)
return ret;
}

static const struct net_device_ops dscc4_ops = {
.ndo_open = dscc4_open,
.ndo_stop = dscc4_close,
.ndo_change_mtu = hdlc_change_mtu,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_do_ioctl = dscc4_ioctl,
.ndo_tx_timeout = dscc4_tx_timeout,
};

static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr)
{
struct dscc4_pci_priv *ppriv;
Expand Down Expand Up @@ -916,13 +925,8 @@ static int dscc4_found1(struct pci_dev *pdev, void __iomem *ioaddr)
hdlc_device *hdlc = dev_to_hdlc(d);

d->base_addr = (unsigned long)ioaddr;
d->init = NULL;
d->irq = pdev->irq;
d->open = dscc4_open;
d->stop = dscc4_close;
d->set_multicast_list = NULL;
d->do_ioctl = dscc4_ioctl;
d->tx_timeout = dscc4_tx_timeout;
d->netdev_ops = &dscc4_ops;
d->watchdog_timeo = TX_TIMEOUT;
SET_NETDEV_DEV(d, &pdev->dev);

Expand Down Expand Up @@ -1048,7 +1052,7 @@ static int dscc4_open(struct net_device *dev)
struct dscc4_pci_priv *ppriv;
int ret = -EAGAIN;

if ((dscc4_loopback_check(dpriv) < 0) || !dev->hard_start_xmit)
if ((dscc4_loopback_check(dpriv) < 0))
goto err;

if ((ret = hdlc_open(dev)))
Expand Down
18 changes: 12 additions & 6 deletions drivers/net/wan/farsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -2424,6 +2424,15 @@ fst_init_card(struct fst_card_info *card)
type_strings[card->type], card->irq, card->nports);
}

static const struct net_device_ops fst_ops = {
.ndo_open = fst_open,
.ndo_stop = fst_close,
.ndo_change_mtu = hdlc_change_mtu,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_do_ioctl = fst_ioctl,
.ndo_tx_timeout = fst_tx_timeout,
};

/*
* Initialise card when detected.
* Returns 0 to indicate success, or errno otherwise.
Expand Down Expand Up @@ -2565,12 +2574,9 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->base_addr = card->pci_conf;
dev->irq = card->irq;

dev->tx_queue_len = FST_TX_QUEUE_LEN;
dev->open = fst_open;
dev->stop = fst_close;
dev->do_ioctl = fst_ioctl;
dev->watchdog_timeo = FST_TX_TIMEOUT;
dev->tx_timeout = fst_tx_timeout;
dev->netdev_ops = &fst_ops;
dev->tx_queue_len = FST_TX_QUEUE_LEN;
dev->watchdog_timeo = FST_TX_TIMEOUT;
hdlc->attach = fst_attach;
hdlc->xmit = fst_start_xmit;
}
Expand Down
14 changes: 11 additions & 3 deletions drivers/net/wan/hdlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static const char* version = "HDLC support module revision 1.22";

static struct hdlc_proto *first_proto;

static int hdlc_change_mtu(struct net_device *dev, int new_mtu)
int hdlc_change_mtu(struct net_device *dev, int new_mtu)
{
if ((new_mtu < 68) || (new_mtu > HDLC_MAX_MTU))
return -EINVAL;
Expand All @@ -66,7 +66,15 @@ static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev,
return hdlc->proto->netif_rx(skb);
}

int hdlc_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
hdlc_device *hdlc = dev_to_hdlc(dev);

if (hdlc->proto->xmit)
return hdlc->proto->xmit(skb, dev);

return hdlc->xmit(skb, dev); /* call hardware driver directly */
}

static inline void hdlc_proto_start(struct net_device *dev)
{
Expand Down Expand Up @@ -231,8 +239,6 @@ static void hdlc_setup_dev(struct net_device *dev)
dev->hard_header_len = 16;
dev->addr_len = 0;
dev->header_ops = &hdlc_null_ops;

dev->change_mtu = hdlc_change_mtu;
}

static void hdlc_setup(struct net_device *dev)
Expand Down Expand Up @@ -330,6 +336,8 @@ MODULE_AUTHOR("Krzysztof Halasa <khc@pm.waw.pl>");
MODULE_DESCRIPTION("HDLC support module");
MODULE_LICENSE("GPL v2");

EXPORT_SYMBOL(hdlc_change_mtu);
EXPORT_SYMBOL(hdlc_start_xmit);
EXPORT_SYMBOL(hdlc_open);
EXPORT_SYMBOL(hdlc_close);
EXPORT_SYMBOL(hdlc_ioctl);
Expand Down
1 change: 0 additions & 1 deletion drivers/net/wan/hdlc_cisco.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ static int cisco_ioctl(struct net_device *dev, struct ifreq *ifr)

memcpy(&state(hdlc)->settings, &new_settings, size);
spin_lock_init(&state(hdlc)->lock);
dev->hard_start_xmit = hdlc->xmit;
dev->header_ops = &cisco_header_ops;
dev->type = ARPHRD_CISCO;
netif_dormant_on(dev);
Expand Down
28 changes: 9 additions & 19 deletions drivers/net/wan/hdlc_fr.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,18 +444,6 @@ static int pvc_xmit(struct sk_buff *skb, struct net_device *dev)
return 0;
}



static int pvc_change_mtu(struct net_device *dev, int new_mtu)
{
if ((new_mtu < 68) || (new_mtu > HDLC_MAX_MTU))
return -EINVAL;
dev->mtu = new_mtu;
return 0;
}



static inline void fr_log_dlci_active(pvc_device *pvc)
{
printk(KERN_INFO "%s: DLCI %d [%s%s%s]%s %s\n",
Expand Down Expand Up @@ -1068,6 +1056,14 @@ static void pvc_setup(struct net_device *dev)
dev->addr_len = 2;
}

static const struct net_device_ops pvc_ops = {
.ndo_open = pvc_open,
.ndo_stop = pvc_close,
.ndo_change_mtu = hdlc_change_mtu,
.ndo_start_xmit = pvc_xmit,
.ndo_do_ioctl = pvc_ioctl,
};

static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
{
hdlc_device *hdlc = dev_to_hdlc(frad);
Expand Down Expand Up @@ -1104,11 +1100,7 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
*(__be16*)dev->dev_addr = htons(dlci);
dlci_to_q922(dev->broadcast, dlci);
}
dev->hard_start_xmit = pvc_xmit;
dev->open = pvc_open;
dev->stop = pvc_close;
dev->do_ioctl = pvc_ioctl;
dev->change_mtu = pvc_change_mtu;
dev->netdev_ops = &pvc_ops;
dev->mtu = HDLC_MAX_MTU;
dev->tx_queue_len = 0;
dev->ml_priv = pvc;
Expand Down Expand Up @@ -1260,8 +1252,6 @@ static int fr_ioctl(struct net_device *dev, struct ifreq *ifr)
state(hdlc)->dce_pvc_count = 0;
}
memcpy(&state(hdlc)->settings, &new_settings, size);

dev->hard_start_xmit = hdlc->xmit;
dev->type = ARPHRD_FRAD;
return 0;

Expand Down
2 changes: 0 additions & 2 deletions drivers/net/wan/hdlc_ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,6 @@ static int ppp_rx(struct sk_buff *skb)
return NET_RX_DROP;
}


static void ppp_timer(unsigned long arg)
{
struct proto *proto = (struct proto *)arg;
Expand Down Expand Up @@ -679,7 +678,6 @@ static int ppp_ioctl(struct net_device *dev, struct ifreq *ifr)
ppp->keepalive_interval = 10;
ppp->keepalive_timeout = 60;

dev->hard_start_xmit = hdlc->xmit;
dev->hard_header_len = sizeof(struct hdlc_header);
dev->header_ops = &ppp_header_ops;
dev->type = ARPHRD_PPP;
Expand Down
Loading

0 comments on commit 991990a

Please sign in to comment.