Commit b9c58884 authored by Alexander Viro's avatar Alexander Viro Committed by Stephen Hemminger

[wan wanxl] eliminated hdlc_to_name() uses and a bunch of port->hdlc ones.

parent f31b6d76
...@@ -82,15 +82,9 @@ typedef struct card_t { ...@@ -82,15 +82,9 @@ typedef struct card_t {
static inline port_t* hdlc_to_port(hdlc_device *hdlc)
{
return (port_t*)hdlc;
}
static inline port_t* dev_to_port(struct net_device *dev) static inline port_t* dev_to_port(struct net_device *dev)
{ {
return hdlc_to_port(dev_to_hdlc(dev)); return (port_t *)(dev_to_hdlc(dev));
} }
...@@ -102,7 +96,7 @@ static inline struct net_device *port_to_dev(port_t* port) ...@@ -102,7 +96,7 @@ static inline struct net_device *port_to_dev(port_t* port)
static inline const char* port_name(port_t *port) static inline const char* port_name(port_t *port)
{ {
return hdlc_to_name((hdlc_device*)port); return port_to_dev(port)->name;
} }
...@@ -180,6 +174,8 @@ static inline void wanxl_cable_intr(port_t *port) ...@@ -180,6 +174,8 @@ static inline void wanxl_cable_intr(port_t *port)
/* Transmit complete interrupt service */ /* Transmit complete interrupt service */
static inline void wanxl_tx_intr(port_t *port) static inline void wanxl_tx_intr(port_t *port)
{ {
struct net_device *dev = port_to_dev(port);
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
while (1) { while (1) {
desc_t *desc = &get_status(port)->tx_descs[port->tx_in]; desc_t *desc = &get_status(port)->tx_descs[port->tx_in];
struct sk_buff *skb = port->tx_skbs[port->tx_in]; struct sk_buff *skb = port->tx_skbs[port->tx_in];
...@@ -187,17 +183,17 @@ static inline void wanxl_tx_intr(port_t *port) ...@@ -187,17 +183,17 @@ static inline void wanxl_tx_intr(port_t *port)
switch (desc->stat) { switch (desc->stat) {
case PACKET_FULL: case PACKET_FULL:
case PACKET_EMPTY: case PACKET_EMPTY:
netif_wake_queue(port_to_dev(port)); netif_wake_queue(dev);
return; return;
case PACKET_UNDERRUN: case PACKET_UNDERRUN:
port->hdlc.stats.tx_errors++; stats->tx_errors++;
port->hdlc.stats.tx_fifo_errors++; stats->tx_fifo_errors++;
break; break;
default: default:
port->hdlc.stats.tx_packets++; stats->tx_packets++;
port->hdlc.stats.tx_bytes += skb->len; stats->tx_bytes += skb->len;
} }
desc->stat = PACKET_EMPTY; /* Free descriptor */ desc->stat = PACKET_EMPTY; /* Free descriptor */
pci_unmap_single(port->card->pdev, desc->address, skb->len, pci_unmap_single(port->card->pdev, desc->address, skb->len,
...@@ -218,13 +214,14 @@ static inline void wanxl_rx_intr(card_t *card) ...@@ -218,13 +214,14 @@ static inline void wanxl_rx_intr(card_t *card)
struct sk_buff *skb = card->rx_skbs[card->rx_in]; struct sk_buff *skb = card->rx_skbs[card->rx_in];
port_t *port = card->ports[desc->stat & PACKET_PORT_MASK]; port_t *port = card->ports[desc->stat & PACKET_PORT_MASK];
struct net_device *dev = port_to_dev(port); struct net_device *dev = port_to_dev(port);
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
if ((desc->stat & PACKET_PORT_MASK) > card->n_ports) if ((desc->stat & PACKET_PORT_MASK) > card->n_ports)
printk(KERN_CRIT "wanXL %s: received packet for" printk(KERN_CRIT "wanXL %s: received packet for"
" nonexistent port\n", card_name(card->pdev)); " nonexistent port\n", card_name(card->pdev));
else if (!skb) else if (!skb)
port->hdlc.stats.rx_dropped++; stats->rx_dropped++;
else { else {
pci_unmap_single(card->pdev, desc->address, pci_unmap_single(card->pdev, desc->address,
...@@ -236,8 +233,8 @@ static inline void wanxl_rx_intr(card_t *card) ...@@ -236,8 +233,8 @@ static inline void wanxl_rx_intr(card_t *card)
skb->len); skb->len);
debug_frame(skb); debug_frame(skb);
#endif #endif
port->hdlc.stats.rx_packets++; stats->rx_packets++;
port->hdlc.stats.rx_bytes += skb->len; stats->rx_bytes += skb->len;
skb->mac.raw = skb->data; skb->mac.raw = skb->data;
skb->dev = dev; skb->dev = dev;
dev->last_rx = jiffies; dev->last_rx = jiffies;
...@@ -290,8 +287,7 @@ static irqreturn_t wanxl_intr(int irq, void* dev_id, struct pt_regs *regs) ...@@ -290,8 +287,7 @@ static irqreturn_t wanxl_intr(int irq, void* dev_id, struct pt_regs *regs)
static int wanxl_xmit(struct sk_buff *skb, struct net_device *dev) static int wanxl_xmit(struct sk_buff *skb, struct net_device *dev)
{ {
hdlc_device *hdlc = dev_to_hdlc(dev); port_t *port = dev_to_port(dev);
port_t *port = hdlc_to_port(hdlc);
desc_t *desc; desc_t *desc;
spin_lock(&port->lock); spin_lock(&port->lock);
...@@ -341,7 +337,7 @@ static int wanxl_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -341,7 +337,7 @@ static int wanxl_xmit(struct sk_buff *skb, struct net_device *dev)
static int wanxl_attach(struct net_device *dev, unsigned short encoding, static int wanxl_attach(struct net_device *dev, unsigned short encoding,
unsigned short parity) unsigned short parity)
{ {
port_t *port = hdlc_to_port(dev_to_hdlc(dev)); port_t *port = dev_to_port(dev);
if (encoding != ENCODING_NRZ && if (encoding != ENCODING_NRZ &&
encoding != ENCODING_NRZI) encoding != ENCODING_NRZI)
...@@ -365,8 +361,7 @@ static int wanxl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -365,8 +361,7 @@ static int wanxl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{ {
const size_t size = sizeof(sync_serial_settings); const size_t size = sizeof(sync_serial_settings);
sync_serial_settings line; sync_serial_settings line;
hdlc_device *hdlc = dev_to_hdlc(dev); port_t *port = dev_to_port(dev);
port_t *port = hdlc_to_port(hdlc);
if (cmd != SIOCWANDEV) if (cmd != SIOCWANDEV)
return hdlc_ioctl(dev, ifr, cmd); return hdlc_ioctl(dev, ifr, cmd);
...@@ -415,8 +410,7 @@ static int wanxl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -415,8 +410,7 @@ static int wanxl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
static int wanxl_open(struct net_device *dev) static int wanxl_open(struct net_device *dev)
{ {
hdlc_device *hdlc = dev_to_hdlc(dev); port_t *port = dev_to_port(dev);
port_t *port = hdlc_to_port(hdlc);
u8 *dbr = port->card->plx + PLX_DOORBELL_TO_CARD; u8 *dbr = port->card->plx + PLX_DOORBELL_TO_CARD;
unsigned long timeout; unsigned long timeout;
int i; int i;
...@@ -450,8 +444,7 @@ static int wanxl_open(struct net_device *dev) ...@@ -450,8 +444,7 @@ static int wanxl_open(struct net_device *dev)
static int wanxl_close(struct net_device *dev) static int wanxl_close(struct net_device *dev)
{ {
hdlc_device *hdlc = dev_to_hdlc(dev); port_t *port = dev_to_port(dev);
port_t *port = hdlc_to_port(hdlc);
unsigned long timeout; unsigned long timeout;
int i; int i;
...@@ -488,7 +481,7 @@ static int wanxl_close(struct net_device *dev) ...@@ -488,7 +481,7 @@ static int wanxl_close(struct net_device *dev)
static struct net_device_stats *wanxl_get_stats(struct net_device *dev) static struct net_device_stats *wanxl_get_stats(struct net_device *dev)
{ {
hdlc_device *hdlc = dev_to_hdlc(dev); hdlc_device *hdlc = dev_to_hdlc(dev);
port_t *port = hdlc_to_port(hdlc); port_t *port = dev_to_port(dev);
hdlc->stats.rx_over_errors = get_status(port)->rx_overruns; hdlc->stats.rx_over_errors = get_status(port)->rx_overruns;
hdlc->stats.rx_frame_errors = get_status(port)->rx_frame_errors; hdlc->stats.rx_frame_errors = get_status(port)->rx_frame_errors;
...@@ -540,8 +533,10 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev) ...@@ -540,8 +533,10 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev)
free_irq(card->irq, card); free_irq(card->irq, card);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
if (card->ports[i]) if (card->ports[i]) {
unregister_hdlc_device(&card->ports[i]->hdlc); struct net_device *dev = port_to_dev(card->ports[i]);
unregister_hdlc_device(dev_to_hdlc(dev));
}
wanxl_reset(card); wanxl_reset(card);
...@@ -711,16 +706,17 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, ...@@ -711,16 +706,17 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev,
for (i = 0; i < ports; i++) { for (i = 0; i < ports; i++) {
port_t *port = (void *)card + sizeof(card_t) + port_t *port = (void *)card + sizeof(card_t) +
i * sizeof(port_t); i * sizeof(port_t);
struct net_device *dev = hdlc_to_dev(&port->hdlc); struct net_device *dev = port_to_dev(port);
hdlc_device *hdlc = dev_to_hdlc(dev);
spin_lock_init(&port->lock); spin_lock_init(&port->lock);
SET_MODULE_OWNER(dev); SET_MODULE_OWNER(dev);
dev->tx_queue_len = 50; dev->tx_queue_len = 50;
dev->do_ioctl = wanxl_ioctl; dev->do_ioctl = wanxl_ioctl;
dev->open = wanxl_open; dev->open = wanxl_open;
dev->stop = wanxl_close; dev->stop = wanxl_close;
port->hdlc.attach = wanxl_attach; hdlc->attach = wanxl_attach;
port->hdlc.xmit = wanxl_xmit; hdlc->xmit = wanxl_xmit;
if(register_hdlc_device(&port->hdlc)) { if (register_hdlc_device(dev_to_hdlc(dev))) {
printk(KERN_ERR "wanXL %s: unable to register hdlc" printk(KERN_ERR "wanXL %s: unable to register hdlc"
" device\n", card_name(pdev)); " device\n", card_name(pdev));
wanxl_pci_remove_one(pdev); wanxl_pci_remove_one(pdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment