From c360d0a60e57217733e00b5ad7c4cf3a94a2b07e Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:36:15 -0500 Subject: [wan lapb] beginning of cleanups Beginning of lapb cleanups: lapb_register gets net_device along with the "token" and it gets stored in lapb_cb (token argument will die later). --- include/linux/lapb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/linux') diff --git a/include/linux/lapb.h b/include/linux/lapb.h index 2eeb76f2cf5c..602326af0d64 100644 --- a/include/linux/lapb.h +++ b/include/linux/lapb.h @@ -44,7 +44,7 @@ struct lapb_parms_struct { unsigned int mode; }; -extern int lapb_register(void *token, struct lapb_register_struct *callbacks); +extern int lapb_register(struct net_device *dev, void *token, struct lapb_register_struct *callbacks); extern int lapb_unregister(void *token); extern int lapb_getparms(void *token, struct lapb_parms_struct *parms); extern int lapb_setparms(void *token, struct lapb_parms_struct *parms); -- cgit v1.2.3 From a01d4ab4699e5947109d09f71067631f3bcac5b8 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:37:28 -0500 Subject: [wan lapb] switch to use net_device instead of custom token lapb functions that used to take a token to select lapb_cb they'll deal with are switched to getting net_device instead. Callbacks switched to using lapb->dev instead of lapb->token. --- drivers/net/wan/comx-proto-lapb.c | 46 ++++++++++++++++----------------- drivers/net/wan/hdlc_x25.c | 40 ++++++++++++++--------------- drivers/net/wan/lapbether.c | 31 ++++++++++------------ drivers/net/wan/x25_asy.c | 24 ++++++++--------- include/linux/lapb.h | 26 +++++++++---------- net/lapb/lapb_iface.c | 54 ++++++++++++++++++--------------------- 6 files changed, 105 insertions(+), 116 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/comx-proto-lapb.c b/drivers/net/wan/comx-proto-lapb.c index 6344c4566b8c..ec6f4b48b235 100644 --- a/drivers/net/wan/comx-proto-lapb.c +++ b/drivers/net/wan/comx-proto-lapb.c @@ -44,7 +44,7 @@ static void comxlapb_rx(struct net_device *dev, struct sk_buff *skb) if (!dev || !dev->priv) { dev_kfree_skb(skb); } else { - lapb_data_received(dev->priv, skb); + lapb_data_received(dev, skb); } } @@ -82,7 +82,7 @@ static int comxlapb_open(struct net_device *dev) return -ENODEV; } - err = lapb_connect_request(ch); + err = lapb_connect_request(dev); if (ch->debug_flags & DEBUG_COMX_LAPB) { comx_debug(dev, "%s: lapb opened, error code: %d\n", @@ -108,7 +108,7 @@ static int comxlapb_close(struct net_device *dev) comx_debug(dev, "%s: lapb closed\n", dev->name); } - lapb_disconnect_request(ch); + lapb_disconnect_request(dev); ch->init_status &= ~LINE_OPEN; ch->line_status &= ~PROTO_UP; @@ -130,11 +130,11 @@ static int comxlapb_xmit(struct sk_buff *skb, struct net_device *dev) case 0x00: break; // transmit case 0x01: - lapb_connect_request(ch); + lapb_connect_request(dev); kfree_skb(skb); return 0; case 0x02: - lapb_disconnect_request(ch); + lapb_disconnect_request(dev); default: kfree_skb(skb); return 0; @@ -145,7 +145,7 @@ static int comxlapb_xmit(struct sk_buff *skb, struct net_device *dev) netif_stop_queue(dev); if ((skb2 = skb_clone(skb, GFP_ATOMIC)) != NULL) { - lapb_data_request(ch, skb2); + lapb_data_request(dev, skb2); } return FRAME_ACCEPTED; @@ -157,7 +157,7 @@ static int comxlapb_statistics(struct net_device *dev, char *page) int len = 0; len += sprintf(page + len, "Line status: "); - if (lapb_getparms(dev->priv, &parms) != LAPB_OK) { + if (lapb_getparms(dev, &parms) != LAPB_OK) { len += sprintf(page + len, "not initialized\n"); return len; } @@ -178,7 +178,7 @@ static int comxlapb_read_proc(char *page, char **start, off_t off, int count, struct lapb_parms_struct parms; int len = 0; - if (lapb_getparms(dev->priv, &parms)) { + if (lapb_getparms(dev, &parms)) { return -ENODEV; } @@ -223,7 +223,7 @@ static int comxlapb_write_proc(struct file *file, const char *buffer, unsigned long parm; char *page; - if (lapb_getparms(dev->priv, &parms)) { + if (lapb_getparms(dev, &parms)) { return -ENODEV; } @@ -243,23 +243,23 @@ static int comxlapb_write_proc(struct file *file, const char *buffer, parm=simple_strtoul(page,NULL,10); if (parm > 0 && parm < 100) { parms.t1=parm; - lapb_setparms(dev->priv, &parms); + lapb_setparms(dev, &parms); } } else if (strcmp(entry->name, FILENAME_T2) == 0) { parm=simple_strtoul(page, NULL, 10); if (parm > 0 && parm < 100) { parms.t2=parm; - lapb_setparms(dev->priv, &parms); + lapb_setparms(dev, &parms); } } else if (strcmp(entry->name, FILENAME_N2) == 0) { parm=simple_strtoul(page, NULL, 10); if (parm > 0 && parm < 100) { parms.n2=parm; - lapb_setparms(dev->priv, &parms); + lapb_setparms(dev, &parms); } } else if (strcmp(entry->name, FILENAME_WINDOW) == 0) { parms.window = simple_strtoul(page, NULL, 10); - lapb_setparms(dev->priv, &parms); + lapb_setparms(dev, &parms); } else if (strcmp(entry->name, FILENAME_MODE) == 0) { if (comx_strcasecmp(page, "dte") == 0) { parms.mode &= ~(LAPB_DCE | LAPB_DTE); @@ -276,7 +276,7 @@ static int comxlapb_write_proc(struct file *file, const char *buffer, parms.mode &= ~LAPB_STANDARD; parms.mode |= LAPB_EXTENDED; } - lapb_setparms(dev->priv, &parms); + lapb_setparms(dev, &parms); } else { printk(KERN_ERR "comxlapb_write_proc: internal error, filename %s\n", entry->name); @@ -287,9 +287,9 @@ static int comxlapb_write_proc(struct file *file, const char *buffer, return count; } -static void comxlapb_connected(void *token, int reason) +static void comxlapb_connected(struct net_device *dev, int reason) { - struct comx_channel *ch = token; + struct comx_channel *ch = dev->priv; struct proc_dir_entry *comxdir = ch->procdir->subdir; if (ch->debug_flags & DEBUG_COMX_LAPB) { @@ -327,9 +327,9 @@ static void comxlapb_connected(void *token, int reason) comx_status(ch->dev, ch->line_status); } -static void comxlapb_disconnected(void *token, int reason) +static void comxlapb_disconnected(struct net_device *dev, int reason) { - struct comx_channel *ch = token; + struct comx_channel *ch = dev->priv; struct proc_dir_entry *comxdir = ch->procdir->subdir; if (ch->debug_flags & DEBUG_COMX_LAPB) { @@ -366,9 +366,9 @@ static void comxlapb_disconnected(void *token, int reason) comx_status(ch->dev, ch->line_status); } -static int comxlapb_data_indication(void *token, struct sk_buff *skb) +static int comxlapb_data_indication(struct net_device *dev, struct sk_buff *skb) { - struct comx_channel *ch = token; + struct comx_channel *ch = dev->priv; if (ch->dev->type == ARPHRD_X25) { skb_push(skb, 1); @@ -387,9 +387,9 @@ static int comxlapb_data_indication(void *token, struct sk_buff *skb) return comx_rx(ch->dev, skb); } -static void comxlapb_data_transmit(void *token, struct sk_buff *skb) +static void comxlapb_data_transmit(struct net_device *dev, struct sk_buff *skb) { - struct comx_channel *ch = token; + struct comx_channel *ch = dev->priv; if (ch->HW_send_packet) { ch->HW_send_packet(ch->dev, skb); @@ -417,7 +417,7 @@ static int comxlapb_exit(struct net_device *dev) if (ch->debug_flags & DEBUG_COMX_LAPB) { comx_debug(dev, "%s: unregistering lapb\n", dev->name); } - lapb_unregister(dev->priv); + lapb_unregister(dev); remove_proc_entry(FILENAME_T1, ch->procdir); remove_proc_entry(FILENAME_T2, ch->procdir); diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c index 55adca984e65..ac81b10189ea 100644 --- a/drivers/net/wan/hdlc_x25.c +++ b/drivers/net/wan/hdlc_x25.c @@ -25,21 +25,20 @@ /* These functions are callbacks called by LAPB layer */ -static void x25_connect_disconnect(void *token, int reason, int code) +static void x25_connect_disconnect(struct net_device *dev, int reason, int code) { - hdlc_device *hdlc = token; struct sk_buff *skb; unsigned char *ptr; if ((skb = dev_alloc_skb(1)) == NULL) { - printk(KERN_ERR "%s: out of memory\n", hdlc_to_name(hdlc)); + printk(KERN_ERR "%s: out of memory\n", dev->name); return; } ptr = skb_put(skb, 1); *ptr = code; - skb->dev = hdlc_to_dev(hdlc); + skb->dev = dev; skb->protocol = htons(ETH_P_X25); skb->mac.raw = skb->data; skb->pkt_type = PACKET_HOST; @@ -49,23 +48,22 @@ static void x25_connect_disconnect(void *token, int reason, int code) -static void x25_connected(void *token, int reason) +static void x25_connected(struct net_device *dev, int reason) { - x25_connect_disconnect(token, reason, 1); + x25_connect_disconnect(dev, reason, 1); } -static void x25_disconnected(void *token, int reason) +static void x25_disconnected(struct net_device *dev, int reason) { - x25_connect_disconnect(token, reason, 2); + x25_connect_disconnect(dev, reason, 2); } -static int x25_data_indication(void *token, struct sk_buff *skb) +static int x25_data_indication(struct net_device *dev, struct sk_buff *skb) { - hdlc_device *hdlc = token; unsigned char *ptr; skb_push(skb, 1); @@ -76,7 +74,7 @@ static int x25_data_indication(void *token, struct sk_buff *skb) ptr = skb->data; *ptr = 0; - skb->dev = hdlc_to_dev(hdlc); + skb->dev = dev; skb->protocol = htons(ETH_P_X25); skb->mac.raw = skb->data; skb->pkt_type = PACKET_HOST; @@ -86,10 +84,10 @@ static int x25_data_indication(void *token, struct sk_buff *skb) -static void x25_data_transmit(void *token, struct sk_buff *skb) +static void x25_data_transmit(struct net_device *dev, struct sk_buff *skb) { - hdlc_device *hdlc = token; - hdlc->xmit(skb, hdlc_to_dev(hdlc)); /* Ignore return value :-( */ + hdlc_device *hdlc = dev_to_hdlc(dev); + hdlc->xmit(skb, dev); /* Ignore return value :-( */ } @@ -104,15 +102,15 @@ static int x25_xmit(struct sk_buff *skb, struct net_device *dev) switch (skb->data[0]) { case 0: /* Data to be transmitted */ skb_pull(skb, 1); - if ((result = lapb_data_request(hdlc, skb)) != LAPB_OK) + if ((result = lapb_data_request(dev, skb)) != LAPB_OK) dev_kfree_skb(skb); return 0; case 1: - if ((result = lapb_connect_request(hdlc))!= LAPB_OK) { + if ((result = lapb_connect_request(dev))!= LAPB_OK) { if (result == LAPB_CONNECTED) /* Send connect confirm. msg to level 3 */ - x25_connected(hdlc, 0); + x25_connected(dev, 0); else printk(KERN_ERR "%s: LAPB connect request " "failed, error code = %i\n", @@ -121,10 +119,10 @@ static int x25_xmit(struct sk_buff *skb, struct net_device *dev) break; case 2: - if ((result = lapb_disconnect_request(hdlc)) != LAPB_OK) { + if ((result = lapb_disconnect_request(dev)) != LAPB_OK) { if (result == LAPB_NOTCONNECTED) /* Send disconnect confirm. msg to level 3 */ - x25_disconnected(hdlc, 0); + x25_disconnected(dev, 0); else printk(KERN_ERR "%s: LAPB disconnect request " "failed, error code = %i\n", @@ -164,7 +162,7 @@ static int x25_open(hdlc_device *hdlc) static void x25_close(hdlc_device *hdlc) { - lapb_unregister(hdlc); + lapb_unregister(hdlc_to_dev(hdlc)); } @@ -178,7 +176,7 @@ static int x25_rx(struct sk_buff *skb) return NET_RX_DROP; } - if (lapb_data_received(hdlc, skb) == LAPB_OK) + if (lapb_data_received(skb->dev, skb) == LAPB_OK) return NET_RX_SUCCESS; hdlc->stats.rx_errors++; diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c index 722f8cd00427..7d280626c76c 100644 --- a/drivers/net/wan/lapbether.c +++ b/drivers/net/wan/lapbether.c @@ -110,7 +110,7 @@ static int lapbeth_rcv(struct sk_buff *skb, struct net_device *dev, struct packe skb_pull(skb, 2); /* Remove the length bytes */ skb_trim(skb, len); /* Set the length of the data */ - if ((err = lapb_data_received(lapbeth, skb)) != LAPB_OK) { + if ((err = lapb_data_received(lapbeth->axdev, skb)) != LAPB_OK) { printk(KERN_DEBUG "lapbether: lapb_data_received err - %d\n", err); goto drop_unlock; } @@ -125,9 +125,8 @@ drop: return 0; } -static int lapbeth_data_indication(void *token, struct sk_buff *skb) +static int lapbeth_data_indication(struct net_device *dev, struct sk_buff *skb) { - struct lapbethdev *lapbeth = (struct lapbethdev *)token; unsigned char *ptr; skb_push(skb, 1); @@ -138,7 +137,7 @@ static int lapbeth_data_indication(void *token, struct sk_buff *skb) ptr = skb->data; *ptr = 0x00; - skb->dev = lapbeth->axdev; + skb->dev = dev; skb->protocol = htons(ETH_P_X25); skb->mac.raw = skb->data; skb->pkt_type = PACKET_HOST; @@ -152,7 +151,6 @@ static int lapbeth_data_indication(void *token, struct sk_buff *skb) */ static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev) { - struct lapbethdev *lapbeth = (struct lapbethdev *)dev->priv; int err = -ENODEV; /* @@ -168,12 +166,12 @@ static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev) err = 0; break; case 0x01: - if ((err = lapb_connect_request(lapbeth)) != LAPB_OK) + if ((err = lapb_connect_request(dev)) != LAPB_OK) printk(KERN_ERR "lapbeth: lapb_connect_request " "error: %d\n", err); goto drop_ok; case 0x02: - if ((err = lapb_disconnect_request(lapbeth)) != LAPB_OK) + if ((err = lapb_disconnect_request(dev)) != LAPB_OK) printk(KERN_ERR "lapbeth: lapb_disconnect_request " "err: %d\n", err); /* Fall thru */ @@ -183,7 +181,7 @@ static int lapbeth_xmit(struct sk_buff *skb, struct net_device *dev) skb_pull(skb, 1); - if ((err = lapb_data_request(lapbeth, skb)) != LAPB_OK) { + if ((err = lapb_data_request(dev, skb)) != LAPB_OK) { printk(KERN_ERR "lapbeth: lapb_data_request error - %d\n", err); err = -ENOMEM; goto drop; @@ -198,9 +196,9 @@ drop: goto out; } -static void lapbeth_data_transmit(void *token, struct sk_buff *skb) +static void lapbeth_data_transmit(struct net_device *ndev, struct sk_buff *skb) { - struct lapbethdev *lapbeth = (struct lapbethdev *)token; + struct lapbethdev *lapbeth = ndev->priv; unsigned char *ptr; struct net_device *dev; int size = skb->len; @@ -222,9 +220,8 @@ static void lapbeth_data_transmit(void *token, struct sk_buff *skb) dev_queue_xmit(skb); } -static void lapbeth_connected(void *token, int reason) +static void lapbeth_connected(struct net_device *dev, int reason) { - struct lapbethdev *lapbeth = (struct lapbethdev *)token; unsigned char *ptr; struct sk_buff *skb = dev_alloc_skb(1); @@ -236,7 +233,7 @@ static void lapbeth_connected(void *token, int reason) ptr = skb_put(skb, 1); *ptr = 0x01; - skb->dev = lapbeth->axdev; + skb->dev = dev; skb->protocol = htons(ETH_P_X25); skb->mac.raw = skb->data; skb->pkt_type = PACKET_HOST; @@ -245,9 +242,8 @@ static void lapbeth_connected(void *token, int reason) netif_rx(skb); } -static void lapbeth_disconnected(void *token, int reason) +static void lapbeth_disconnected(struct net_device *dev, int reason) { - struct lapbethdev *lapbeth = (struct lapbethdev *)token; unsigned char *ptr; struct sk_buff *skb = dev_alloc_skb(1); @@ -259,7 +255,7 @@ static void lapbeth_disconnected(void *token, int reason) ptr = skb_put(skb, 1); *ptr = 0x02; - skb->dev = lapbeth->axdev; + skb->dev = dev; skb->protocol = htons(ETH_P_X25); skb->mac.raw = skb->data; skb->pkt_type = PACKET_HOST; @@ -318,12 +314,11 @@ static int lapbeth_open(struct net_device *dev) static int lapbeth_close(struct net_device *dev) { - struct lapbethdev *lapbeth = (struct lapbethdev *)dev->priv; int err; netif_stop_queue(dev); - if ((err = lapb_unregister(lapbeth)) != LAPB_OK) + if ((err = lapb_unregister(dev)) != LAPB_OK) printk(KERN_ERR "lapbeth: lapb_unregister error - %d\n", err); return 0; diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index b13cef08f59a..bebd9502a46f 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c @@ -213,7 +213,7 @@ static void x25_asy_bump(struct x25_asy *sl) memcpy(skb_put(skb,count), sl->rbuff, count); skb->mac.raw=skb->data; skb->protocol=htons(ETH_P_X25); - if((err=lapb_data_received(sl,skb))!=LAPB_OK) + if((err=lapb_data_received(skb->dev, skb))!=LAPB_OK) { kfree_skb(skb); printk(KERN_DEBUG "x25_asy: data received err - %d\n",err); @@ -324,12 +324,12 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) { case 0x00:break; case 0x01: /* Connection request .. do nothing */ - if((err=lapb_connect_request(sl))!=LAPB_OK) + if((err=lapb_connect_request(dev))!=LAPB_OK) printk(KERN_ERR "x25_asy: lapb_connect_request error - %d\n", err); kfree_skb(skb); return 0; case 0x02: /* Disconnect request .. do nothing - hang up ?? */ - if((err=lapb_disconnect_request(sl))!=LAPB_OK) + if((err=lapb_disconnect_request(dev))!=LAPB_OK) printk(KERN_ERR "x25_asy: lapb_disconnect_request error - %d\n", err); default: kfree_skb(skb); @@ -347,7 +347,7 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) * 14 Oct 1994 Dmitry Gorodchanin. */ - if((err=lapb_data_request(sl,skb))!=LAPB_OK) + if((err=lapb_data_request(dev,skb))!=LAPB_OK) { printk(KERN_ERR "lapbeth: lapb_data_request error - %d\n", err); kfree_skb(skb); @@ -366,7 +366,7 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) * at the net layer. */ -static int x25_asy_data_indication(void *token, struct sk_buff *skb) +static int x25_asy_data_indication(struct net_device *dev, struct sk_buff *skb) { skb->dev->last_rx = jiffies; return netif_rx(skb); @@ -378,9 +378,9 @@ static int x25_asy_data_indication(void *token, struct sk_buff *skb) * perhaps lapb should allow us to bounce this ? */ -static void x25_asy_data_transmit(void *token, struct sk_buff *skb) +static void x25_asy_data_transmit(struct net_device *dev, struct sk_buff *skb) { - struct x25_asy *sl=token; + struct x25_asy *sl=dev->priv; spin_lock(&sl->lock); if (netif_queue_stopped(sl->dev) || sl->tty == NULL) @@ -405,9 +405,9 @@ static void x25_asy_data_transmit(void *token, struct sk_buff *skb) * LAPB connection establish/down information. */ -static void x25_asy_connected(void *token, int reason) +static void x25_asy_connected(struct net_device *dev, int reason) { - struct x25_asy *sl = token; + struct x25_asy *sl = dev->priv; struct sk_buff *skb; unsigned char *ptr; @@ -428,9 +428,9 @@ static void x25_asy_connected(void *token, int reason) sl->dev->last_rx = jiffies; } -static void x25_asy_disconnected(void *token, int reason) +static void x25_asy_disconnected(struct net_device *dev, int reason) { - struct x25_asy *sl = token; + struct x25_asy *sl = dev->priv; struct sk_buff *skb; unsigned char *ptr; @@ -525,7 +525,7 @@ static int x25_asy_close(struct net_device *dev) netif_stop_queue(dev); sl->rcount = 0; sl->xleft = 0; - if((err=lapb_unregister(sl))!=LAPB_OK) + if((err=lapb_unregister(dev))!=LAPB_OK) printk(KERN_ERR "x25_asy_close: lapb_unregister error -%d\n",err); spin_unlock(&sl->lock); return 0; diff --git a/include/linux/lapb.h b/include/linux/lapb.h index 602326af0d64..dfe6402d812f 100644 --- a/include/linux/lapb.h +++ b/include/linux/lapb.h @@ -24,12 +24,12 @@ #define LAPB_DCE 0x04 struct lapb_register_struct { - void (*connect_confirmation)(void *token, int reason); - void (*connect_indication)(void *token, int reason); - void (*disconnect_confirmation)(void *token, int reason); - void (*disconnect_indication)(void *token, int reason); - int (*data_indication)(void *token, struct sk_buff *skb); - void (*data_transmit)(void *token, struct sk_buff *skb); + void (*connect_confirmation)(struct net_device *dev, int reason); + void (*connect_indication)(struct net_device *dev, int reason); + void (*disconnect_confirmation)(struct net_device *dev, int reason); + void (*disconnect_indication)(struct net_device *dev, int reason); + int (*data_indication)(struct net_device *dev, struct sk_buff *skb); + void (*data_transmit)(struct net_device *dev, struct sk_buff *skb); }; struct lapb_parms_struct { @@ -45,12 +45,12 @@ struct lapb_parms_struct { }; extern int lapb_register(struct net_device *dev, void *token, struct lapb_register_struct *callbacks); -extern int lapb_unregister(void *token); -extern int lapb_getparms(void *token, struct lapb_parms_struct *parms); -extern int lapb_setparms(void *token, struct lapb_parms_struct *parms); -extern int lapb_connect_request(void *token); -extern int lapb_disconnect_request(void *token); -extern int lapb_data_request(void *token, struct sk_buff *skb); -extern int lapb_data_received(void *token, struct sk_buff *skb); +extern int lapb_unregister(struct net_device *dev); +extern int lapb_getparms(struct net_device *dev, struct lapb_parms_struct *parms); +extern int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms); +extern int lapb_connect_request(struct net_device *dev); +extern int lapb_disconnect_request(struct net_device *dev); +extern int lapb_data_request(struct net_device *dev, struct sk_buff *skb); +extern int lapb_data_received(struct net_device *dev, struct sk_buff *skb); #endif diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c index 8be730427a3d..634e04c69622 100644 --- a/net/lapb/lapb_iface.c +++ b/net/lapb/lapb_iface.c @@ -81,18 +81,14 @@ static void __lapb_insert_cb(struct lapb_cb *lapb) lapb_hold(lapb); } -/* - * Convert the integer token used by the device driver into a pointer - * to a LAPB control structure. - */ -static struct lapb_cb *__lapb_tokentostruct(void *token) +static struct lapb_cb *__lapb_devtostruct(struct net_device *dev) { struct list_head *entry; struct lapb_cb *lapb, *use = NULL; list_for_each(entry, &lapb_list) { lapb = list_entry(entry, struct lapb_cb, node); - if (lapb->token == token) { + if (lapb->dev == dev) { use = lapb; break; } @@ -104,12 +100,12 @@ static struct lapb_cb *__lapb_tokentostruct(void *token) return use; } -static struct lapb_cb *lapb_tokentostruct(void *token) +static struct lapb_cb *lapb_devtostruct(struct net_device *dev) { struct lapb_cb *rc; read_lock_bh(&lapb_list_lock); - rc = __lapb_tokentostruct(token); + rc = __lapb_devtostruct(dev); read_unlock_bh(&lapb_list_lock); return rc; @@ -151,7 +147,7 @@ int lapb_register(struct net_device *dev, void *token, struct lapb_register_stru write_lock_bh(&lapb_list_lock); - lapb = __lapb_tokentostruct(token); + lapb = __lapb_devtostruct(dev); if (lapb) { lapb_put(lapb); goto out; @@ -176,13 +172,13 @@ out: return rc; } -int lapb_unregister(void *token) +int lapb_unregister(struct net_device *dev) { struct lapb_cb *lapb; int rc = LAPB_BADTOKEN; write_unlock_bh(&lapb_list_lock); - lapb = __lapb_tokentostruct(token); + lapb = __lapb_devtostruct(dev); if (!lapb) goto out; @@ -200,10 +196,10 @@ out: return rc; } -int lapb_getparms(void *token, struct lapb_parms_struct *parms) +int lapb_getparms(struct net_device *dev, struct lapb_parms_struct *parms) { int rc = LAPB_BADTOKEN; - struct lapb_cb *lapb = lapb_tokentostruct(token); + struct lapb_cb *lapb = lapb_devtostruct(dev); if (!lapb) goto out; @@ -232,10 +228,10 @@ out: return rc; } -int lapb_setparms(void *token, struct lapb_parms_struct *parms) +int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms) { int rc = LAPB_BADTOKEN; - struct lapb_cb *lapb = lapb_tokentostruct(token); + struct lapb_cb *lapb = lapb_devtostruct(dev); if (!lapb) goto out; @@ -265,9 +261,9 @@ out: return rc; } -int lapb_connect_request(void *token) +int lapb_connect_request(struct net_device *dev) { - struct lapb_cb *lapb = lapb_tokentostruct(token); + struct lapb_cb *lapb = lapb_devtostruct(dev); int rc = LAPB_BADTOKEN; if (!lapb) @@ -295,9 +291,9 @@ out: return rc; } -int lapb_disconnect_request(void *token) +int lapb_disconnect_request(struct net_device *dev) { - struct lapb_cb *lapb = lapb_tokentostruct(token); + struct lapb_cb *lapb = lapb_devtostruct(dev); int rc = LAPB_BADTOKEN; if (!lapb) @@ -347,9 +343,9 @@ out: return rc; } -int lapb_data_request(void *token, struct sk_buff *skb) +int lapb_data_request(struct net_device *dev, struct sk_buff *skb) { - struct lapb_cb *lapb = lapb_tokentostruct(token); + struct lapb_cb *lapb = lapb_devtostruct(dev); int rc = LAPB_BADTOKEN; if (!lapb) @@ -368,9 +364,9 @@ out: return rc; } -int lapb_data_received(void *token, struct sk_buff *skb) +int lapb_data_received(struct net_device *dev, struct sk_buff *skb) { - struct lapb_cb *lapb = lapb_tokentostruct(token); + struct lapb_cb *lapb = lapb_devtostruct(dev); int rc = LAPB_BADTOKEN; if (lapb) { @@ -385,31 +381,31 @@ int lapb_data_received(void *token, struct sk_buff *skb) void lapb_connect_confirmation(struct lapb_cb *lapb, int reason) { if (lapb->callbacks.connect_confirmation) - lapb->callbacks.connect_confirmation(lapb->token, reason); + lapb->callbacks.connect_confirmation(lapb->dev, reason); } void lapb_connect_indication(struct lapb_cb *lapb, int reason) { if (lapb->callbacks.connect_indication) - lapb->callbacks.connect_indication(lapb->token, reason); + lapb->callbacks.connect_indication(lapb->dev, reason); } void lapb_disconnect_confirmation(struct lapb_cb *lapb, int reason) { if (lapb->callbacks.disconnect_confirmation) - lapb->callbacks.disconnect_confirmation(lapb->token, reason); + lapb->callbacks.disconnect_confirmation(lapb->dev, reason); } void lapb_disconnect_indication(struct lapb_cb *lapb, int reason) { if (lapb->callbacks.disconnect_indication) - lapb->callbacks.disconnect_indication(lapb->token, reason); + lapb->callbacks.disconnect_indication(lapb->dev, reason); } int lapb_data_indication(struct lapb_cb *lapb, struct sk_buff *skb) { if (lapb->callbacks.data_indication) - return lapb->callbacks.data_indication(lapb->token, skb); + return lapb->callbacks.data_indication(lapb->dev, skb); kfree_skb(skb); return NET_RX_CN_HIGH; /* For now; must be != NET_RX_DROP */ @@ -420,7 +416,7 @@ int lapb_data_transmit(struct lapb_cb *lapb, struct sk_buff *skb) int used = 0; if (lapb->callbacks.data_transmit) { - lapb->callbacks.data_transmit(lapb->token, skb); + lapb->callbacks.data_transmit(lapb->dev, skb); used = 1; } -- cgit v1.2.3 From b4629aeb6694a86c9aa1779a11e209ef012fef96 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:39:13 -0500 Subject: [wan lapb] kill now-unused custom token container Nothing is using lapb->token anymore; removed, along with the old "token" argument of lapb_register(). --- drivers/net/wan/comx-proto-lapb.c | 2 +- drivers/net/wan/hdlc_x25.c | 2 +- drivers/net/wan/lapbether.c | 4 +--- drivers/net/wan/x25_asy.c | 2 +- include/linux/lapb.h | 2 +- include/net/lapb.h | 1 - net/lapb/lapb_iface.c | 3 +-- 7 files changed, 6 insertions(+), 10 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/comx-proto-lapb.c b/drivers/net/wan/comx-proto-lapb.c index ec6f4b48b235..b203ff689331 100644 --- a/drivers/net/wan/comx-proto-lapb.c +++ b/drivers/net/wan/comx-proto-lapb.c @@ -453,7 +453,7 @@ static int comxlapb_init(struct net_device *dev) lapbreg.disconnect_indication = comxlapb_disconnected; lapbreg.data_indication = comxlapb_data_indication; lapbreg.data_transmit = comxlapb_data_transmit; - if (lapb_register(dev, dev->priv, &lapbreg)) { + if (lapb_register(dev, &lapbreg)) { return -ENOMEM; } if (ch->debug_flags & DEBUG_COMX_LAPB) { diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c index ac81b10189ea..ebcc51233d4d 100644 --- a/drivers/net/wan/hdlc_x25.c +++ b/drivers/net/wan/hdlc_x25.c @@ -152,7 +152,7 @@ static int x25_open(hdlc_device *hdlc) cb.data_indication = x25_data_indication; cb.data_transmit = x25_data_transmit; - result = lapb_register(hdlc_to_dev(hdlc), hdlc, &cb); + result = lapb_register(hdlc_to_dev(hdlc), &cb); if (result != LAPB_OK) return result; return 0; diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c index 7d280626c76c..880e50381bb3 100644 --- a/drivers/net/wan/lapbether.c +++ b/drivers/net/wan/lapbether.c @@ -299,11 +299,9 @@ static struct lapb_register_struct lapbeth_callbacks = { */ static int lapbeth_open(struct net_device *dev) { - struct lapbethdev *lapbeth; int err; - lapbeth = (struct lapbethdev *)dev->priv; - if ((err = lapb_register(dev, lapbeth, &lapbeth_callbacks)) != LAPB_OK) { + if ((err = lapb_register(dev, &lapbeth_callbacks)) != LAPB_OK) { printk(KERN_ERR "lapbeth: lapb_register error - %d\n", err); return -ENODEV; } diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index bebd9502a46f..4243fea5354d 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c @@ -500,7 +500,7 @@ static int x25_asy_open(struct net_device *dev) /* * Now attach LAPB */ - if((err=lapb_register(dev, sl, &x25_asy_callbacks))==LAPB_OK) + if((err=lapb_register(dev, &x25_asy_callbacks))==LAPB_OK) return 0; /* Cleanup */ diff --git a/include/linux/lapb.h b/include/linux/lapb.h index dfe6402d812f..ce709e1885cc 100644 --- a/include/linux/lapb.h +++ b/include/linux/lapb.h @@ -44,7 +44,7 @@ struct lapb_parms_struct { unsigned int mode; }; -extern int lapb_register(struct net_device *dev, void *token, struct lapb_register_struct *callbacks); +extern int lapb_register(struct net_device *dev, struct lapb_register_struct *callbacks); extern int lapb_unregister(struct net_device *dev); extern int lapb_getparms(struct net_device *dev, struct lapb_parms_struct *parms); extern int lapb_setparms(struct net_device *dev, struct lapb_parms_struct *parms); diff --git a/include/net/lapb.h b/include/net/lapb.h index 0730d4177125..96cb5ddaa9f1 100644 --- a/include/net/lapb.h +++ b/include/net/lapb.h @@ -81,7 +81,6 @@ struct lapb_frame { struct lapb_cb { struct list_head node; struct net_device *dev; - void *token; /* Link status fields */ unsigned int mode; diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c index 051e0176422c..beca11e7a5e9 100644 --- a/net/lapb/lapb_iface.c +++ b/net/lapb/lapb_iface.c @@ -140,7 +140,7 @@ out: return lapb; } -int lapb_register(struct net_device *dev, void *token, struct lapb_register_struct *callbacks) +int lapb_register(struct net_device *dev, struct lapb_register_struct *callbacks) { struct lapb_cb *lapb; int rc = LAPB_BADTOKEN; @@ -158,7 +158,6 @@ int lapb_register(struct net_device *dev, void *token, struct lapb_register_stru if (!lapb) goto out; - lapb->token = token; lapb->dev = dev; lapb->callbacks = *callbacks; -- cgit v1.2.3 From 24b84925ce61a1bf54925563845f58ba496a89c3 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:44:19 -0500 Subject: [wan hdlc] hdlc_open() switched to net_device Beginning of hdlc fixes. hdlc_open() switched from hdlc_device to net_device. --- drivers/net/wan/c101.c | 2 +- drivers/net/wan/dscc4.c | 2 +- drivers/net/wan/farsync.c | 2 +- drivers/net/wan/hdlc_generic.c | 11 ++++++----- drivers/net/wan/n2.c | 2 +- drivers/net/wan/pc300_drv.c | 2 +- drivers/net/wan/wanxl.c | 2 +- include/linux/hdlc.h | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c index f47cd918ea56..7c6976e2bf7e 100644 --- a/drivers/net/wan/c101.c +++ b/drivers/net/wan/c101.c @@ -181,7 +181,7 @@ static int c101_open(struct net_device *dev) port_t *port = hdlc_to_port(hdlc); int result; - result = hdlc_open(hdlc); + result = hdlc_open(dev); if (result) return result; diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c index 632a4c7ed901..71a5c0f4e9f8 100644 --- a/drivers/net/wan/dscc4.c +++ b/drivers/net/wan/dscc4.c @@ -1022,7 +1022,7 @@ static int dscc4_open(struct net_device *dev) if ((dscc4_loopback_check(dpriv) < 0) || !dev->hard_start_xmit) goto err; - if ((ret = hdlc_open(hdlc))) + if ((ret = hdlc_open(dev))) goto err; ppriv = dpriv->pci_priv; diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index 66170e0a945d..eb0059722cd1 100644 --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c @@ -1309,7 +1309,7 @@ fst_open ( struct net_device *dev ) { int err; - err = hdlc_open ( dev_to_hdlc ( dev )); + err = hdlc_open (dev); if ( err ) return err; diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index ef7ae7e4189d..6af18698c321 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -108,8 +108,9 @@ void hdlc_set_carrier(int on, hdlc_device *hdlc) /* Must be called by hardware driver when HDLC device is being opened */ -int hdlc_open(hdlc_device *hdlc) +int hdlc_open(struct net_device *dev) { + hdlc_device *hdlc = dev_to_hdlc(dev); #ifdef DEBUG_LINK printk(KERN_DEBUG "hdlc_open carrier %i open %i\n", hdlc->carrier, hdlc->open); @@ -129,11 +130,11 @@ int hdlc_open(hdlc_device *hdlc) if (hdlc->carrier) { if (hdlc->proto.start) hdlc->proto.start(hdlc); - else if (!netif_carrier_ok(&hdlc->netdev)) - netif_carrier_on(&hdlc->netdev); + else if (!netif_carrier_ok(dev)) + netif_carrier_on(dev); - } else if (netif_carrier_ok(&hdlc->netdev)) - netif_carrier_off(&hdlc->netdev); + } else if (netif_carrier_ok(dev)) + netif_carrier_off(dev); hdlc->open = 1; diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c index 7e50bc51f021..b203e3ef5cdd 100644 --- a/drivers/net/wan/n2.c +++ b/drivers/net/wan/n2.c @@ -221,7 +221,7 @@ static int n2_open(struct net_device *dev) u8 mcr = inb(io + N2_MCR) | (port->phy_node ? TX422_PORT1:TX422_PORT0); int result; - result = hdlc_open(hdlc); + result = hdlc_open(dev); if (result) return result; diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c index 3fa5e3d61007..ac7ab38bfc62 100644 --- a/drivers/net/wan/pc300_drv.c +++ b/drivers/net/wan/pc300_drv.c @@ -3157,7 +3157,7 @@ int cpc_open(struct net_device *dev) d->if_ptr = &hdlc->state.ppp.pppdev; } - result = hdlc_open(hdlc); + result = hdlc_open(dev); if (hdlc->proto.id == IF_PROTO_PPP) { dev->priv = d; } diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index 15bc7da391b4..4ae2e6a04438 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c @@ -425,7 +425,7 @@ static int wanxl_open(struct net_device *dev) printk(KERN_ERR "%s: port already open\n", port_name(port)); return -EIO; } - if ((i = hdlc_open(hdlc)) != 0) + if ((i = hdlc_open(dev)) != 0) return i; port->tx_in = port->tx_out = 0; diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index 7b35bd079439..65a35f525367 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -229,7 +229,7 @@ static __inline__ void debug_frame(const struct sk_buff *skb) /* Must be called by hardware driver when HDLC device is being opened */ -int hdlc_open(hdlc_device *hdlc); +int hdlc_open(struct net_device *dev); /* Must be called by hardware driver when HDLC device is being closed */ void hdlc_close(hdlc_device *hdlc); /* Called by hardware driver when DCD line level changes */ -- cgit v1.2.3 From d5dc249cccf4b90a7e002b16da178c773a6045e7 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:47:42 -0500 Subject: [wan hdlc] hdlc_close() switched to net_device. --- drivers/net/wan/c101.c | 2 +- drivers/net/wan/dscc4.c | 6 ++---- drivers/net/wan/farsync.c | 2 +- drivers/net/wan/hdlc_generic.c | 3 ++- drivers/net/wan/n2.c | 2 +- drivers/net/wan/pc300_drv.c | 2 +- drivers/net/wan/wanxl.c | 2 +- include/linux/hdlc.h | 2 +- 8 files changed, 10 insertions(+), 11 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c index 7c6976e2bf7e..b099fbe31388 100644 --- a/drivers/net/wan/c101.c +++ b/drivers/net/wan/c101.c @@ -212,7 +212,7 @@ static int c101_close(struct net_device *dev) sca_close(hdlc); writeb(0, port->win0base + C101_DTR); sca_out(CTL_NORTS, MSCI1_OFFSET + CTL, port); - hdlc_close(hdlc); + hdlc_close(dev); return 0; } diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c index 71a5c0f4e9f8..aaad274c1b9d 100644 --- a/drivers/net/wan/dscc4.c +++ b/drivers/net/wan/dscc4.c @@ -1015,7 +1015,6 @@ static void dscc4_pci_reset(struct pci_dev *pdev, unsigned long ioaddr) static int dscc4_open(struct net_device *dev) { struct dscc4_dev_priv *dpriv = dscc4_priv(dev); - hdlc_device *hdlc = &dpriv->hdlc; struct dscc4_pci_priv *ppriv; int ret = -EAGAIN; @@ -1103,7 +1102,7 @@ err_disable_scc_events: scc_writel(0xffffffff, dpriv, dev, IMR); scc_patchl(PowerUp | Vis, 0, dpriv, dev, CCR0); err_out: - hdlc_close(hdlc); + hdlc_close(dev); err: return ret; } @@ -1155,7 +1154,6 @@ static int dscc4_start_xmit(struct sk_buff *skb, struct net_device *dev) static int dscc4_close(struct net_device *dev) { struct dscc4_dev_priv *dpriv = dscc4_priv(dev); - hdlc_device *hdlc = dev_to_hdlc(dev); del_timer_sync(&dpriv->timer); netif_stop_queue(dev); @@ -1166,7 +1164,7 @@ static int dscc4_close(struct net_device *dev) dpriv->flags |= FakeReset; - hdlc_close(hdlc); + hdlc_close(dev); return 0; } diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index eb0059722cd1..1e4289b7e9d4 100644 --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c @@ -1325,7 +1325,7 @@ fst_close ( struct net_device *dev ) { netif_stop_queue ( dev ); fst_closeport ( dev_to_port ( dev )); - hdlc_close ( dev_to_hdlc ( dev )); + hdlc_close ( dev ); MOD_DEC_USE_COUNT; return 0; } diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index 6af18698c321..03bb61237194 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -145,8 +145,9 @@ int hdlc_open(struct net_device *dev) /* Must be called by hardware driver when HDLC device is being closed */ -void hdlc_close(hdlc_device *hdlc) +void hdlc_close(struct net_device *dev) { + hdlc_device *hdlc = dev_to_hdlc(dev); #ifdef DEBUG_LINK printk(KERN_DEBUG "hdlc_close carrier %i open %i\n", hdlc->carrier, hdlc->open); diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c index b203e3ef5cdd..dc4ecf120e7e 100644 --- a/drivers/net/wan/n2.c +++ b/drivers/net/wan/n2.c @@ -247,7 +247,7 @@ static int n2_close(struct net_device *dev) sca_close(hdlc); mcr |= port->phy_node ? DTR_PORT1 : DTR_PORT0; /* set DTR OFF */ outb(mcr, io + N2_MCR); - hdlc_close(hdlc); + hdlc_close(dev); return 0; } diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c index ac7ab38bfc62..5ac17d811e46 100644 --- a/drivers/net/wan/pc300_drv.c +++ b/drivers/net/wan/pc300_drv.c @@ -3190,7 +3190,7 @@ int cpc_close(struct net_device *dev) cpc_closech(d); CPC_UNLOCK(card, flags); - hdlc_close(hdlc); + hdlc_close(dev); if (hdlc->proto.id == IF_PROTO_PPP) { d->if_ptr = NULL; } diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index 4ae2e6a04438..00f38cccda54 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c @@ -455,7 +455,7 @@ static int wanxl_close(struct net_device *dev) unsigned long timeout; int i; - hdlc_close(hdlc); + hdlc_close(dev); /* signal the card */ writel(1 << (DOORBELL_TO_CARD_CLOSE_0 + port->node), port->card->plx + PLX_DOORBELL_TO_CARD); diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index 65a35f525367..634b3159c89e 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -231,7 +231,7 @@ static __inline__ void debug_frame(const struct sk_buff *skb) /* Must be called by hardware driver when HDLC device is being opened */ int hdlc_open(struct net_device *dev); /* Must be called by hardware driver when HDLC device is being closed */ -void hdlc_close(hdlc_device *hdlc); +void hdlc_close(struct net_device *dev); /* Called by hardware driver when DCD line level changes */ void hdlc_set_carrier(int on, hdlc_device *hdlc); -- cgit v1.2.3 From 11b2884f27c256b4603408e2b242191b986fefe7 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:49:55 -0500 Subject: [wan hdlc] hdlc_set_carrier() switched to net_device. --- drivers/net/wan/c101.c | 7 +++---- drivers/net/wan/hd6457x.c | 6 +++--- drivers/net/wan/hdlc_generic.c | 13 +++++++------ drivers/net/wan/wanxl.c | 2 +- include/linux/hdlc.h | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c index 2d6f01c7f3b0..9d5e121af26b 100644 --- a/drivers/net/wan/c101.c +++ b/drivers/net/wan/c101.c @@ -139,7 +139,7 @@ static void sca_msci_intr(port_t *port) if (stat & ST1_CDCD) hdlc_set_carrier(!(sca_in(MSCI1_OFFSET + ST3, card) & ST3_DCD), - dev_to_hdlc(dev)); + dev); } @@ -193,7 +193,7 @@ static int c101_open(struct net_device *dev) sca_out(IE1_UDRN, MSCI0_OFFSET + IE1, port); sca_out(IE0_TXINT, MSCI0_OFFSET + IE0, port); - hdlc_set_carrier(!(sca_in(MSCI1_OFFSET + ST3, port) & ST3_DCD), dev_to_hdlc(dev)); + hdlc_set_carrier(!(sca_in(MSCI1_OFFSET + ST3, port) & ST3_DCD), dev); printk(KERN_DEBUG "0x%X\n", sca_in(MSCI1_OFFSET + ST3, port)); /* enable MSCI1 CDCD interrupt */ @@ -371,8 +371,7 @@ static int __init c101_run(unsigned long irq, unsigned long winbase) } sca_init_sync_port(card); /* Set up C101 memory */ - hdlc_set_carrier(!(sca_in(MSCI1_OFFSET + ST3, card) & ST3_DCD), - dev_to_hdlc(dev)); + hdlc_set_carrier(!(sca_in(MSCI1_OFFSET + ST3, card) & ST3_DCD), dev); printk(KERN_INFO "%s: Moxa C101 on IRQ%u," " using %u TX + %u RX packets rings\n", diff --git a/drivers/net/wan/hd6457x.c b/drivers/net/wan/hd6457x.c index fff184a0177c..96ce3239ac5f 100644 --- a/drivers/net/wan/hd6457x.c +++ b/drivers/net/wan/hd6457x.c @@ -250,7 +250,7 @@ static void sca_init_sync_port(port_t *port) } hdlc_set_carrier(!(sca_in(get_msci(port) + ST3, card) & ST3_DCD), - dev_to_hdlc(port_to_dev(port))); + port_to_dev(port)); } @@ -274,7 +274,7 @@ static inline void sca_msci_intr(port_t *port) if (stat & ST1_CDCD) hdlc_set_carrier(!(sca_in(msci + ST3, card) & ST3_DCD), - dev_to_hdlc(port_to_dev(port))); + port_to_dev(port)); } #endif @@ -579,7 +579,7 @@ static void sca_open(struct net_device *dev) - all DMA interrupts */ - hdlc_set_carrier(!(sca_in(msci + ST3, card) & ST3_DCD), dev_to_hdlc(dev)); + hdlc_set_carrier(!(sca_in(msci + ST3, card) & ST3_DCD), dev); #ifdef __HD64570_H /* MSCI TX INT and RX INT A IRQ enable */ diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index 03bb61237194..8e20a3d4711e 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -69,8 +69,9 @@ static int hdlc_rcv(struct sk_buff *skb, struct net_device *dev, -void hdlc_set_carrier(int on, hdlc_device *hdlc) +void hdlc_set_carrier(int on, struct net_device *dev) { + hdlc_device *hdlc = dev_to_hdlc(dev); on = on ? 1 : 0; #ifdef DEBUG_LINK @@ -82,7 +83,7 @@ void hdlc_set_carrier(int on, hdlc_device *hdlc) if (hdlc->carrier == on) goto carrier_exit; /* no change in DCD line level */ - printk(KERN_INFO "%s: carrier %s\n", hdlc_to_name(hdlc), + printk(KERN_INFO "%s: carrier %s\n", dev->name, on ? "ON" : "off"); hdlc->carrier = on; @@ -92,14 +93,14 @@ void hdlc_set_carrier(int on, hdlc_device *hdlc) if (hdlc->carrier) { if (hdlc->proto.start) hdlc->proto.start(hdlc); - else if (!netif_carrier_ok(&hdlc->netdev)) - netif_carrier_on(&hdlc->netdev); + else if (!netif_carrier_ok(dev)) + netif_carrier_on(dev); } else { /* no carrier */ if (hdlc->proto.stop) hdlc->proto.stop(hdlc); - else if (netif_carrier_ok(&hdlc->netdev)) - netif_carrier_off(&hdlc->netdev); + else if (netif_carrier_ok(dev)) + netif_carrier_off(dev); } carrier_exit: diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index 00f38cccda54..d3e8407fa64b 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c @@ -172,7 +172,7 @@ static inline void wanxl_cable_intr(port_t *port) printk(KERN_INFO "%s: %s%s module, %s cable%s%s\n", port_name(port), pm, dte, cable, dsr, dcd); - hdlc_set_carrier(value & STATUS_CABLE_DCD, &port->hdlc); + hdlc_set_carrier(value & STATUS_CABLE_DCD, port_to_dev(port)); } diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index 634b3159c89e..273e0bc67d7c 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -233,7 +233,7 @@ int hdlc_open(struct net_device *dev); /* Must be called by hardware driver when HDLC device is being closed */ void hdlc_close(struct net_device *dev); /* Called by hardware driver when DCD line level changes */ -void hdlc_set_carrier(int on, hdlc_device *hdlc); +void hdlc_set_carrier(int on, struct net_device *dev); /* May be used by hardware driver to gain control over HDLC device */ static __inline__ void hdlc_proto_detach(hdlc_device *hdlc) -- cgit v1.2.3 From 40881456a3fb1b34ad3974d70a0a2c098be93614 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:50:28 -0500 Subject: [wan hdlc] hdlc->attach() switched to net_device. --- drivers/net/wan/dscc4.c | 5 ++--- drivers/net/wan/farsync.c | 2 +- drivers/net/wan/hd6457x.c | 19 ++++--------------- drivers/net/wan/hdlc_cisco.c | 2 +- drivers/net/wan/hdlc_fr.c | 2 +- drivers/net/wan/hdlc_ppp.c | 2 +- drivers/net/wan/hdlc_raw.c | 2 +- drivers/net/wan/hdlc_raw_eth.c | 2 +- drivers/net/wan/hdlc_x25.c | 2 +- drivers/net/wan/pc300_drv.c | 5 ++--- drivers/net/wan/wanxl.c | 4 ++-- include/linux/hdlc.h | 2 +- 12 files changed, 18 insertions(+), 31 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c index aaad274c1b9d..d9d34e7f25e9 100644 --- a/drivers/net/wan/dscc4.c +++ b/drivers/net/wan/dscc4.c @@ -364,7 +364,7 @@ static void dscc4_release_ring(struct dscc4_dev_priv *); static void dscc4_timer(unsigned long); static void dscc4_tx_timeout(struct net_device *); static irqreturn_t dscc4_irq(int irq, void *dev_id, struct pt_regs *ptregs); -static int dscc4_hdlc_attach(hdlc_device *, unsigned short, unsigned short); +static int dscc4_hdlc_attach(struct net_device *, unsigned short, unsigned short); static int dscc4_set_iface(struct dscc4_dev_priv *, struct net_device *); static inline int dscc4_set_quartz(struct dscc4_dev_priv *, int); #ifdef DSCC4_POLLING @@ -1986,10 +1986,9 @@ static void __devexit dscc4_remove_one(struct pci_dev *pdev) pci_resource_len(pdev, 0)); } -static int dscc4_hdlc_attach(hdlc_device *hdlc, unsigned short encoding, +static int dscc4_hdlc_attach(struct net_device *dev, unsigned short encoding, unsigned short parity) { - struct net_device *dev = hdlc_to_dev(hdlc); struct dscc4_dev_priv *dpriv = dscc4_priv(dev); if (encoding != ENCODING_NRZ && diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index 1e4289b7e9d4..bbaa3681d8b3 100644 --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c @@ -1331,7 +1331,7 @@ fst_close ( struct net_device *dev ) } static int -fst_attach ( hdlc_device *hdlc, unsigned short encoding, unsigned short parity ) +fst_attach ( struct net_device *dev, unsigned short encoding, unsigned short parity ) { /* Setting currently fixed in FarSync card so we check and forget */ if ( encoding != ENCODING_NRZ || parity != PARITY_CRC16_PR1_CCITT ) diff --git a/drivers/net/wan/hd6457x.c b/drivers/net/wan/hd6457x.c index 96ce3239ac5f..6c17e7000230 100644 --- a/drivers/net/wan/hd6457x.c +++ b/drivers/net/wan/hd6457x.c @@ -115,22 +115,11 @@ static inline int sca_intr_status(card_t *card) return result; } - - -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) { - return hdlc_to_port(dev_to_hdlc(dev)); + return (port_t *)(dev_to_hdlc(dev)); } - - static inline u16 next_desc(port_t *port, u16 desc, int transmit) { return (desc + 1) % (transmit ? port_to_card(port)->tx_ring_buffers @@ -639,7 +628,7 @@ static void sca_close(struct net_device *dev) -static int sca_attach(hdlc_device *hdlc, unsigned short encoding, +static int sca_attach(struct net_device *dev, unsigned short encoding, unsigned short parity) { if (encoding != ENCODING_NRZ && @@ -660,8 +649,8 @@ static int sca_attach(hdlc_device *hdlc, unsigned short encoding, parity != PARITY_CRC16_PR1_CCITT) return -EINVAL; - hdlc_to_port(hdlc)->encoding = encoding; - hdlc_to_port(hdlc)->parity = parity; + dev_to_port(dev)->encoding = encoding; + dev_to_port(dev)->parity = parity; return 0; } diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c index b7116e07c3be..5dab7eae84d1 100644 --- a/drivers/net/wan/hdlc_cisco.c +++ b/drivers/net/wan/hdlc_cisco.c @@ -295,7 +295,7 @@ int hdlc_cisco_ioctl(hdlc_device *hdlc, struct ifreq *ifr) new_settings.timeout < 2) return -EINVAL; - result=hdlc->attach(hdlc, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT); + result=hdlc->attach(dev, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT); if (result) return result; diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c index a6c81713f492..d6528376a674 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c @@ -1163,7 +1163,7 @@ int hdlc_fr_ioctl(hdlc_device *hdlc, struct ifreq *ifr) new_settings.dce != 1)) return -EINVAL; - result=hdlc->attach(hdlc, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT); + result=hdlc->attach(dev, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT); if (result) return result; diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c index 7eeec068d5a2..e94a2629a409 100644 --- a/drivers/net/wan/hdlc_ppp.c +++ b/drivers/net/wan/hdlc_ppp.c @@ -93,7 +93,7 @@ int hdlc_ppp_ioctl(hdlc_device *hdlc, struct ifreq *ifr) /* no settable parameters */ - result=hdlc->attach(hdlc, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT); + result=hdlc->attach(dev, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT); if (result) return result; diff --git a/drivers/net/wan/hdlc_raw.c b/drivers/net/wan/hdlc_raw.c index 6c0aecc442fa..8d091cf0c987 100644 --- a/drivers/net/wan/hdlc_raw.c +++ b/drivers/net/wan/hdlc_raw.c @@ -67,7 +67,7 @@ int hdlc_raw_ioctl(hdlc_device *hdlc, struct ifreq *ifr) if (new_settings.parity == PARITY_DEFAULT) new_settings.parity = PARITY_CRC16_PR1_CCITT; - result = hdlc->attach(hdlc, new_settings.encoding, + result = hdlc->attach(dev, new_settings.encoding, new_settings.parity); if (result) return result; diff --git a/drivers/net/wan/hdlc_raw_eth.c b/drivers/net/wan/hdlc_raw_eth.c index d91a4fc87730..89c887ad5b2c 100644 --- a/drivers/net/wan/hdlc_raw_eth.c +++ b/drivers/net/wan/hdlc_raw_eth.c @@ -81,7 +81,7 @@ int hdlc_raw_eth_ioctl(hdlc_device *hdlc, struct ifreq *ifr) if (new_settings.parity == PARITY_DEFAULT) new_settings.parity = PARITY_CRC16_PR1_CCITT; - result = hdlc->attach(hdlc, new_settings.encoding, + result = hdlc->attach(dev, new_settings.encoding, new_settings.parity); if (result) return result; diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c index ebcc51233d4d..56fe8420e2b1 100644 --- a/drivers/net/wan/hdlc_x25.c +++ b/drivers/net/wan/hdlc_x25.c @@ -203,7 +203,7 @@ int hdlc_x25_ioctl(hdlc_device *hdlc, struct ifreq *ifr) if(dev->flags & IFF_UP) return -EBUSY; - result=hdlc->attach(hdlc, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT); + result=hdlc->attach(dev, ENCODING_NRZ,PARITY_CRC16_PR1_CCITT); if (result) return result; diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c index 5ac17d811e46..c8cb8cb77abe 100644 --- a/drivers/net/wan/pc300_drv.c +++ b/drivers/net/wan/pc300_drv.c @@ -290,7 +290,7 @@ static int clock_rate_calc(uclong, uclong, int *); static uclong detect_ram(pc300_t *); static void plx_init(pc300_t *); static void cpc_trace(struct net_device *, struct sk_buff *, char); -static int cpc_attach(hdlc_device *, unsigned short, unsigned short); +static int cpc_attach(struct net_device *, unsigned short, unsigned short); #ifdef CONFIG_PC300_MLPPP void cpc_tty_init(pc300dev_t * dev); @@ -3064,10 +3064,9 @@ int tx_config(pc300dev_t * d) return 0; } -static int cpc_attach(hdlc_device * hdlc, unsigned short encoding, +static int cpc_attach(struct net_device *dev, unsigned short encoding, unsigned short parity) { - 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; diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index d3e8407fa64b..9d59d6228ace 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c @@ -338,10 +338,10 @@ static int wanxl_xmit(struct sk_buff *skb, struct net_device *dev) -static int wanxl_attach(hdlc_device *hdlc, unsigned short encoding, +static int wanxl_attach(struct net_device *dev, unsigned short encoding, unsigned short parity) { - port_t *port = hdlc_to_port(hdlc); + port_t *port = hdlc_to_port(dev_to_hdlc(dev)); if (encoding != ENCODING_NRZ && encoding != ENCODING_NRZI) diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index 273e0bc67d7c..7cc1cb3b6ad1 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -100,7 +100,7 @@ typedef struct hdlc_device_struct { struct net_device_stats stats; /* used by HDLC layer to take control over HDLC device from hw driver*/ - int (*attach)(struct hdlc_device_struct *hdlc, + int (*attach)(struct net_device *dev, unsigned short encoding, unsigned short parity); /* hardware driver must handle this instead of dev->hard_start_xmit */ -- cgit v1.2.3 From de73d3b3fb87746cb1fc30ad6d9d6ed11c12d92a Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:52:47 -0500 Subject: [wan hdlc] hdlc->proto.*() switched to net_device. Eliminated a bunch of ->netdev and hdlc_to_dev() uses. --- drivers/net/wan/hdlc_cisco.c | 11 ++++++----- drivers/net/wan/hdlc_fr.c | 13 ++++++++----- drivers/net/wan/hdlc_generic.c | 12 ++++++------ drivers/net/wan/hdlc_ppp.c | 8 ++++---- drivers/net/wan/hdlc_x25.c | 8 ++++---- include/linux/hdlc.h | 8 ++++---- 6 files changed, 32 insertions(+), 28 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c index 5dab7eae84d1..569fb0f22479 100644 --- a/drivers/net/wan/hdlc_cisco.c +++ b/drivers/net/wan/hdlc_cisco.c @@ -238,8 +238,9 @@ static void cisco_timer(unsigned long arg) -static void cisco_start(hdlc_device *hdlc) +static void cisco_start(struct net_device *dev) { + hdlc_device *hdlc = dev_to_hdlc(dev); hdlc->state.cisco.last_poll = 0; hdlc->state.cisco.up = 0; hdlc->state.cisco.txseq = hdlc->state.cisco.rxseq = 0; @@ -253,11 +254,11 @@ static void cisco_start(hdlc_device *hdlc) -static void cisco_stop(hdlc_device *hdlc) +static void cisco_stop(struct net_device *dev) { - del_timer_sync(&hdlc->state.cisco.timer); - if (netif_carrier_ok(&hdlc->netdev)) - netif_carrier_off(&hdlc->netdev); + del_timer_sync(&dev_to_hdlc(dev)->state.cisco.timer); + if (netif_carrier_ok(dev)) + netif_carrier_off(dev); } diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c index d6528376a674..acf4beb8a4d1 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c @@ -932,14 +932,15 @@ static int fr_rx(struct sk_buff *skb) -static void fr_start(hdlc_device *hdlc) +static void fr_start(struct net_device *dev) { + hdlc_device *hdlc = dev_to_hdlc(dev); #ifdef DEBUG_LINK printk(KERN_DEBUG "fr_start\n"); #endif if (hdlc->state.fr.settings.lmi != LMI_NONE) { - if (netif_carrier_ok(&hdlc->netdev)) - netif_carrier_off(&hdlc->netdev); + if (netif_carrier_ok(dev)) + netif_carrier_off(dev); hdlc->state.fr.last_poll = 0; hdlc->state.fr.reliable = 0; hdlc->state.fr.dce_changed = 1; @@ -961,8 +962,9 @@ static void fr_start(hdlc_device *hdlc) -static void fr_stop(hdlc_device *hdlc) +static void fr_stop(struct net_device *dev) { + hdlc_device *hdlc = dev_to_hdlc(dev); #ifdef DEBUG_LINK printk(KERN_DEBUG "fr_stop\n"); #endif @@ -973,8 +975,9 @@ static void fr_stop(hdlc_device *hdlc) -static void fr_close(hdlc_device *hdlc) +static void fr_close(struct net_device *dev) { + hdlc_device *hdlc = dev_to_hdlc(dev); pvc_device *pvc = hdlc->state.fr.first_pvc; while (pvc) { /* Shutdown all PVCs for this FRAD */ diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index 8e20a3d4711e..5b01e6362df7 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -92,13 +92,13 @@ void hdlc_set_carrier(int on, struct net_device *dev) if (hdlc->carrier) { if (hdlc->proto.start) - hdlc->proto.start(hdlc); + hdlc->proto.start(dev); else if (!netif_carrier_ok(dev)) netif_carrier_on(dev); } else { /* no carrier */ if (hdlc->proto.stop) - hdlc->proto.stop(hdlc); + hdlc->proto.stop(dev); else if (netif_carrier_ok(dev)) netif_carrier_off(dev); } @@ -121,7 +121,7 @@ int hdlc_open(struct net_device *dev) return -ENOSYS; /* no protocol attached */ if (hdlc->proto.open) { - int result = hdlc->proto.open(hdlc); + int result = hdlc->proto.open(dev); if (result) return result; } @@ -130,7 +130,7 @@ int hdlc_open(struct net_device *dev) if (hdlc->carrier) { if (hdlc->proto.start) - hdlc->proto.start(hdlc); + hdlc->proto.start(dev); else if (!netif_carrier_ok(dev)) netif_carrier_on(dev); @@ -158,12 +158,12 @@ void hdlc_close(struct net_device *dev) hdlc->open = 0; if (hdlc->carrier && hdlc->proto.stop) - hdlc->proto.stop(hdlc); + hdlc->proto.stop(dev); spin_unlock_irq(&hdlc->state_lock); if (hdlc->proto.close) - hdlc->proto.close(hdlc); + hdlc->proto.close(dev); } diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c index e94a2629a409..e9ebd0c0c180 100644 --- a/drivers/net/wan/hdlc_ppp.c +++ b/drivers/net/wan/hdlc_ppp.c @@ -24,9 +24,9 @@ #include -static int ppp_open(hdlc_device *hdlc) +static int ppp_open(struct net_device *dev) { - struct net_device *dev = hdlc_to_dev(hdlc); + hdlc_device *hdlc = dev_to_hdlc(dev); void *old_ioctl; int result; @@ -52,9 +52,9 @@ static int ppp_open(hdlc_device *hdlc) -static void ppp_close(hdlc_device *hdlc) +static void ppp_close(struct net_device *dev) { - struct net_device *dev = hdlc_to_dev(hdlc); + hdlc_device *hdlc = dev_to_hdlc(dev); sppp_close(dev); sppp_detach(dev); diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c index 56fe8420e2b1..cf772135d5be 100644 --- a/drivers/net/wan/hdlc_x25.c +++ b/drivers/net/wan/hdlc_x25.c @@ -140,7 +140,7 @@ static int x25_xmit(struct sk_buff *skb, struct net_device *dev) -static int x25_open(hdlc_device *hdlc) +static int x25_open(struct net_device *dev) { struct lapb_register_struct cb; int result; @@ -152,7 +152,7 @@ static int x25_open(hdlc_device *hdlc) cb.data_indication = x25_data_indication; cb.data_transmit = x25_data_transmit; - result = lapb_register(hdlc_to_dev(hdlc), &cb); + result = lapb_register(dev, &cb); if (result != LAPB_OK) return result; return 0; @@ -160,9 +160,9 @@ static int x25_open(hdlc_device *hdlc) -static void x25_close(hdlc_device *hdlc) +static void x25_close(struct net_device *dev) { - lapb_unregister(hdlc_to_dev(hdlc)); + lapb_unregister(dev); } diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index 7cc1cb3b6ad1..22f7615bd6b6 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -109,13 +109,13 @@ typedef struct hdlc_device_struct { /* Things below are for HDLC layer internal use only */ struct { - int (*open)(struct hdlc_device_struct *hdlc); - void (*close)(struct hdlc_device_struct *hdlc); + int (*open)(struct net_device *dev); + void (*close)(struct net_device *dev); /* if open & DCD */ - void (*start)(struct hdlc_device_struct *hdlc); + void (*start)(struct net_device *dev); /* if open & !DCD */ - void (*stop)(struct hdlc_device_struct *hdlc); + void (*stop)(struct net_device *dev); void (*detach)(struct hdlc_device_struct *hdlc); int (*netif_rx)(struct sk_buff *skb); -- cgit v1.2.3 From 8f3c812a68b7948f71341c89ead5da46473ca9bc Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:53:17 -0500 Subject: [wan hdlc] hdlc_cisco: killed ->netdev, hdlc_to_name() and hdlc_to_dev() uses. --- drivers/net/wan/hdlc_cisco.c | 43 +++++++++++++++++++++--------------------- drivers/net/wan/hdlc_generic.c | 4 ++-- include/linux/hdlc.h | 2 +- 3 files changed, 25 insertions(+), 24 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/hdlc_cisco.c b/drivers/net/wan/hdlc_cisco.c index 569fb0f22479..43e8bf3cecd6 100644 --- a/drivers/net/wan/hdlc_cisco.c +++ b/drivers/net/wan/hdlc_cisco.c @@ -57,7 +57,7 @@ static int cisco_hard_header(struct sk_buff *skb, struct net_device *dev, -static void cisco_keepalive_send(hdlc_device *hdlc, u32 type, +static void cisco_keepalive_send(struct net_device *dev, u32 type, u32 par1, u32 par2) { struct sk_buff *skb; @@ -67,12 +67,11 @@ static void cisco_keepalive_send(hdlc_device *hdlc, u32 type, if (!skb) { printk(KERN_WARNING "%s: Memory squeeze on cisco_keepalive_send()\n", - hdlc_to_name(hdlc)); + dev->name); return; } skb_reserve(skb, 4); - cisco_hard_header(skb, hdlc_to_dev(hdlc), CISCO_KEEPALIVE, - NULL, NULL, 0); + cisco_hard_header(skb, dev, CISCO_KEEPALIVE, NULL, NULL, 0); data = (cisco_packet*)skb->tail; data->type = htonl(type); @@ -84,7 +83,7 @@ static void cisco_keepalive_send(hdlc_device *hdlc, u32 type, skb_put(skb, sizeof(cisco_packet)); skb->priority = TC_PRIO_CONTROL; - skb->dev = hdlc_to_dev(hdlc); + skb->dev = dev; skb->nh.raw = skb->data; dev_queue_xmit(skb); @@ -118,7 +117,8 @@ static unsigned short cisco_type_trans(struct sk_buff *skb, static int cisco_rx(struct sk_buff *skb) { - hdlc_device *hdlc = dev_to_hdlc(skb->dev); + struct net_device *dev = skb->dev; + hdlc_device *hdlc = dev_to_hdlc(dev); hdlc_header *data = (hdlc_header*)skb->data; cisco_packet *cisco_data; struct in_device *in_dev; @@ -142,7 +142,7 @@ static int cisco_rx(struct sk_buff *skb) skb->len != sizeof(hdlc_header) + CISCO_BIG_PACKET_LEN) { printk(KERN_INFO "%s: Invalid length of Cisco " "control packet (%d bytes)\n", - hdlc_to_name(hdlc), skb->len); + dev->name, skb->len); goto rx_error; } @@ -150,7 +150,7 @@ static int cisco_rx(struct sk_buff *skb) switch(ntohl (cisco_data->type)) { case CISCO_ADDR_REQ: /* Stolen from syncppp.c :-) */ - in_dev = hdlc_to_dev(hdlc)->ip_ptr; + in_dev = dev->ip_ptr; addr = 0; mask = ~0; /* is the mask correct? */ @@ -158,7 +158,7 @@ static int cisco_rx(struct sk_buff *skb) struct in_ifaddr **ifap = &in_dev->ifa_list; while (*ifap != NULL) { - if (strcmp(hdlc_to_name(hdlc), + if (strcmp(dev->name, (*ifap)->ifa_label) == 0) { addr = (*ifap)->ifa_local; mask = (*ifap)->ifa_mask; @@ -167,7 +167,7 @@ static int cisco_rx(struct sk_buff *skb) ifap = &(*ifap)->ifa_next; } - cisco_keepalive_send(hdlc, CISCO_ADDR_REPLY, + cisco_keepalive_send(dev, CISCO_ADDR_REPLY, addr, mask); } dev_kfree_skb_any(skb); @@ -175,7 +175,7 @@ static int cisco_rx(struct sk_buff *skb) case CISCO_ADDR_REPLY: printk(KERN_INFO "%s: Unexpected Cisco IP address " - "reply\n", hdlc_to_name(hdlc)); + "reply\n", dev->name); goto rx_error; case CISCO_KEEPALIVE_REQ: @@ -190,7 +190,7 @@ static int cisco_rx(struct sk_buff *skb) days = hrs / 24; hrs -= days * 24; printk(KERN_INFO "%s: Link up (peer " "uptime %ud%uh%um%us)\n", - hdlc_to_name(hdlc), days, hrs, + dev->name, days, hrs, min, sec); } hdlc->state.cisco.up = 1; @@ -201,7 +201,7 @@ static int cisco_rx(struct sk_buff *skb) } /* switch(keepalive type) */ } /* switch(protocol) */ - printk(KERN_INFO "%s: Unsupported protocol %x\n", hdlc_to_name(hdlc), + printk(KERN_INFO "%s: Unsupported protocol %x\n", dev->name, data->protocol); dev_kfree_skb_any(skb); return NET_RX_DROP; @@ -216,17 +216,18 @@ static int cisco_rx(struct sk_buff *skb) static void cisco_timer(unsigned long arg) { - hdlc_device *hdlc = (hdlc_device*)arg; + struct net_device *dev = (struct net_device *)arg; + hdlc_device *hdlc = dev_to_hdlc(dev); if (hdlc->state.cisco.up && jiffies - hdlc->state.cisco.last_poll >= hdlc->state.cisco.settings.timeout * HZ) { hdlc->state.cisco.up = 0; - printk(KERN_INFO "%s: Link down\n", hdlc_to_name(hdlc)); - if (netif_carrier_ok(&hdlc->netdev)) - netif_carrier_off(&hdlc->netdev); + printk(KERN_INFO "%s: Link down\n", dev->name); + if (netif_carrier_ok(dev)) + netif_carrier_off(dev); } - cisco_keepalive_send(hdlc, CISCO_KEEPALIVE_REQ, + cisco_keepalive_send(dev, CISCO_KEEPALIVE_REQ, ++hdlc->state.cisco.txseq, hdlc->state.cisco.rxseq); hdlc->state.cisco.timer.expires = jiffies + @@ -248,7 +249,7 @@ static void cisco_start(struct net_device *dev) init_timer(&hdlc->state.cisco.timer); hdlc->state.cisco.timer.expires = jiffies + HZ; /*First poll after 1s*/ hdlc->state.cisco.timer.function = cisco_timer; - hdlc->state.cisco.timer.data = (unsigned long)hdlc; + hdlc->state.cisco.timer.data = (unsigned long)dev; add_timer(&hdlc->state.cisco.timer); } @@ -263,12 +264,12 @@ static void cisco_stop(struct net_device *dev) -int hdlc_cisco_ioctl(hdlc_device *hdlc, struct ifreq *ifr) +int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr) { cisco_proto *cisco_s = ifr->ifr_settings.ifs_ifsu.cisco; const size_t size = sizeof(cisco_proto); cisco_proto new_settings; - struct net_device *dev = hdlc_to_dev(hdlc); + hdlc_device *hdlc = dev_to_hdlc(dev); int result; switch (ifr->ifr_settings.type) { diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index 5b01e6362df7..7dad287f199c 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -181,7 +181,7 @@ void hdlc_close(struct net_device *dev) #endif #ifndef CONFIG_HDLC_CISCO -#define hdlc_cisco_ioctl(hdlc, ifr) -ENOSYS +#define hdlc_cisco_ioctl(dev, ifr) -ENOSYS #endif #ifndef CONFIG_HDLC_FR @@ -219,7 +219,7 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) case IF_PROTO_HDLC: return hdlc_raw_ioctl(hdlc, ifr); case IF_PROTO_HDLC_ETH: return hdlc_raw_eth_ioctl(hdlc, ifr); case IF_PROTO_PPP: return hdlc_ppp_ioctl(hdlc, ifr); - case IF_PROTO_CISCO: return hdlc_cisco_ioctl(hdlc, ifr); + case IF_PROTO_CISCO: return hdlc_cisco_ioctl(dev, ifr); case IF_PROTO_FR: return hdlc_fr_ioctl(hdlc, ifr); case IF_PROTO_X25: return hdlc_x25_ioctl(hdlc, ifr); default: return -EINVAL; diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index 22f7615bd6b6..e78f8ae37c69 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -173,7 +173,7 @@ typedef struct hdlc_device_struct { int hdlc_raw_ioctl(hdlc_device *hdlc, struct ifreq *ifr); int hdlc_raw_eth_ioctl(hdlc_device *hdlc, struct ifreq *ifr); -int hdlc_cisco_ioctl(hdlc_device *hdlc, struct ifreq *ifr); +int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr); int hdlc_ppp_ioctl(hdlc_device *hdlc, struct ifreq *ifr); int hdlc_fr_ioctl(hdlc_device *hdlc, struct ifreq *ifr); int hdlc_x25_ioctl(hdlc_device *hdlc, struct ifreq *ifr); -- cgit v1.2.3 From aa7815effbd16d0a1b59c60e176d1dee29ec7fb7 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:53:51 -0500 Subject: [wan hdlc] hdlc_fr: eliminated ->netdev, hdlc_to_dev() and hdlc_to_name() uses. --- drivers/net/wan/hdlc_fr.c | 119 ++++++++++++++++++++++------------------- drivers/net/wan/hdlc_generic.c | 4 +- include/linux/hdlc.h | 4 +- 3 files changed, 68 insertions(+), 59 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c index acf4beb8a4d1..9d0f1abfd094 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c @@ -146,8 +146,9 @@ static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci) } -static inline pvc_device* add_pvc(hdlc_device *hdlc, u16 dlci) +static inline pvc_device* add_pvc(struct net_device *dev, u16 dlci) { + hdlc_device *hdlc = dev_to_hdlc(dev); pvc_device *pvc, **pvc_p = &hdlc->state.fr.first_pvc; while (*pvc_p) { @@ -164,7 +165,7 @@ static inline pvc_device* add_pvc(hdlc_device *hdlc, u16 dlci) memset(pvc, 0, sizeof(pvc_device)); pvc->dlci = dlci; - pvc->master = hdlc; + pvc->master = dev; pvc->next = *pvc_p; /* Put it in the chain */ *pvc_p = pvc; return pvc; @@ -311,15 +312,16 @@ static int pvc_open(struct net_device *dev) { pvc_device *pvc = dev_to_pvc(dev); - if ((hdlc_to_dev(pvc->master)->flags & IFF_UP) == 0) + if ((pvc->master->flags & IFF_UP) == 0) return -EIO; /* Master must be UP in order to activate PVC */ if (pvc->open_count++ == 0) { - if (pvc->master->state.fr.settings.lmi == LMI_NONE) - pvc->state.active = pvc->master->carrier; + hdlc_device *hdlc = dev_to_hdlc(pvc->master); + if (hdlc->state.fr.settings.lmi == LMI_NONE) + pvc->state.active = hdlc->carrier; pvc_carrier(pvc->state.active, pvc); - pvc->master->state.fr.dce_changed = 1; + hdlc->state.fr.dce_changed = 1; } return 0; } @@ -331,11 +333,12 @@ static int pvc_close(struct net_device *dev) pvc_device *pvc = dev_to_pvc(dev); if (--pvc->open_count == 0) { - if (pvc->master->state.fr.settings.lmi == LMI_NONE) + hdlc_device *hdlc = dev_to_hdlc(pvc->master); + if (hdlc->state.fr.settings.lmi == LMI_NONE) pvc->state.active = 0; - if (pvc->master->state.fr.settings.dce) { - pvc->master->state.fr.dce_changed = 1; + if (hdlc->state.fr.settings.dce) { + hdlc->state.fr.dce_changed = 1; pvc->state.active = 0; } } @@ -362,7 +365,7 @@ int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) } info.dlci = pvc->dlci; - memcpy(info.master, hdlc_to_name(pvc->master), IFNAMSIZ); + memcpy(info.master, pvc->master->name, IFNAMSIZ); if (copy_to_user(ifr->ifr_settings.ifs_ifsu.fr_pvc_info, &info, sizeof(info))) return -EFAULT; @@ -408,7 +411,7 @@ static int pvc_xmit(struct sk_buff *skb, struct net_device *dev) stats->tx_packets++; if (pvc->state.fecn) /* TX Congestion counter */ stats->tx_compressed++; - skb->dev = hdlc_to_dev(pvc->master); + skb->dev = pvc->master; dev_queue_xmit(skb); return 0; } @@ -434,7 +437,7 @@ static int pvc_change_mtu(struct net_device *dev, int new_mtu) static inline void fr_log_dlci_active(pvc_device *pvc) { printk(KERN_INFO "%s: DLCI %d [%s%s%s]%s %s\n", - hdlc_to_name(pvc->master), + pvc->master->name, pvc->dlci, pvc->main ? pvc->main->name : "", pvc->main && pvc->ether ? " " : "", @@ -454,8 +457,9 @@ static inline u8 fr_lmi_nextseq(u8 x) -static void fr_lmi_send(hdlc_device *hdlc, int fullrep) +static void fr_lmi_send(struct net_device *dev, int fullrep) { + hdlc_device *hdlc = dev_to_hdlc(dev); struct sk_buff *skb; pvc_device *pvc = hdlc->state.fr.first_pvc; int len = (hdlc->state.fr.settings.lmi == LMI_ANSI) ? LMI_ANSI_LENGTH @@ -468,7 +472,7 @@ static void fr_lmi_send(hdlc_device *hdlc, int fullrep) len += hdlc->state.fr.dce_pvc_count * (2 + stat_len); if (len > HDLC_MAX_MRU) { printk(KERN_WARNING "%s: Too many PVCs while sending " - "LMI full report\n", hdlc_to_name(hdlc)); + "LMI full report\n", dev->name); return; } } @@ -476,7 +480,7 @@ static void fr_lmi_send(hdlc_device *hdlc, int fullrep) skb = dev_alloc_skb(len); if (!skb) { printk(KERN_WARNING "%s: Memory squeeze on fr_lmi_send()\n", - hdlc_to_name(hdlc)); + dev->name); return; } memset(skb->data, 0, len); @@ -529,7 +533,7 @@ static void fr_lmi_send(hdlc_device *hdlc, int fullrep) skb_put(skb, i); skb->priority = TC_PRIO_CONTROL; - skb->dev = hdlc_to_dev(hdlc); + skb->dev = dev; skb->nh.raw = skb->data; dev_queue_xmit(skb); @@ -537,14 +541,15 @@ static void fr_lmi_send(hdlc_device *hdlc, int fullrep) -static void fr_set_link_state(int reliable, hdlc_device *hdlc) +static void fr_set_link_state(int reliable, struct net_device *dev) { + hdlc_device *hdlc = dev_to_hdlc(dev); pvc_device *pvc = hdlc->state.fr.first_pvc; hdlc->state.fr.reliable = reliable; if (reliable) { - if (!netif_carrier_ok(&hdlc->netdev)) - netif_carrier_on(&hdlc->netdev); + if (!netif_carrier_ok(dev)) + netif_carrier_on(dev); hdlc->state.fr.n391cnt = 0; /* Request full status */ hdlc->state.fr.dce_changed = 1; @@ -558,8 +563,8 @@ static void fr_set_link_state(int reliable, hdlc_device *hdlc) } } } else { - if (netif_carrier_ok(&hdlc->netdev)) - netif_carrier_off(&hdlc->netdev); + if (netif_carrier_ok(dev)) + netif_carrier_off(dev); while (pvc) { /* Deactivate all PVCs */ pvc_carrier(0, pvc); @@ -574,7 +579,8 @@ static void fr_set_link_state(int reliable, hdlc_device *hdlc) static void fr_timer(unsigned long arg) { - hdlc_device *hdlc = (hdlc_device*)arg; + struct net_device *dev = (struct net_device *)arg; + hdlc_device *hdlc = dev_to_hdlc(dev); int i, cnt = 0, reliable; u32 list; @@ -586,7 +592,7 @@ static void fr_timer(unsigned long arg) if (hdlc->state.fr.request) { if (hdlc->state.fr.reliable) printk(KERN_INFO "%s: No LMI status reply " - "received\n", hdlc_to_name(hdlc)); + "received\n", dev->name); hdlc->state.fr.last_errors |= 1; } @@ -598,9 +604,9 @@ static void fr_timer(unsigned long arg) } if (hdlc->state.fr.reliable != reliable) { - printk(KERN_INFO "%s: Link %sreliable\n", hdlc_to_name(hdlc), + printk(KERN_INFO "%s: Link %sreliable\n", dev->name, reliable ? "" : "un"); - fr_set_link_state(reliable, hdlc); + fr_set_link_state(reliable, dev); } if (hdlc->state.fr.settings.dce) @@ -610,7 +616,7 @@ static void fr_timer(unsigned long arg) if (hdlc->state.fr.n391cnt) hdlc->state.fr.n391cnt--; - fr_lmi_send(hdlc, hdlc->state.fr.n391cnt == 0); + fr_lmi_send(dev, hdlc->state.fr.n391cnt == 0); hdlc->state.fr.request = 1; hdlc->state.fr.timer.expires = jiffies + @@ -624,8 +630,9 @@ static void fr_timer(unsigned long arg) -static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb) +static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb) { + hdlc_device *hdlc = dev_to_hdlc(dev); int stat_len; pvc_device *pvc; int reptype = -1, error, no_ram; @@ -634,14 +641,14 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb) if (skb->len < ((hdlc->state.fr.settings.lmi == LMI_ANSI) ? LMI_ANSI_LENGTH : LMI_LENGTH)) { - printk(KERN_INFO "%s: Short LMI frame\n", hdlc_to_name(hdlc)); + printk(KERN_INFO "%s: Short LMI frame\n", dev->name); return 1; } if (skb->data[5] != (!hdlc->state.fr.settings.dce ? LMI_STATUS : LMI_STATUS_ENQUIRY)) { printk(KERN_INFO "%s: LMI msgtype=%x, Not LMI status %s\n", - hdlc_to_name(hdlc), skb->data[2], + dev->name, skb->data[2], hdlc->state.fr.settings.dce ? "enquiry" : "reply"); return 1; } @@ -652,7 +659,7 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb) ((hdlc->state.fr.settings.lmi == LMI_CCITT) ? LMI_CCITT_REPTYPE : LMI_REPTYPE)) { printk(KERN_INFO "%s: Not a report type=%x\n", - hdlc_to_name(hdlc), skb->data[i]); + dev->name, skb->data[i]); return 1; } i++; @@ -665,7 +672,7 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb) ((hdlc->state.fr.settings.lmi == LMI_CCITT) ? LMI_CCITT_ALIVE : LMI_ALIVE)) { printk(KERN_INFO "%s: Unsupported status element=%x\n", - hdlc_to_name(hdlc), skb->data[i]); + dev->name, skb->data[i]); return 1; } i++; @@ -680,7 +687,7 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb) if (hdlc->state.fr.settings.dce) { if (reptype != LMI_FULLREP && reptype != LMI_INTEGRITY) { printk(KERN_INFO "%s: Unsupported report type=%x\n", - hdlc_to_name(hdlc), reptype); + dev->name, reptype); return 1; } } @@ -716,7 +723,7 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb) hdlc->state.fr.dce_changed = 0; } - fr_lmi_send(hdlc, reptype == LMI_FULLREP ? 1 : 0); + fr_lmi_send(dev, reptype == LMI_FULLREP ? 1 : 0); return 0; } @@ -741,26 +748,26 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb) if (skb->data[i] != ((hdlc->state.fr.settings.lmi == LMI_CCITT) ? LMI_CCITT_PVCSTAT : LMI_PVCSTAT)) { printk(KERN_WARNING "%s: Invalid PVCSTAT ID: %x\n", - hdlc_to_name(hdlc), skb->data[i]); + dev->name, skb->data[i]); return 1; } i++; if (skb->data[i] != stat_len) { printk(KERN_WARNING "%s: Invalid PVCSTAT length: %x\n", - hdlc_to_name(hdlc), skb->data[i]); + dev->name, skb->data[i]); return 1; } i++; dlci = status_to_dlci(skb->data + i, &active, &new); - pvc = add_pvc(hdlc, dlci); + pvc = add_pvc(dev, dlci); if (!pvc && !no_ram) { printk(KERN_WARNING "%s: Memory squeeze on fr_lmi_recv()\n", - hdlc_to_name(hdlc)); + dev->name); no_ram = 1; } @@ -802,7 +809,8 @@ static int fr_lmi_recv(hdlc_device *hdlc, struct sk_buff *skb) static int fr_rx(struct sk_buff *skb) { - hdlc_device *hdlc = dev_to_hdlc(skb->dev); + struct net_device *ndev = skb->dev; + hdlc_device *hdlc = dev_to_hdlc(ndev); fr_hdr *fh = (fr_hdr*)skb->data; u8 *data = skb->data; u16 dlci; @@ -819,7 +827,7 @@ static int fr_rx(struct sk_buff *skb) goto rx_error; /* LMI packet with no LMI? */ if (data[3] == LMI_PROTO) { - if (fr_lmi_recv(hdlc, skb)) + if (fr_lmi_recv(ndev, skb)) goto rx_error; else { /* No request pending */ @@ -831,7 +839,7 @@ static int fr_rx(struct sk_buff *skb) } printk(KERN_INFO "%s: Received non-LMI frame with LMI DLCI\n", - hdlc_to_name(hdlc)); + ndev->name); goto rx_error; } @@ -839,7 +847,7 @@ static int fr_rx(struct sk_buff *skb) if (!pvc) { #ifdef DEBUG_PKT printk(KERN_INFO "%s: No PVC for received frame's DLCI %d\n", - hdlc_to_name(hdlc), dlci); + ndev->name, dlci); #endif dev_kfree_skb_any(skb); return NET_RX_DROP; @@ -847,7 +855,7 @@ static int fr_rx(struct sk_buff *skb) if (pvc->state.fecn != fh->fecn) { #ifdef DEBUG_ECN - printk(KERN_DEBUG "%s: DLCI %d FECN O%s\n", hdlc_to_name(pvc), + printk(KERN_DEBUG "%s: DLCI %d FECN O%s\n", ndev->name, dlci, fh->fecn ? "N" : "FF"); #endif pvc->state.fecn ^= 1; @@ -855,7 +863,7 @@ static int fr_rx(struct sk_buff *skb) if (pvc->state.becn != fh->becn) { #ifdef DEBUG_ECN - printk(KERN_DEBUG "%s: DLCI %d BECN O%s\n", hdlc_to_name(pvc), + printk(KERN_DEBUG "%s: DLCI %d BECN O%s\n", ndev->name, dlci, fh->becn ? "N" : "FF"); #endif pvc->state.becn ^= 1; @@ -899,13 +907,13 @@ static int fr_rx(struct sk_buff *skb) default: printk(KERN_INFO "%s: Unsupported protocol, OUI=%x " - "PID=%x\n", hdlc_to_name(hdlc), oui, pid); + "PID=%x\n", ndev->name, oui, pid); dev_kfree_skb_any(skb); return NET_RX_DROP; } } else { printk(KERN_INFO "%s: Unsupported protocol, NLPID=%x " - "length = %i\n", hdlc_to_name(hdlc), data[3], skb->len); + "length = %i\n", ndev->name, data[3], skb->len); dev_kfree_skb_any(skb); return NET_RX_DROP; } @@ -954,10 +962,10 @@ static void fr_start(struct net_device *dev) /* First poll after 1 s */ hdlc->state.fr.timer.expires = jiffies + HZ; hdlc->state.fr.timer.function = fr_timer; - hdlc->state.fr.timer.data = (unsigned long)hdlc; + hdlc->state.fr.timer.data = (unsigned long)dev; add_timer(&hdlc->state.fr.timer); } else - fr_set_link_state(1, hdlc); + fr_set_link_state(1, dev); } @@ -970,7 +978,7 @@ static void fr_stop(struct net_device *dev) #endif if (hdlc->state.fr.settings.lmi != LMI_NONE) del_timer_sync(&hdlc->state.fr.timer); - fr_set_link_state(0, hdlc); + fr_set_link_state(0, dev); } @@ -991,8 +999,9 @@ static void fr_close(struct net_device *dev) -static int fr_add_pvc(hdlc_device *hdlc, unsigned int dlci, int type) +static int fr_add_pvc(struct net_device *master, unsigned int dlci, int type) { + hdlc_device *hdlc = dev_to_hdlc(master); pvc_device *pvc = NULL; struct net_device *dev; int result, used; @@ -1001,9 +1010,9 @@ static int fr_add_pvc(hdlc_device *hdlc, unsigned int dlci, int type) if (type == ARPHRD_ETHER) prefix = "pvceth%d"; - if ((pvc = add_pvc(hdlc, dlci)) == NULL) { + if ((pvc = add_pvc(master, dlci)) == NULL) { printk(KERN_WARNING "%s: Memory squeeze on fr_add_pvc()\n", - hdlc_to_name(hdlc)); + master->name); return -ENOBUFS; } @@ -1016,7 +1025,7 @@ static int fr_add_pvc(hdlc_device *hdlc, unsigned int dlci, int type) sizeof(struct net_device_stats), GFP_KERNEL); if (!dev) { printk(KERN_WARNING "%s: Memory squeeze on fr_pvc()\n", - hdlc_to_name(hdlc)); + master->name); delete_unused_pvcs(hdlc); return -ENOBUFS; } @@ -1120,12 +1129,12 @@ static void fr_destroy(hdlc_device *hdlc) -int hdlc_fr_ioctl(hdlc_device *hdlc, struct ifreq *ifr) +int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr) { fr_proto *fr_s = ifr->ifr_settings.ifs_ifsu.fr; const size_t size = sizeof(fr_proto); fr_proto new_settings; - struct net_device *dev = hdlc_to_dev(hdlc); + hdlc_device *hdlc = dev_to_hdlc(dev); fr_proto_pvc pvc; int result; @@ -1213,7 +1222,7 @@ int hdlc_fr_ioctl(hdlc_device *hdlc, struct ifreq *ifr) if (ifr->ifr_settings.type == IF_PROTO_FR_ADD_PVC || ifr->ifr_settings.type == IF_PROTO_FR_ADD_ETH_PVC) - return fr_add_pvc(hdlc, pvc.dlci, result); + return fr_add_pvc(dev, pvc.dlci, result); else return fr_del_pvc(hdlc, pvc.dlci, result); } diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index 7dad287f199c..ce5b35c83597 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -185,7 +185,7 @@ void hdlc_close(struct net_device *dev) #endif #ifndef CONFIG_HDLC_FR -#define hdlc_fr_ioctl(hdlc, ifr) -ENOSYS +#define hdlc_fr_ioctl(dev, ifr) -ENOSYS #endif #ifndef CONFIG_HDLC_X25 @@ -220,7 +220,7 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) case IF_PROTO_HDLC_ETH: return hdlc_raw_eth_ioctl(hdlc, ifr); case IF_PROTO_PPP: return hdlc_ppp_ioctl(hdlc, ifr); case IF_PROTO_CISCO: return hdlc_cisco_ioctl(dev, ifr); - case IF_PROTO_FR: return hdlc_fr_ioctl(hdlc, ifr); + case IF_PROTO_FR: return hdlc_fr_ioctl(dev, ifr); case IF_PROTO_X25: return hdlc_x25_ioctl(hdlc, ifr); default: return -EINVAL; } diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index e78f8ae37c69..dcd716f9042e 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -75,7 +75,7 @@ typedef struct { typedef struct pvc_device_struct { - struct hdlc_device_struct *master; + struct net_device *master; struct net_device *main; struct net_device *ether; /* bridged Ethernet interface */ struct pvc_device_struct *next; /* Sorted in ascending DLCI order */ @@ -175,7 +175,7 @@ int hdlc_raw_ioctl(hdlc_device *hdlc, struct ifreq *ifr); int hdlc_raw_eth_ioctl(hdlc_device *hdlc, struct ifreq *ifr); int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr); int hdlc_ppp_ioctl(hdlc_device *hdlc, struct ifreq *ifr); -int hdlc_fr_ioctl(hdlc_device *hdlc, struct ifreq *ifr); +int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr); int hdlc_x25_ioctl(hdlc_device *hdlc, struct ifreq *ifr); -- cgit v1.2.3 From f31b6d7619dc3e1179bdf65813cf01192a4c62aa Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:54:24 -0500 Subject: [wan hdlc_x25] eliminated hdlc_to_dev() and hdlc_to_name() uses. --- drivers/net/wan/hdlc_generic.c | 4 ++-- drivers/net/wan/hdlc_x25.c | 9 ++++----- include/linux/hdlc.h | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index ce5b35c83597..70d683de4ae0 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -189,7 +189,7 @@ void hdlc_close(struct net_device *dev) #endif #ifndef CONFIG_HDLC_X25 -#define hdlc_x25_ioctl(hdlc, ifr) -ENOSYS +#define hdlc_x25_ioctl(dev, ifr) -ENOSYS #endif @@ -221,7 +221,7 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) case IF_PROTO_PPP: return hdlc_ppp_ioctl(hdlc, ifr); case IF_PROTO_CISCO: return hdlc_cisco_ioctl(dev, ifr); case IF_PROTO_FR: return hdlc_fr_ioctl(dev, ifr); - case IF_PROTO_X25: return hdlc_x25_ioctl(hdlc, ifr); + case IF_PROTO_X25: return hdlc_x25_ioctl(dev, ifr); default: return -EINVAL; } } diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c index cf772135d5be..5231063c9d64 100644 --- a/drivers/net/wan/hdlc_x25.c +++ b/drivers/net/wan/hdlc_x25.c @@ -94,7 +94,6 @@ static void x25_data_transmit(struct net_device *dev, struct sk_buff *skb) static int x25_xmit(struct sk_buff *skb, struct net_device *dev) { - hdlc_device *hdlc = dev_to_hdlc(dev); int result; @@ -114,7 +113,7 @@ static int x25_xmit(struct sk_buff *skb, struct net_device *dev) else printk(KERN_ERR "%s: LAPB connect request " "failed, error code = %i\n", - hdlc_to_name(hdlc), result); + dev->name, result); } break; @@ -126,7 +125,7 @@ static int x25_xmit(struct sk_buff *skb, struct net_device *dev) else printk(KERN_ERR "%s: LAPB disconnect request " "failed, error code = %i\n", - hdlc_to_name(hdlc), result); + dev->name, result); } break; @@ -186,9 +185,9 @@ static int x25_rx(struct sk_buff *skb) -int hdlc_x25_ioctl(hdlc_device *hdlc, struct ifreq *ifr) +int hdlc_x25_ioctl(struct net_device *dev, struct ifreq *ifr) { - struct net_device *dev = hdlc_to_dev(hdlc); + hdlc_device *hdlc = dev_to_hdlc(dev); int result; switch (ifr->ifr_settings.type) { diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index dcd716f9042e..91fe1121d55b 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -176,7 +176,7 @@ int hdlc_raw_eth_ioctl(hdlc_device *hdlc, struct ifreq *ifr); int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr); int hdlc_ppp_ioctl(hdlc_device *hdlc, struct ifreq *ifr); int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr); -int hdlc_x25_ioctl(hdlc_device *hdlc, struct ifreq *ifr); +int hdlc_x25_ioctl(struct net_device *dev, struct ifreq *ifr); /* Exported from hdlc.o */ -- cgit v1.2.3 From 61fd4dc7849a43ddcd4785e8f88b2b6ee2d8d6b0 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:55:30 -0500 Subject: [wan hdlc] switch internal ioctl dispatch to net_device Switched remaining ioctls to net_device, killed a bunch of hdlc_to_dev() and killed hdlc_to_name(). --- drivers/net/wan/hdlc_generic.c | 12 ++++++------ drivers/net/wan/hdlc_ppp.c | 4 ++-- drivers/net/wan/hdlc_raw.c | 4 ++-- drivers/net/wan/hdlc_raw_eth.c | 4 ++-- include/linux/hdlc.h | 12 +++--------- 5 files changed, 15 insertions(+), 21 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index 70d683de4ae0..ffbcb2db0fc6 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -169,15 +169,15 @@ void hdlc_close(struct net_device *dev) #ifndef CONFIG_HDLC_RAW -#define hdlc_raw_ioctl(hdlc, ifr) -ENOSYS +#define hdlc_raw_ioctl(dev, ifr) -ENOSYS #endif #ifndef CONFIG_HDLC_RAW_ETH -#define hdlc_raw_eth_ioctl(hdlc, ifr) -ENOSYS +#define hdlc_raw_eth_ioctl(dev, ifr) -ENOSYS #endif #ifndef CONFIG_HDLC_PPP -#define hdlc_ppp_ioctl(hdlc, ifr) -ENOSYS +#define hdlc_ppp_ioctl(dev, ifr) -ENOSYS #endif #ifndef CONFIG_HDLC_CISCO @@ -216,9 +216,9 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) } switch(proto) { - case IF_PROTO_HDLC: return hdlc_raw_ioctl(hdlc, ifr); - case IF_PROTO_HDLC_ETH: return hdlc_raw_eth_ioctl(hdlc, ifr); - case IF_PROTO_PPP: return hdlc_ppp_ioctl(hdlc, ifr); + case IF_PROTO_HDLC: return hdlc_raw_ioctl(dev, ifr); + case IF_PROTO_HDLC_ETH: return hdlc_raw_eth_ioctl(dev, ifr); + case IF_PROTO_PPP: return hdlc_ppp_ioctl(dev, ifr); case IF_PROTO_CISCO: return hdlc_cisco_ioctl(dev, ifr); case IF_PROTO_FR: return hdlc_fr_ioctl(dev, ifr); case IF_PROTO_X25: return hdlc_x25_ioctl(dev, ifr); diff --git a/drivers/net/wan/hdlc_ppp.c b/drivers/net/wan/hdlc_ppp.c index e9ebd0c0c180..7cd6195a2e46 100644 --- a/drivers/net/wan/hdlc_ppp.c +++ b/drivers/net/wan/hdlc_ppp.c @@ -74,9 +74,9 @@ static unsigned short ppp_type_trans(struct sk_buff *skb, -int hdlc_ppp_ioctl(hdlc_device *hdlc, struct ifreq *ifr) +int hdlc_ppp_ioctl(struct net_device *dev, struct ifreq *ifr) { - struct net_device *dev = hdlc_to_dev(hdlc); + hdlc_device *hdlc = dev_to_hdlc(dev); int result; switch (ifr->ifr_settings.type) { diff --git a/drivers/net/wan/hdlc_raw.c b/drivers/net/wan/hdlc_raw.c index 8d091cf0c987..42690658b146 100644 --- a/drivers/net/wan/hdlc_raw.c +++ b/drivers/net/wan/hdlc_raw.c @@ -32,12 +32,12 @@ static unsigned short raw_type_trans(struct sk_buff *skb, -int hdlc_raw_ioctl(hdlc_device *hdlc, struct ifreq *ifr) +int hdlc_raw_ioctl(struct net_device *dev, struct ifreq *ifr) { raw_hdlc_proto *raw_s = ifr->ifr_settings.ifs_ifsu.raw_hdlc; const size_t size = sizeof(raw_hdlc_proto); raw_hdlc_proto new_settings; - struct net_device *dev = hdlc_to_dev(hdlc); + hdlc_device *hdlc = dev_to_hdlc(dev); int result; switch (ifr->ifr_settings.type) { diff --git a/drivers/net/wan/hdlc_raw_eth.c b/drivers/net/wan/hdlc_raw_eth.c index 89c887ad5b2c..b8150405424f 100644 --- a/drivers/net/wan/hdlc_raw_eth.c +++ b/drivers/net/wan/hdlc_raw_eth.c @@ -44,12 +44,12 @@ static int eth_tx(struct sk_buff *skb, struct net_device *dev) } -int hdlc_raw_eth_ioctl(hdlc_device *hdlc, struct ifreq *ifr) +int hdlc_raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr) { raw_hdlc_proto *raw_s = ifr->ifr_settings.ifs_ifsu.raw_hdlc; const size_t size = sizeof(raw_hdlc_proto); raw_hdlc_proto new_settings; - struct net_device *dev = hdlc_to_dev(hdlc); + hdlc_device *hdlc = dev_to_hdlc(dev); int result; void *old_ch_mtu; int old_qlen; diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index 91fe1121d55b..53f160515b9d 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -171,10 +171,10 @@ typedef struct hdlc_device_struct { -int hdlc_raw_ioctl(hdlc_device *hdlc, struct ifreq *ifr); -int hdlc_raw_eth_ioctl(hdlc_device *hdlc, struct ifreq *ifr); +int hdlc_raw_ioctl(struct net_device *dev, struct ifreq *ifr); +int hdlc_raw_eth_ioctl(struct net_device *dev, struct ifreq *ifr); int hdlc_cisco_ioctl(struct net_device *dev, struct ifreq *ifr); -int hdlc_ppp_ioctl(hdlc_device *hdlc, struct ifreq *ifr); +int hdlc_ppp_ioctl(struct net_device *dev, struct ifreq *ifr); int hdlc_fr_ioctl(struct net_device *dev, struct ifreq *ifr); int hdlc_x25_ioctl(struct net_device *dev, struct ifreq *ifr); @@ -207,12 +207,6 @@ static __inline__ pvc_device* dev_to_pvc(struct net_device *dev) } -static __inline__ const char *hdlc_to_name(hdlc_device *hdlc) -{ - return hdlc_to_dev(hdlc)->name; -} - - static __inline__ void debug_frame(const struct sk_buff *skb) { int i; -- cgit v1.2.3 From 0108ce25029474be8a46c8dbb0f3e97657e8478d Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 08:56:58 -0500 Subject: [wan hdlc] new hdlc_stats() helper New inlined helper - hdlc_stats(). A lot of places had it spelled out; replaced with calls. --- drivers/net/wan/c101.c | 2 +- drivers/net/wan/dscc4.c | 8 ++++---- drivers/net/wan/farsync.c | 10 +++++----- drivers/net/wan/hd6457x.c | 12 ++++++------ drivers/net/wan/hdlc_generic.c | 2 +- drivers/net/wan/hdlc_raw_eth.c | 2 +- drivers/net/wan/pc300_drv.c | 10 +++++----- drivers/net/wan/pc300_tty.c | 6 +++--- drivers/net/wan/wanxl.c | 15 +++++++-------- include/linux/hdlc.h | 6 ++++++ 10 files changed, 39 insertions(+), 34 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c index 9d5e121af26b..fed8f3b3649d 100644 --- a/drivers/net/wan/c101.c +++ b/drivers/net/wan/c101.c @@ -129,7 +129,7 @@ static void sca_msci_intr(port_t *port) sca_out(stat & ST1_UDRN, MSCI0_OFFSET + ST1, card); if (stat & ST1_UDRN) { - struct net_device_stats *stats = &dev_to_hdlc(dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev); stats->tx_errors++; /* TX Underrun error detected */ stats->tx_fifo_errors++; } diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c index d9d34e7f25e9..0e6bf476bdbb 100644 --- a/drivers/net/wan/dscc4.c +++ b/drivers/net/wan/dscc4.c @@ -636,7 +636,7 @@ static inline void dscc4_rx_skb(struct dscc4_dev_priv *dpriv, struct net_device *dev) { struct RxFD *rx_fd = dpriv->rx_fd + dpriv->rx_current%RX_RING_SIZE; - struct net_device_stats *stats = &dpriv->hdlc.stats; + struct net_device_stats *stats = hdlc_stats(dev); struct pci_dev *pdev = dpriv->pci_priv->pdev; struct sk_buff *skb; int pkt_len; @@ -1547,7 +1547,7 @@ try: if (state & SccEvt) { if (state & Alls) { - struct net_device_stats *stats = &dpriv->hdlc.stats; + struct net_device_stats *stats = hdlc_stats(dev); struct sk_buff *skb; struct TxFD *tx_fd; @@ -1675,7 +1675,7 @@ try: } if (state & Err) { printk(KERN_INFO "%s: Tx ERR\n", dev->name); - dev_to_hdlc(dev)->stats.tx_errors++; + hdlc_stats(dev)->tx_errors++; state &= ~Err; } } @@ -1811,7 +1811,7 @@ try: if (!(rx_fd->state2 & DataComplete)) break; if (rx_fd->state2 & FrameAborted) { - dev_to_hdlc(dev)->stats.rx_over_errors++; + hdlc_stats(dev)->rx_over_errors++; rx_fd->state1 |= Hold; rx_fd->state2 = 0x00000000; rx_fd->end = 0xbabeface; diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index c78a93207ff5..9edf36840a74 100644 --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c @@ -652,7 +652,7 @@ fst_intr_rx ( struct fst_card_info *card, struct fst_port_info *port ) unsigned short len; struct sk_buff *skb; struct net_device *dev = port_to_dev(port); - struct net_device_stats *stats = &dev_to_hdlc(dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev); int i; @@ -837,8 +837,8 @@ fst_intr ( int irq, void *dev_id, struct pt_regs *regs ) * always load up the entire packet for DMA. */ dbg ( DBG_TX,"Tx underflow port %d\n", event & 0x03 ); - dev_to_hdlc(port_to_dev(port))->stats.tx_errors++; - dev_to_hdlc(port_to_dev(port))->stats.tx_fifo_errors++; + hdlc_stats(port_to_dev(port))->tx_errors++; + hdlc_stats(port_to_dev(port))->tx_fifo_errors++; break; case INIT_CPLT: @@ -1346,7 +1346,7 @@ static void fst_tx_timeout ( struct net_device *dev ) { struct fst_port_info *port; - struct net_device_stats *stats = &dev_to_hdlc(dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev); dbg ( DBG_INTR | DBG_TX,"tx_timeout\n"); @@ -1366,7 +1366,7 @@ fst_tx_timeout ( struct net_device *dev ) static int fst_start_xmit ( struct sk_buff *skb, struct net_device *dev ) { - struct net_device_stats *stats = &dev_to_hdlc(dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev); struct fst_card_info *card; struct fst_port_info *port; unsigned char dmabits; diff --git a/drivers/net/wan/hd6457x.c b/drivers/net/wan/hd6457x.c index 6c17e7000230..bcd2f043823b 100644 --- a/drivers/net/wan/hd6457x.c +++ b/drivers/net/wan/hd6457x.c @@ -256,9 +256,9 @@ static inline void sca_msci_intr(port_t *port) sca_out(stat & (ST1_UDRN | ST1_CDCD), msci + ST1, card); if (stat & ST1_UDRN) { - hdlc_device *hdlc = dev_to_hdlc(port_to_dev(port)); - hdlc->stats.tx_errors++; /* TX Underrun error detected */ - hdlc->stats.tx_fifo_errors++; + struct net_device_stats *stats = hdlc_stats(port_to_dev(port)); + stats->tx_errors++; /* TX Underrun error detected */ + stats->tx_fifo_errors++; } if (stat & ST1_CDCD) @@ -272,7 +272,7 @@ static inline void sca_msci_intr(port_t *port) static inline void sca_rx(card_t *card, port_t *port, pkt_desc *desc, u16 rxin) { struct net_device *dev = port_to_dev(port); - struct net_device_stats *stats = &dev_to_hdlc(dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev); struct sk_buff *skb; u16 len; u32 buff; @@ -330,7 +330,7 @@ static inline void sca_rx_intr(port_t *port) u16 dmac = get_dmac_rx(port); card_t *card = port_to_card(port); u8 stat = sca_in(DSR_RX(phy_node(port)), card); /* read DMA Status */ - struct net_device_stats *stats = &dev_to_hdlc(port_to_dev(port))->stats; + struct net_device_stats *stats = hdlc_stats(port_to_dev(port)); /* Reset DSR status bits */ sca_out((stat & (DSR_EOT | DSR_EOM | DSR_BOF | DSR_COF)) | DSR_DWE, @@ -378,7 +378,7 @@ static inline void sca_rx_intr(port_t *port) static inline void sca_tx_intr(port_t *port) { struct net_device *dev = port_to_dev(port); - struct net_device_stats *stats = &dev_to_hdlc(dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev); u16 dmac = get_dmac_tx(port); card_t* card = port_to_card(port); u8 stat; diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index ffbcb2db0fc6..805725b4b0c0 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -50,7 +50,7 @@ static int hdlc_change_mtu(struct net_device *dev, int new_mtu) static struct net_device_stats *hdlc_get_stats(struct net_device *dev) { - return &dev_to_hdlc(dev)->stats; + return hdlc_stats(dev); } diff --git a/drivers/net/wan/hdlc_raw_eth.c b/drivers/net/wan/hdlc_raw_eth.c index b8150405424f..4ddc2e08c4ec 100644 --- a/drivers/net/wan/hdlc_raw_eth.c +++ b/drivers/net/wan/hdlc_raw_eth.c @@ -33,7 +33,7 @@ static int eth_tx(struct sk_buff *skb, struct net_device *dev) int len = skb->len; if (skb_tailroom(skb) < pad) if (pskb_expand_head(skb, 0, pad, GFP_ATOMIC)) { - dev_to_hdlc(dev)->stats.tx_dropped++; + hdlc_stats(dev)->tx_dropped++; dev_kfree_skb(skb); return 0; } diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c index 7dcd5915530a..57b323eb6297 100644 --- a/drivers/net/wan/pc300_drv.c +++ b/drivers/net/wan/pc300_drv.c @@ -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 = &dev_to_hdlc(dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev); 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 = &dev_to_hdlc(dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev); int ch = chan->channel; uclong flags; #ifdef PC300_DEBUG_TX @@ -1885,7 +1885,7 @@ void cpc_net_rx(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 = &dev_to_hdlc(dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev); int ch = chan->channel; #ifdef PC300_DEBUG_RX int i; @@ -1974,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_to_hdlc(dev->dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev->dev); /* Clean up descriptors from previous transmission */ ptdescr = (pcsca_bd_t *)(card->hw.rambase + @@ -2817,7 +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) { - return &dev_to_hdlc(dev)->stats; + return hdlc_stats(dev); } static int clock_rate_calc(uclong rate, uclong clock, int *br_io) diff --git a/drivers/net/wan/pc300_tty.c b/drivers/net/wan/pc300_tty.c index f3551d3fccae..c4a2e8aee6e2 100644 --- a/drivers/net/wan/pc300_tty.c +++ b/drivers/net/wan/pc300_tty.c @@ -452,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 = &dev_to_hdlc(((pc300dev_t*)cpc_tty->pc300dev)->dev)->stats; + stats = hdlc_stats(((pc300dev_t*)cpc_tty->pc300dev)->dev); card = (pc300_t *) pc300chan->card; ch = pc300chan->channel; @@ -738,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 = &dev_to_hdlc(pc300dev->dev)->stats; + struct net_device_stats *stats = hdlc_stats(pc300dev->dev); int rx_len, rx_aux; volatile unsigned char status; unsigned short first_bd = pc300chan->rx_first_bd; @@ -914,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_to_hdlc(dev->dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev->dev); unsigned long flags; volatile pcsca_bd_t * ptdescr; int i, nchar; diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index 5102de169db7..0e94e40dd2f2 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c @@ -175,7 +175,7 @@ static inline void wanxl_cable_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; + struct net_device_stats *stats = hdlc_stats(dev); while (1) { desc_t *desc = &get_status(port)->tx_descs[port->tx_in]; struct sk_buff *skb = port->tx_skbs[port->tx_in]; @@ -214,7 +214,7 @@ static inline void wanxl_rx_intr(card_t *card) struct sk_buff *skb = card->rx_skbs[card->rx_in]; port_t *port = card->ports[desc->stat & PACKET_PORT_MASK]; struct net_device *dev = port_to_dev(port); - struct net_device_stats *stats = &dev_to_hdlc(dev)->stats; + struct net_device_stats *stats = hdlc_stats(dev); if ((desc->stat & PACKET_PORT_MASK) > card->n_ports) printk(KERN_CRIT "wanXL %s: received packet for" @@ -480,14 +480,13 @@ static int wanxl_close(struct net_device *dev) static struct net_device_stats *wanxl_get_stats(struct net_device *dev) { - hdlc_device *hdlc = dev_to_hdlc(dev); + struct net_device_stats *stats = hdlc_stats(dev); port_t *port = dev_to_port(dev); - hdlc->stats.rx_over_errors = get_status(port)->rx_overruns; - hdlc->stats.rx_frame_errors = get_status(port)->rx_frame_errors; - hdlc->stats.rx_errors = hdlc->stats.rx_over_errors + - hdlc->stats.rx_frame_errors; - return &hdlc->stats; + stats->rx_over_errors = get_status(port)->rx_overruns; + stats->rx_frame_errors = get_status(port)->rx_frame_errors; + stats->rx_errors = stats->rx_over_errors + stats->rx_frame_errors; + return stats; } diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index 53f160515b9d..a9b7c3d153f4 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -238,6 +238,12 @@ static __inline__ void hdlc_proto_detach(hdlc_device *hdlc) } +static __inline__ struct net_device_stats *hdlc_stats(struct net_device *dev) +{ + return &dev_to_hdlc(dev)->stats; +} + + static __inline__ unsigned short hdlc_type_trans(struct sk_buff *skb, struct net_device *dev) { -- cgit v1.2.3 From 070c8cb2e1cb775848b65cc4aeacb99dfdc3c9b3 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 09:00:10 -0500 Subject: [wan hdlc] switch register_hdlc_device() to take net_device arg register_hdlc_device()/unregister_hdlc_device() switched to net_device. Now all remaining callers of hdlc_to_dev() are isolated and we can start killing them. --- drivers/net/wan/c101.c | 4 ++-- drivers/net/wan/dscc4.c | 8 ++++---- drivers/net/wan/farsync.c | 4 ++-- drivers/net/wan/hdlc_generic.c | 10 +++++----- drivers/net/wan/n2.c | 4 ++-- drivers/net/wan/pc300_drv.c | 4 ++-- drivers/net/wan/wanxl.c | 4 ++-- include/linux/hdlc.h | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c index fed8f3b3649d..8c7ad592a5c4 100644 --- a/drivers/net/wan/c101.c +++ b/drivers/net/wan/c101.c @@ -363,7 +363,7 @@ static int __init c101_run(unsigned long irq, unsigned long winbase) hdlc->xmit = sca_xmit; card->settings.clock_type = CLOCK_EXT; - result = register_hdlc_device(hdlc); + result = register_hdlc_device(dev); if (result) { printk(KERN_WARNING "c101: unable to register hdlc device\n"); c101_destroy_card(card); @@ -424,7 +424,7 @@ static void __exit c101_cleanup(void) while (card) { card_t *ptr = card; card = card->next_card; - unregister_hdlc_device(dev_to_hdlc(port_to_dev(ptr))); + unregister_hdlc_device(port_to_dev(ptr)); c101_destroy_card(ptr); } } diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c index 1bb203f3423f..7478c8287df8 100644 --- a/drivers/net/wan/dscc4.c +++ b/drivers/net/wan/dscc4.c @@ -694,7 +694,7 @@ static void dscc4_free1(struct pci_dev *pdev) root = ppriv->root; for (i = 0; i < dev_per_card; i++) - unregister_hdlc_device(&root[i].hdlc); + unregister_hdlc_device(dscc4_to_dev(&root[i])); pci_set_drvdata(pdev, NULL); @@ -910,7 +910,7 @@ static int dscc4_found1(struct pci_dev *pdev, unsigned long ioaddr) hdlc->xmit = dscc4_start_xmit; hdlc->attach = dscc4_hdlc_attach; - ret = register_hdlc_device(hdlc); + ret = register_hdlc_device(d); if (ret < 0) { printk(KERN_ERR "%s: unable to register\n", DRV_NAME); goto err_unregister; @@ -922,7 +922,7 @@ static int dscc4_found1(struct pci_dev *pdev, unsigned long ioaddr) ret = dscc4_init_ring(d); if (ret < 0) { - unregister_hdlc_device(hdlc); + unregister_hdlc_device(d); goto err_unregister; } } @@ -937,7 +937,7 @@ static int dscc4_found1(struct pci_dev *pdev, unsigned long ioaddr) err_unregister: while (--i >= 0) { dscc4_release_ring(root + i); - unregister_hdlc_device(&root[i].hdlc); + unregister_hdlc_device(dscc4_to_dev(&root[i])); } kfree(ppriv); err_free_dev: diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index 9edf36840a74..120f43177efe 100644 --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c @@ -1491,7 +1491,7 @@ fst_init_card ( struct fst_card_info *card ) hdlc->attach = fst_attach; hdlc->xmit = fst_start_xmit; - if (( err = register_hdlc_device(dev_to_hdlc(dev))) < 0 ) + if (( err = register_hdlc_device(dev)) < 0 ) { printk_err ("Cannot register HDLC device for port %d" " (errno %d)\n", i, -err ); @@ -1657,7 +1657,7 @@ fst_remove_one ( struct pci_dev *pdev ) for ( i = 0 ; i < card->nports ; i++ ) { struct net_device *dev = port_to_dev(&card->ports[i]); - unregister_hdlc_device(dev_to_hdlc(dev)); + unregister_hdlc_device(dev); } fst_disable_intr ( card ); diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index 805725b4b0c0..712365899ad5 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -228,10 +228,10 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -int register_hdlc_device(hdlc_device *hdlc) +int register_hdlc_device(struct net_device *dev) { int result; - struct net_device *dev = hdlc_to_dev(hdlc); + hdlc_device *hdlc = dev_to_hdlc(dev); dev->get_stats = hdlc_get_stats; dev->change_mtu = hdlc_change_mtu; @@ -261,11 +261,11 @@ int register_hdlc_device(hdlc_device *hdlc) -void unregister_hdlc_device(hdlc_device *hdlc) +void unregister_hdlc_device(struct net_device *dev) { rtnl_lock(); - hdlc_proto_detach(hdlc); - unregister_netdevice(hdlc_to_dev(hdlc)); + hdlc_proto_detach(dev_to_hdlc(dev)); + unregister_netdevice(dev); rtnl_unlock(); } diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c index c4119012f36d..404443d153c0 100644 --- a/drivers/net/wan/n2.c +++ b/drivers/net/wan/n2.c @@ -311,7 +311,7 @@ static void n2_destroy_card(card_t *card) for (cnt = 0; cnt < 2; cnt++) if (card->ports[cnt].card) { struct net_device *dev = port_to_dev(&card->ports[cnt]); - unregister_hdlc_device(dev_to_hdlc(dev)); + unregister_hdlc_device(dev); } if (card->irq) @@ -459,7 +459,7 @@ static int __init n2_run(unsigned long io, unsigned long irq, hdlc->xmit = sca_xmit; port->settings.clock_type = CLOCK_EXT; - if (register_hdlc_device(hdlc)) { + if (register_hdlc_device(dev)) { printk(KERN_WARNING "n2: unable to register hdlc " "device\n"); n2_destroy_card(card); diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c index 57b323eb6297..b4fbf228cf70 100644 --- a/drivers/net/wan/pc300_drv.c +++ b/drivers/net/wan/pc300_drv.c @@ -3379,7 +3379,7 @@ static void cpc_init_card(pc300_t * card) dev->change_mtu = cpc_change_mtu; dev->do_ioctl = cpc_ioctl; - if (register_hdlc_device(hdlc) == 0) { + if (register_hdlc_device(dev) == 0) { dev->priv = d; /* We need 'priv', hdlc doesn't */ printk("%s: Cyclades-PC300/", dev->name); switch (card->hw.type) { @@ -3639,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(dev_to_hdlc(card->chan[i].d.dev)); + unregister_hdlc_device(card->chan[i].d.dev); } iounmap((void *) card->hw.plxbase); iounmap((void *) card->hw.scabase); diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index 0e94e40dd2f2..1e0a850d480c 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c @@ -534,7 +534,7 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev) for (i = 0; i < 4; i++) if (card->ports[i]) { struct net_device *dev = port_to_dev(card->ports[i]); - unregister_hdlc_device(dev_to_hdlc(dev)); + unregister_hdlc_device(dev); } wanxl_reset(card); @@ -715,7 +715,7 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, dev->stop = wanxl_close; hdlc->attach = wanxl_attach; hdlc->xmit = wanxl_xmit; - if (register_hdlc_device(dev_to_hdlc(dev))) { + if (register_hdlc_device(dev)) { printk(KERN_ERR "wanXL %s: unable to register hdlc" " device\n", card_name(pdev)); wanxl_pci_remove_one(pdev); diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index a9b7c3d153f4..8a2ac90c9b0f 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -185,8 +185,8 @@ int hdlc_x25_ioctl(struct net_device *dev, struct ifreq *ifr); int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); /* Must be used by hardware driver on module startup/exit */ -int register_hdlc_device(hdlc_device *hdlc); -void unregister_hdlc_device(hdlc_device *hdlc); +int register_hdlc_device(struct net_device *dev); +void unregister_hdlc_device(struct net_device *dev); static __inline__ struct net_device* hdlc_to_dev(hdlc_device *hdlc) -- cgit v1.2.3 From 9f361f7a9a981cb0840c4966b372d5acc0ee1b0f Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 09:01:23 -0500 Subject: [wan hdlc] new private struct pointer in hdlc_device, and helpers for it New field in hdlc_device: void *priv; New helpers: struct net_device *alloc_hdlcdev(priv) allocates hdlc, sets ->priv and returns pointer to hdlc->netdev free_hdlcdev(dev) takes such pointer and frees its hdlc. wanxl switched to use of those; instead of embedding hdlc into card->ports[] we allocate it separately right after card had been allocated and store pointer to hdlc->netdev in card->ports[]->dev. Freeing is done just before freeing card. Pointer back to card->ports[] is stored in hdlc->priv. port_to_dev() and dev_to_port() rewritten in the obvious way; by now the rest of driver doesn't care whether hdlc is embedded or not - everything uses port_to_dev() and dev_to_port(). That killed embedded hdlc replacing it with pointer to net_device. Fairly similar work will be done in the next few patches for other drivers. Additionally, setup-after-register and free_irq()-before-unregister races had been fixed. --- drivers/net/wan/hdlc_generic.c | 11 +++++- drivers/net/wan/wanxl.c | 81 +++++++++++++++++++++++++----------------- include/linux/hdlc.h | 7 ++++ 3 files changed, 65 insertions(+), 34 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index 712365899ad5..8301afd1a019 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -226,7 +226,15 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) } } - +struct net_device *alloc_hdlcdev(void *priv) +{ + void *p = kmalloc(sizeof(hdlc_device), GFP_KERNEL); + if (p) { + memset(p, 0, sizeof(hdlc_device)); + dev_to_hdlc(p)->priv = priv; + } + return p; +} int register_hdlc_device(struct net_device *dev) { @@ -279,6 +287,7 @@ EXPORT_SYMBOL(hdlc_open); EXPORT_SYMBOL(hdlc_close); EXPORT_SYMBOL(hdlc_set_carrier); EXPORT_SYMBOL(hdlc_ioctl); +EXPORT_SYMBOL(alloc_hdlcdev); EXPORT_SYMBOL(register_hdlc_device); EXPORT_SYMBOL(unregister_hdlc_device); diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index 1e0a850d480c..f324ad5b7f4b 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c @@ -51,7 +51,7 @@ static const char* version = "wanXL serial card driver version: 0.47"; typedef struct { - hdlc_device hdlc; /* HDLC device struct - must be first */ + struct net_device *dev; struct card_t *card; spinlock_t lock; /* for wanxl_xmit */ int node; /* physical port #0 - 3 */ @@ -78,19 +78,20 @@ typedef struct card_t { struct sk_buff *rx_skbs[RX_QUEUE_LENGTH]; card_status_t *status; /* shared between host and card */ dma_addr_t status_address; + port_t __ports[0]; }card_t; static inline port_t* dev_to_port(struct net_device *dev) { - return (port_t *)(dev_to_hdlc(dev)); + return (port_t *)dev_to_hdlc(dev)->priv; } static inline struct net_device *port_to_dev(port_t* port) { - return hdlc_to_dev(&port->hdlc); + return port->dev; } @@ -527,16 +528,16 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev) card_t *card = pci_get_drvdata(pdev); int i; - /* unregister and free all host resources */ - if (card->irq) - free_irq(card->irq, card); - for (i = 0; i < 4; i++) if (card->ports[i]) { struct net_device *dev = port_to_dev(card->ports[i]); unregister_hdlc_device(dev); } + /* unregister and free all host resources */ + if (card->irq) + free_irq(card->irq, card); + wanxl_reset(card); for (i = 0; i < RX_QUEUE_LENGTH; i++) @@ -554,6 +555,10 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev) pci_free_consistent(pdev, sizeof(card_status_t), card->status, card->status_address); + for (i = 0; i < card->n_ports; i++) + if (card->__ports[i].dev) + free_hdlcdev(card->__ports[i].dev); + pci_set_drvdata(pdev, NULL); kfree(card); pci_release_regions(pdev); @@ -622,6 +627,16 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, card->pdev = pdev; card->n_ports = ports; + for (i = 0; i < ports; i++) { + card->__ports[i].dev = alloc_hdlcdev(&card->__ports[i]); + if (!card->__ports[i].dev) { + printk(KERN_ERR "wanXL %s: unable to allocate memory\n", + card_name(pdev)); + wanxl_pci_remove_one(pdev); + return -ENOMEM; + } + } + card->status = pci_alloc_consistent(pdev, sizeof(card_status_t), &card->status_address); if (card->status == NULL) { @@ -702,32 +717,6 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, return -ENODEV; } - for (i = 0; i < ports; i++) { - port_t *port = (void *)card + sizeof(card_t) + - i * sizeof(port_t); - struct net_device *dev = port_to_dev(port); - hdlc_device *hdlc = dev_to_hdlc(dev); - spin_lock_init(&port->lock); - SET_MODULE_OWNER(dev); - dev->tx_queue_len = 50; - dev->do_ioctl = wanxl_ioctl; - dev->open = wanxl_open; - dev->stop = wanxl_close; - hdlc->attach = wanxl_attach; - hdlc->xmit = wanxl_xmit; - if (register_hdlc_device(dev)) { - printk(KERN_ERR "wanXL %s: unable to register hdlc" - " device\n", card_name(pdev)); - wanxl_pci_remove_one(pdev); - return -ENOBUFS; - } - card->ports[i] = port; - dev->get_stats = wanxl_get_stats; - port->card = card; - port->node = i; - get_status(port)->clocking = CLOCK_EXT; - } - for (i = 0; i < RX_QUEUE_LENGTH; i++) { struct sk_buff *skb = dev_alloc_skb(BUFFER_LENGTH); card->rx_skbs[i] = skb; @@ -796,6 +785,32 @@ static int __devinit wanxl_pci_init_one(struct pci_dev *pdev, } card->irq = pdev->irq; + for (i = 0; i < ports; i++) { + port_t *port = &card->__ports[i]; + struct net_device *dev = port_to_dev(port); + hdlc_device *hdlc = dev_to_hdlc(dev); + spin_lock_init(&port->lock); + SET_MODULE_OWNER(dev); + dev->tx_queue_len = 50; + dev->do_ioctl = wanxl_ioctl; + dev->open = wanxl_open; + dev->stop = wanxl_close; + hdlc->attach = wanxl_attach; + hdlc->xmit = wanxl_xmit; + card->ports[i] = port; + dev->get_stats = wanxl_get_stats; + port->card = card; + port->node = i; + get_status(port)->clocking = CLOCK_EXT; + if (register_hdlc_device(dev)) { + printk(KERN_ERR "wanXL %s: unable to register hdlc" + " device\n", card_name(pdev)); + card->ports[i] = NULL; + wanxl_pci_remove_one(pdev); + return -ENOBUFS; + } + } + return 0; } diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index 8a2ac90c9b0f..ab808ddbd4ac 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -167,6 +167,7 @@ typedef struct hdlc_device_struct { int new_mtu); }ppp; }state; + void *priv; }hdlc_device; @@ -188,6 +189,12 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); int register_hdlc_device(struct net_device *dev); void unregister_hdlc_device(struct net_device *dev); +struct net_device *alloc_hdlcdev(void *priv); + +static inline void free_hdlcdev(struct net_device *dev) +{ + kfree(dev); +} static __inline__ struct net_device* hdlc_to_dev(hdlc_device *hdlc) { -- cgit v1.2.3 From 705ddf6082f77fc71bea763d50d12748b9d3befb Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 09:05:38 -0500 Subject: [wan hdlc] removal hdlc_to_dev() No more users, we may remove it. --- include/linux/hdlc.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include/linux') diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index ab808ddbd4ac..4c0dc1cb99b7 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -196,11 +196,6 @@ static inline void free_hdlcdev(struct net_device *dev) kfree(dev); } -static __inline__ struct net_device* hdlc_to_dev(hdlc_device *hdlc) -{ - return &hdlc->netdev; -} - static __inline__ hdlc_device* dev_to_hdlc(struct net_device *dev) { -- cgit v1.2.3 From ec47df588c61d4271223c302be770b68b2fcbf27 Mon Sep 17 00:00:00 2001 From: Alexander Viro Date: Sat, 10 Jan 2004 09:06:22 -0500 Subject: [wan hdlc] kill embedding of struct net_device Now we can kill the embedding of net_device into hdlc_device. Indeed, all instances of hdlc_device are created by alloc_hdlcdev() and nothing uses hdlc->netdev directly. So we can * remove hdlc->netdev * have alloc_hdlcdev() implemented via alloc_netdev() with the rest of hdlc_device as private part of net_device. * replace free_hdlcdev() with free_netdev(). * have dev_to_hdlc(dev) simply return netdev_priv(dev). --- drivers/net/wan/c101.c | 2 +- drivers/net/wan/dscc4.c | 6 +++--- drivers/net/wan/farsync.c | 8 ++++---- drivers/net/wan/hdlc_generic.c | 31 +++++++++++++++++++++++++------ drivers/net/wan/n2.c | 4 ++-- drivers/net/wan/pc300_drv.c | 4 ++-- drivers/net/wan/wanxl.c | 2 +- include/linux/hdlc.h | 9 +-------- 8 files changed, 39 insertions(+), 27 deletions(-) (limited to 'include/linux') diff --git a/drivers/net/wan/c101.c b/drivers/net/wan/c101.c index c95f12a1e2b9..a5445c1a6a77 100644 --- a/drivers/net/wan/c101.c +++ b/drivers/net/wan/c101.c @@ -287,7 +287,7 @@ static void c101_destroy_card(card_t *card) release_mem_region(card->phy_winbase, C101_MAPPED_RAM_SIZE); } - free_hdlcdev(card->dev); + free_netdev(card->dev); kfree(card); } diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c index 34fa5922ee6c..30361cd2fff8 100644 --- a/drivers/net/wan/dscc4.c +++ b/drivers/net/wan/dscc4.c @@ -699,7 +699,7 @@ static void dscc4_free1(struct pci_dev *pdev) pci_set_drvdata(pdev, NULL); for (i = 0; i < dev_per_card; i++) - free_hdlcdev(root[i].dev); + free_netdev(root[i].dev); kfree(root); kfree(ppriv); } @@ -885,7 +885,7 @@ static int dscc4_found1(struct pci_dev *pdev, unsigned long ioaddr) root[i].dev = alloc_hdlcdev(root + i); if (!root[i].dev) { while (i--) - free_hdlcdev(root[i].dev); + free_netdev(root[i].dev); goto err_free_dev; } } @@ -953,7 +953,7 @@ err_free_priv: kfree(ppriv); err_free_dev2: for (i = 0; i < dev_per_card; i++) - free_hdlcdev(root[i].dev); + free_netdev(root[i].dev); err_free_dev: kfree(root); err_out: diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index aee0fe0dc999..80f42bcf4075 100644 --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c @@ -1465,7 +1465,7 @@ fst_init_card ( struct fst_card_info *card ) printk_err ("Cannot register HDLC device for port %d" " (errno %d)\n", i, -err ); for (j = i; j < card->nports; j++) { - free_hdlcdev(card->ports[j].dev); + free_netdev(card->ports[j].dev); card->ports[j].dev = NULL; } card->nports = i; @@ -1534,7 +1534,7 @@ fst_add_one ( struct pci_dev *pdev, const struct pci_device_id *ent ) hdlc_device *hdlc; if (!dev) { while (i--) - free_hdlcdev(card->ports[i].dev); + free_netdev(card->ports[i].dev); printk_err ("FarSync: out of memory\n"); goto error_free_card; } @@ -1651,7 +1651,7 @@ error_release_io: error_free_ports: for (i = 0; i < card->nports; i++) - free_hdlcdev(card->ports[i].dev); + free_netdev(card->ports[i].dev); error_free_card: kfree ( card ); return err; @@ -1686,7 +1686,7 @@ fst_remove_one ( struct pci_dev *pdev ) release_region ( card->pci_conf, 0x80 ); for (i = 0; i < card->nports; i++) - free_hdlcdev(card->ports[i].dev); + free_netdev(card->ports[i].dev); kfree ( card ); } diff --git a/drivers/net/wan/hdlc_generic.c b/drivers/net/wan/hdlc_generic.c index 8301afd1a019..2aa4ae046f25 100644 --- a/drivers/net/wan/hdlc_generic.c +++ b/drivers/net/wan/hdlc_generic.c @@ -226,14 +226,33 @@ int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) } } +static void hdlc_setup(struct net_device *dev) +{ + hdlc_device *hdlc = dev_to_hdlc(dev); + + dev->get_stats = hdlc_get_stats; + dev->change_mtu = hdlc_change_mtu; + dev->mtu = HDLC_MAX_MTU; + + dev->type = ARPHRD_RAWHDLC; + dev->hard_header_len = 16; + + dev->flags = IFF_POINTOPOINT | IFF_NOARP; + + hdlc->proto.id = -1; + hdlc->proto.detach = NULL; + hdlc->carrier = 1; + hdlc->open = 0; + spin_lock_init(&hdlc->state_lock); +} + struct net_device *alloc_hdlcdev(void *priv) { - void *p = kmalloc(sizeof(hdlc_device), GFP_KERNEL); - if (p) { - memset(p, 0, sizeof(hdlc_device)); - dev_to_hdlc(p)->priv = priv; - } - return p; + struct net_device *dev; + dev = alloc_netdev(sizeof(hdlc_device), "hdlc%d", hdlc_setup); + if (dev) + dev_to_hdlc(dev)->priv = priv; + return dev; } int register_hdlc_device(struct net_device *dev) diff --git a/drivers/net/wan/n2.c b/drivers/net/wan/n2.c index c31c37458e89..179b750cc8a8 100644 --- a/drivers/net/wan/n2.c +++ b/drivers/net/wan/n2.c @@ -325,9 +325,9 @@ static void n2_destroy_card(card_t *card) if (card->io) release_region(card->io, N2_IOPORTS); if (card->ports[0].dev) - free_hdlcdev(card->ports[0].dev); + free_netdev(card->ports[0].dev); if (card->ports[1].dev) - free_hdlcdev(card->ports[1].dev); + free_netdev(card->ports[1].dev); kfree(card); } diff --git a/drivers/net/wan/pc300_drv.c b/drivers/net/wan/pc300_drv.c index 3d4a9ad593e9..27049fdd8b40 100644 --- a/drivers/net/wan/pc300_drv.c +++ b/drivers/net/wan/pc300_drv.c @@ -3406,7 +3406,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); - free_hdlcdev(dev); + free_netdev(dev); continue; } } @@ -3653,7 +3653,7 @@ static void __devexit cpc_remove_one(struct pci_dev *pdev) } for (i = 0; i < card->hw.nchan; i++) if (card->chan[i].d.dev); - free_hdlcdev(card->chan[i].d.dev); + free_netdev(card->chan[i].d.dev); if (card->hw.irq) free_irq(card->hw.irq, card); kfree(card); diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index f324ad5b7f4b..b67121f78a5f 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c @@ -557,7 +557,7 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev) for (i = 0; i < card->n_ports; i++) if (card->__ports[i].dev) - free_hdlcdev(card->__ports[i].dev); + free_netdev(card->__ports[i].dev); pci_set_drvdata(pdev, NULL); kfree(card); diff --git a/include/linux/hdlc.h b/include/linux/hdlc.h index 4c0dc1cb99b7..4b925472ac16 100644 --- a/include/linux/hdlc.h +++ b/include/linux/hdlc.h @@ -96,7 +96,6 @@ typedef struct pvc_device_struct { typedef struct hdlc_device_struct { /* To be initialized by hardware driver */ - struct net_device netdev; /* master net device - must be first */ struct net_device_stats stats; /* used by HDLC layer to take control over HDLC device from hw driver*/ @@ -191,15 +190,9 @@ void unregister_hdlc_device(struct net_device *dev); struct net_device *alloc_hdlcdev(void *priv); -static inline void free_hdlcdev(struct net_device *dev) -{ - kfree(dev); -} - - static __inline__ hdlc_device* dev_to_hdlc(struct net_device *dev) { - return (hdlc_device*)dev; + return netdev_priv(dev); } -- cgit v1.2.3