Commit 06aef211 authored by Alexander Viro's avatar Alexander Viro Committed by Stephen Hemminger

[wan pc300] more direct use of net_device

In pc300 replaced dev->hdlc with dev->dev (hdlc to net_device).  Killed a
bunch of ugliness in pc300_tty.c, killed hdlc_to_dev() uses.
parent 61fd4dc7
......@@ -331,7 +331,7 @@ typedef struct pc300dev {
uclong line_off;
#ifdef __KERNEL__
char name[16];
hdlc_device *hdlc;
struct net_device *dev;
void *private;
struct sk_buff *tx_skb;
......@@ -483,7 +483,7 @@ void rx_dma_start(pc300_t *, int);
void tx_dma_stop(pc300_t *, int);
void rx_dma_stop(pc300_t *, int);
int cpc_queue_xmit(struct sk_buff *, struct net_device *);
void cpc_net_rx(hdlc_device *);
void cpc_net_rx(struct net_device *);
void cpc_sca_status(pc300_t *, int);
int cpc_change_mtu(struct net_device *, int);
int cpc_ioctl(struct net_device *, struct ifreq *, int);
......
......@@ -1774,7 +1774,7 @@ void cpc_tx_timeout(struct net_device *dev)
pc300dev_t *d = (pc300dev_t *) dev->priv;
pc300ch_t *chan = (pc300ch_t *) d->chan;
pc300_t *card = (pc300_t *) chan->card;
struct net_device_stats *stats = &d->hdlc->stats;
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
int ch = chan->channel;
uclong flags;
ucchar ilar;
......@@ -1802,7 +1802,7 @@ int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
pc300dev_t *d = (pc300dev_t *) dev->priv;
pc300ch_t *chan = (pc300ch_t *) d->chan;
pc300_t *card = (pc300_t *) chan->card;
struct net_device_stats *stats = &d->hdlc->stats;
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
int ch = chan->channel;
uclong flags;
#ifdef PC300_DEBUG_TX
......@@ -1880,13 +1880,12 @@ int cpc_queue_xmit(struct sk_buff *skb, struct net_device *dev)
return 0;
}
void cpc_net_rx(hdlc_device * hdlc)
void cpc_net_rx(struct net_device *dev)
{
struct net_device *dev = hdlc_to_dev(hdlc);
pc300dev_t *d = (pc300dev_t *) dev->priv;
pc300ch_t *chan = (pc300ch_t *) d->chan;
pc300_t *card = (pc300_t *) chan->card;
struct net_device_stats *stats = &d->hdlc->stats;
struct net_device_stats *stats = &dev_to_hdlc(dev)->stats;
int ch = chan->channel;
#ifdef PC300_DEBUG_RX
int i;
......@@ -1975,7 +1974,7 @@ static void sca_tx_intr(pc300dev_t *dev)
pc300_t *card = (pc300_t *)chan->card;
int ch = chan->channel;
volatile pcsca_bd_t * ptdescr;
struct net_device_stats *stats = &dev->hdlc->stats;
struct net_device_stats *stats = &dev_to_hdlc(dev->dev)->stats;
/* Clean up descriptors from previous transmission */
ptdescr = (pcsca_bd_t *)(card->hw.rambase +
......@@ -1999,7 +1998,7 @@ static void sca_tx_intr(pc300dev_t *dev)
} else {
#endif
/* Tell the upper layer we are ready to transmit more packets */
netif_wake_queue((struct net_device*)dev->hdlc);
netif_wake_queue(dev->dev);
#ifdef CONFIG_PC300_MLPPP
}
#endif
......@@ -2017,8 +2016,8 @@ static void sca_intr(pc300_t * card)
for (ch = 0; ch < card->hw.nchan; ch++) {
pc300ch_t *chan = &card->chan[ch];
pc300dev_t *d = &chan->d;
hdlc_device *hdlc = d->hdlc;
struct net_device *dev = hdlc_to_dev(hdlc);
struct net_device *dev = d->dev;
hdlc_device *hdlc = dev_to_hdlc(dev);
spin_lock(&card->card_lock);
......@@ -2049,7 +2048,7 @@ static void sca_intr(pc300_t * card)
if ((cpc_readb(scabase + DSR_RX(ch)) & DSR_DE)) {
rx_dma_stop(card, ch);
}
cpc_net_rx(hdlc);
cpc_net_rx(dev);
/* Discard invalid frames */
hdlc->stats.rx_errors++;
hdlc->stats.rx_over_errors++;
......@@ -2073,10 +2072,10 @@ static void sca_intr(pc300_t * card)
/* verify if driver is TTY */
cpc_tty_receive(d);
} else {
cpc_net_rx(hdlc);
cpc_net_rx(dev);
}
#else
cpc_net_rx(hdlc);
cpc_net_rx(dev);
#endif
if (card->hw.type == PC300_TE) {
cpc_writeb(card->hw.falcbase +
......@@ -2818,12 +2817,7 @@ int cpc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
static struct net_device_stats *cpc_get_stats(struct net_device *dev)
{
pc300dev_t *d = (pc300dev_t *) dev->priv;
if (d)
return &d->hdlc->stats;
else
return NULL;
return &dev_to_hdlc(dev)->stats;
}
static int clock_rate_calc(uclong rate, uclong clock, int *br_io)
......@@ -3359,17 +3353,15 @@ static void cpc_init_card(pc300_t * card)
d->line_on = 0;
d->line_off = 0;
d->hdlc = (hdlc_device *) kmalloc(sizeof(hdlc_device), GFP_KERNEL);
if (d->hdlc == NULL)
dev = (struct net_device *) kmalloc(sizeof(hdlc_device), GFP_KERNEL);
if (dev == NULL)
continue;
memset(d->hdlc, 0, sizeof(hdlc_device));
memset(dev, 0, sizeof(hdlc_device));
hdlc = d->hdlc;
hdlc = dev_to_hdlc(dev);
hdlc->xmit = cpc_queue_xmit;
hdlc->attach = cpc_attach;
dev = hdlc_to_dev(hdlc);
d->dev = dev;
dev->mem_start = card->hw.ramphys;
dev->mem_end = card->hw.ramphys + card->hw.ramsize - 1;
dev->irq = card->hw.irq;
......@@ -3415,8 +3407,7 @@ static void cpc_init_card(pc300_t * card)
} else {
printk ("Dev%d on card(0x%08lx): unable to allocate i/f name.\n",
i + 1, card->hw.ramphys);
*(dev->name) = 0;
kfree(d->hdlc);
kfree(dev);
continue;
}
}
......@@ -3648,7 +3639,7 @@ static void __devexit cpc_remove_one(struct pci_dev *pdev)
cpc_readw(card->hw.plxbase + card->hw.intctl_reg) & ~(0x0040));
for (i = 0; i < card->hw.nchan; i++) {
unregister_hdlc_device(card->chan[i].d.hdlc);
unregister_hdlc_device(dev_to_hdlc(card->chan[i].d.dev));
}
iounmap((void *) card->hw.plxbase);
iounmap((void *) card->hw.scabase);
......
......@@ -152,8 +152,7 @@ static void cpc_tty_dtr_off(pc300dev_t *pc300dev)
int ch = pc300chan->channel;
unsigned long flags;
CPC_TTY_DBG("%s-tty: Clear signal DTR\n",
((struct net_device*)(pc300dev->hdlc))->name);
CPC_TTY_DBG("%s-tty: Clear signal DTR\n", pc300dev->dev->name);
CPC_TTY_LOCK(card, flags);
cpc_writeb(card->hw.scabase + M_REG(CTL,ch),
cpc_readb(card->hw.scabase+M_REG(CTL,ch))& CTL_DTR);
......@@ -170,8 +169,7 @@ static void cpc_tty_dtr_on(pc300dev_t *pc300dev)
int ch = pc300chan->channel;
unsigned long flags;
CPC_TTY_DBG("%s-tty: Set signal DTR\n",
((struct net_device*)(pc300dev->hdlc))->name);
CPC_TTY_DBG("%s-tty: Set signal DTR\n", pc300dev->dev->name);
CPC_TTY_LOCK(card, flags);
cpc_writeb(card->hw.scabase + M_REG(CTL,ch),
cpc_readb(card->hw.scabase+M_REG(CTL,ch))& ~CTL_DTR);
......@@ -194,17 +192,17 @@ void cpc_tty_init(pc300dev_t *pc300dev)
st_cpc_tty_area * cpc_tty;
/* hdlcX - X=interface number */
port = ((struct net_device*)(pc300dev->hdlc))->name[4] - '0';
port = pc300dev->dev->name[4] - '0';
if (port >= CPC_TTY_NPORTS) {
printk("%s-tty: invalid interface selected (0-%i): %i",
((struct net_device*)(pc300dev->hdlc))->name,
pc300dev->dev->name,
CPC_TTY_NPORTS-1,port);
return;
}
if (cpc_tty_cnt == 0) { /* first TTY connection -> register driver */
CPC_TTY_DBG("%s-tty: driver init, major:%i, minor range:%i=%i\n",
((struct net_device*)(pc300dev->hdlc))->name,
pc300dev->dev->name,
CPC_TTY_MAJOR, CPC_TTY_MINOR_START,
CPC_TTY_MINOR_START+CPC_TTY_NPORTS);
/* initialize tty driver struct */
......@@ -236,7 +234,7 @@ void cpc_tty_init(pc300dev_t *pc300dev)
/* register the TTY driver */
if (tty_register_driver(&serial_drv)) {
printk("%s-tty: Failed to register serial driver! ",
((struct net_device*)(pc300dev->hdlc))->name);
pc300dev->dev->name);
return;
}
......@@ -248,7 +246,7 @@ void cpc_tty_init(pc300dev_t *pc300dev)
if (cpc_tty->state != CPC_TTY_ST_IDLE) {
CPC_TTY_DBG("%s-tty: TTY port %i, already in use.\n",
((struct net_device*)(pc300dev->hdlc))->name,port);
pc300dev->dev->name, port);
return;
}
......@@ -265,11 +263,11 @@ void cpc_tty_init(pc300dev_t *pc300dev)
pc300dev->cpc_tty = (void *)cpc_tty;
aux = strlen(((struct net_device*)(pc300dev->hdlc))->name);
memcpy(cpc_tty->name,((struct net_device*)(pc300dev->hdlc))->name,aux);
aux = strlen(pc300dev->dev->name);
memcpy(cpc_tty->name, pc300dev->dev->name, aux);
memcpy(&cpc_tty->name[aux], "-tty", 5);
cpc_open((struct net_device *)pc300dev->hdlc);
cpc_open(pc300dev->dev);
cpc_tty_dtr_off(pc300dev);
CPC_TTY_DBG("%s: Initializing TTY Sync Driver, tty major#%d minor#%i\n",
......@@ -454,7 +452,7 @@ static int cpc_tty_write(struct tty_struct *tty, int from_user,
(from_user)?"from user" : "from kernel",count);
pc300chan = (pc300ch_t *)((pc300dev_t*)cpc_tty->pc300dev)->chan;
stats = &((pc300dev_t*)cpc_tty->pc300dev)->hdlc->stats;
stats = &dev_to_hdlc(((pc300dev_t*)cpc_tty->pc300dev)->dev)->stats;
card = (pc300_t *) pc300chan->card;
ch = pc300chan->channel;
......@@ -740,7 +738,7 @@ void cpc_tty_receive(pc300dev_t *pc300dev)
pc300_t *card = (pc300_t *)pc300chan->card;
int ch = pc300chan->channel;
volatile pcsca_bd_t * ptdescr;
struct net_device_stats *stats = &pc300dev->hdlc->stats;
struct net_device_stats *stats = &dev_to_hdlc(pc300dev->dev)->stats;
int rx_len, rx_aux;
volatile unsigned char status;
unsigned short first_bd = pc300chan->rx_first_bd;
......@@ -916,7 +914,7 @@ static int cpc_tty_send_to_card(pc300dev_t *dev,void* buf, int len)
pc300ch_t *chan = (pc300ch_t *)dev->chan;
pc300_t *card = (pc300_t *)chan->card;
int ch = chan->channel;
struct net_device_stats *stats = &dev->hdlc->stats;
struct net_device_stats *stats = &dev_to_hdlc(dev->dev)->stats;
unsigned long flags;
volatile pcsca_bd_t * ptdescr;
int i, nchar;
......@@ -1000,19 +998,18 @@ static void cpc_tty_trace(pc300dev_t *dev, char* buf, int len, char rxtx)
if ((skb = dev_alloc_skb(10 + len)) == NULL) {
/* out of memory */
CPC_TTY_DBG("%s: tty_trace - out of memory\n",
((struct net_device *)(dev->hdlc))->name);
CPC_TTY_DBG("%s: tty_trace - out of memory\n", dev->dev->name);
return;
}
skb_put (skb, 10 + len);
skb->dev = (struct net_device *) dev->hdlc;
skb->dev = dev->dev;
skb->protocol = htons(ETH_P_CUST);
skb->mac.raw = skb->data;
skb->pkt_type = PACKET_HOST;
skb->len = 10 + len;
memcpy(skb->data,((struct net_device *)(dev->hdlc))->name,5);
memcpy(skb->data,dev->dev->name,5);
skb->data[5] = '[';
skb->data[6] = rxtx;
skb->data[7] = ']';
......@@ -1034,15 +1031,14 @@ void cpc_tty_unregister_service(pc300dev_t *pc300dev)
int res;
if ((cpc_tty= (st_cpc_tty_area *) pc300dev->cpc_tty) == 0) {
CPC_TTY_DBG("%s: interface is not TTY\n",
((struct net_device *)(pc300dev->hdlc))->name);
CPC_TTY_DBG("%s: interface is not TTY\n", pc300dev->dev->name);
return;
}
CPC_TTY_DBG("%s: cpc_tty_unregister_service", cpc_tty->name);
if (cpc_tty->pc300dev != pc300dev) {
CPC_TTY_DBG("%s: invalid tty ptr=%s\n",
((struct net_device *)(pc300dev->hdlc))->name, cpc_tty->name);
pc300dev->dev->name, cpc_tty->name);
return;
}
......
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