Commit 8dd4eb5c authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Use a function pointer for type-specific connected() callback

Again, instead of a switch statement, just use a callback.
parent 13667ed1
...@@ -193,7 +193,7 @@ isdn_net_ciscohdlck_slarp_send_request(isdn_net_local *lp) ...@@ -193,7 +193,7 @@ isdn_net_ciscohdlck_slarp_send_request(isdn_net_local *lp)
isdn_net_write_super(lp, skb); isdn_net_write_super(lp, skb);
} }
void static void
isdn_ciscohdlck_connected(isdn_net_local *lp) isdn_ciscohdlck_connected(isdn_net_local *lp)
{ {
lp->cisco_myseq = 0; lp->cisco_myseq = 0;
...@@ -204,6 +204,7 @@ isdn_ciscohdlck_connected(isdn_net_local *lp) ...@@ -204,6 +204,7 @@ isdn_ciscohdlck_connected(isdn_net_local *lp)
lp->cisco_line_state = 0; lp->cisco_line_state = 0;
lp->cisco_debserint = 0; lp->cisco_debserint = 0;
if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) {
/* send slarp request because interface/seq.no.s reset */ /* send slarp request because interface/seq.no.s reset */
isdn_net_ciscohdlck_slarp_send_request(lp); isdn_net_ciscohdlck_slarp_send_request(lp);
...@@ -212,12 +213,16 @@ isdn_ciscohdlck_connected(isdn_net_local *lp) ...@@ -212,12 +213,16 @@ isdn_ciscohdlck_connected(isdn_net_local *lp)
lp->cisco_timer.function = isdn_net_ciscohdlck_slarp_send_keepalive; lp->cisco_timer.function = isdn_net_ciscohdlck_slarp_send_keepalive;
lp->cisco_timer.expires = jiffies + lp->cisco_keepalive_period * HZ; lp->cisco_timer.expires = jiffies + lp->cisco_keepalive_period * HZ;
add_timer(&lp->cisco_timer); add_timer(&lp->cisco_timer);
}
isdn_net_device_wake_queue(lp);
} }
void void
isdn_ciscohdlck_disconnected(isdn_net_local *lp) isdn_ciscohdlck_disconnected(isdn_net_local *lp)
{ {
if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) {
del_timer(&lp->cisco_timer); del_timer(&lp->cisco_timer);
}
} }
static void static void
...@@ -394,6 +399,7 @@ isdn_ciscohdlck_setup(isdn_net_dev *p) ...@@ -394,6 +399,7 @@ isdn_ciscohdlck_setup(isdn_net_dev *p)
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT; p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
p->dev.do_ioctl = isdn_ciscohdlck_dev_ioctl; p->dev.do_ioctl = isdn_ciscohdlck_dev_ioctl;
p->local.receive = isdn_ciscohdlck_receive; p->local.receive = isdn_ciscohdlck_receive;
p->local.connected = isdn_ciscohdlck_connected;
return 0; return 0;
} }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#define ISDN_CISCOHDLCK_H #define ISDN_CISCOHDLCK_H
int isdn_ciscohdlck_setup(isdn_net_dev *p); int isdn_ciscohdlck_setup(isdn_net_dev *p);
void isdn_ciscohdlck_connected(isdn_net_local *lp);
void isdn_ciscohdlck_disconnected(isdn_net_local *lp); void isdn_ciscohdlck_disconnected(isdn_net_local *lp);
#endif #endif
...@@ -147,7 +147,7 @@ void isdn_x25_close(struct net_device *dev) ...@@ -147,7 +147,7 @@ void isdn_x25_close(struct net_device *dev)
if( cprot && cprot -> pops ) cprot -> pops -> close( cprot ); if( cprot && cprot -> pops ) cprot -> pops -> close( cprot );
} }
void isdn_x25_connected(isdn_net_local *lp) static void isdn_x25_connected(isdn_net_local *lp)
{ {
struct concap_proto *cprot = lp -> netdev -> cprot; struct concap_proto *cprot = lp -> netdev -> cprot;
struct concap_proto_ops *pops = cprot ? cprot -> pops : 0; struct concap_proto_ops *pops = cprot ? cprot -> pops : 0;
...@@ -156,6 +156,8 @@ void isdn_x25_connected(isdn_net_local *lp) ...@@ -156,6 +156,8 @@ void isdn_x25_connected(isdn_net_local *lp)
if( pops ) if( pops )
if( pops->connect_ind) if( pops->connect_ind)
pops->connect_ind(cprot); pops->connect_ind(cprot);
isdn_net_device_wake_queue(lp);
} }
void isdn_x25_dhup(isdn_net_local *lp) void isdn_x25_dhup(isdn_net_local *lp)
...@@ -264,6 +266,7 @@ int isdn_x25_setup(isdn_net_dev *p, int encap) ...@@ -264,6 +266,7 @@ int isdn_x25_setup(isdn_net_dev *p, int encap)
p->dev.hard_header_cache = NULL; p->dev.hard_header_cache = NULL;
p->dev.header_cache_update = NULL; p->dev.header_cache_update = NULL;
p->local.receive = isdn_x25_receive; p->local.receive = isdn_x25_receive;
p->local.connected = isdn_x25_connected;
/* the protocol is not configured yet; this will /* the protocol is not configured yet; this will
happen later when isdn_x25_open() is called */ happen later when isdn_x25_open() is called */
......
...@@ -18,7 +18,6 @@ int isdn_x25_setup(isdn_net_dev *p, int encap); ...@@ -18,7 +18,6 @@ int isdn_x25_setup(isdn_net_dev *p, int encap);
void isdn_x25_cleanup(isdn_net_dev *p); void isdn_x25_cleanup(isdn_net_dev *p);
void isdn_x25_open(struct net_device *dev); void isdn_x25_open(struct net_device *dev);
void isdn_x25_close(struct net_device *dev); void isdn_x25_close(struct net_device *dev);
void isdn_x25_connected(isdn_net_local *lp);
void isdn_x25_bhup(isdn_net_local *lp); void isdn_x25_bhup(isdn_net_local *lp);
void isdn_x25_hangup(isdn_net_local *lp); void isdn_x25_hangup(isdn_net_local *lp);
int isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev); int isdn_x25_start_xmit(struct sk_buff *skb, struct net_device *dev);
...@@ -48,11 +47,6 @@ isdn_x25_close(struct net_device *dev) ...@@ -48,11 +47,6 @@ isdn_x25_close(struct net_device *dev)
{ {
} }
static inline void
isdn_x25_connected(isdn_net_local *lp)
{
}
static inline void static inline void
isdn_x25_dhup(isdn_net_local *lp) isdn_x25_dhup(isdn_net_local *lp)
{ {
......
...@@ -104,18 +104,6 @@ static __inline__ int isdn_net_device_started(isdn_net_dev *n) ...@@ -104,18 +104,6 @@ static __inline__ int isdn_net_device_started(isdn_net_dev *n)
return netif_running(dev); return netif_running(dev);
} }
/*
* wake up the network -> net_device queue.
* For slaves, wake the corresponding master interface.
*/
static __inline__ void isdn_net_device_wake_queue(isdn_net_local *lp)
{
if (lp->master)
netif_wake_queue(lp->master);
else
netif_wake_queue(&lp->netdev->dev);
}
/* /*
* stop the network -> net_device queue. * stop the network -> net_device queue.
* For slaves, stop the corresponding master interface. * For slaves, stop the corresponding master interface.
...@@ -385,8 +373,6 @@ static void isdn_net_connected(isdn_net_local *lp) ...@@ -385,8 +373,6 @@ static void isdn_net_connected(isdn_net_local *lp)
lp->hup_timer.expires = jiffies + HZ; lp->hup_timer.expires = jiffies + HZ;
add_timer(&lp->hup_timer); add_timer(&lp->hup_timer);
if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK)
isdn_ciscohdlck_connected(lp);
if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) { if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP) {
if (lp->master) { /* is lp a slave? */ if (lp->master) { /* is lp a slave? */
isdn_net_dev *nd = ((isdn_net_local *)lp->master->priv)->netdev; isdn_net_dev *nd = ((isdn_net_local *)lp->master->priv)->netdev;
...@@ -407,13 +393,7 @@ static void isdn_net_connected(isdn_net_local *lp) ...@@ -407,13 +393,7 @@ static void isdn_net_connected(isdn_net_local *lp)
lp->cps = 0; lp->cps = 0;
lp->last_jiffies = jiffies; lp->last_jiffies = jiffies;
if (lp->p_encap == ISDN_NET_ENCAP_SYNCPPP) lp->connected(lp);
isdn_ppp_wakeup_daemon(lp);
isdn_x25_connected(lp);
/* ppp needs to do negotiations first */
if (lp->p_encap != ISDN_NET_ENCAP_SYNCPPP)
isdn_net_device_wake_queue(lp);
} }
/* /*
...@@ -2484,6 +2464,7 @@ isdn_iptyp_setup(isdn_net_dev *p) ...@@ -2484,6 +2464,7 @@ isdn_iptyp_setup(isdn_net_dev *p)
p->dev.header_cache_update = NULL; p->dev.header_cache_update = NULL;
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT; p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
p->local.receive = isdn_iptyp_receive; p->local.receive = isdn_iptyp_receive;
p->local.connected = isdn_net_device_wake_queue;
return 0; return 0;
} }
...@@ -2521,6 +2502,7 @@ isdn_uihdlc_setup(isdn_net_dev *p) ...@@ -2521,6 +2502,7 @@ isdn_uihdlc_setup(isdn_net_dev *p)
p->dev.header_cache_update = NULL; p->dev.header_cache_update = NULL;
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT; p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
p->local.receive = isdn_uihdlc_receive; p->local.receive = isdn_uihdlc_receive;
p->local.connected = isdn_net_device_wake_queue;
return 0; return 0;
} }
...@@ -2548,6 +2530,7 @@ isdn_rawip_setup(isdn_net_dev *p) ...@@ -2548,6 +2530,7 @@ isdn_rawip_setup(isdn_net_dev *p)
p->dev.header_cache_update = NULL; p->dev.header_cache_update = NULL;
p->dev.flags = IFF_NOARP|IFF_POINTOPOINT; p->dev.flags = IFF_NOARP|IFF_POINTOPOINT;
p->local.receive = isdn_rawip_receive; p->local.receive = isdn_rawip_receive;
p->local.connected = isdn_net_device_wake_queue;
return 0; return 0;
} }
...@@ -2629,6 +2612,7 @@ isdn_ether_setup(isdn_net_dev *p) ...@@ -2629,6 +2612,7 @@ isdn_ether_setup(isdn_net_dev *p)
p->dev.header_cache_update = eth_header_cache_update; p->dev.header_cache_update = eth_header_cache_update;
p->dev.flags = IFF_BROADCAST | IFF_MULTICAST; p->dev.flags = IFF_BROADCAST | IFF_MULTICAST;
p->local.receive = isdn_ether_receive; p->local.receive = isdn_ether_receive;
p->local.connected = isdn_net_device_wake_queue;
return 0; return 0;
} }
...@@ -145,6 +145,18 @@ static __inline__ void isdn_net_rm_from_bundle(isdn_net_local *lp) ...@@ -145,6 +145,18 @@ static __inline__ void isdn_net_rm_from_bundle(isdn_net_local *lp)
spin_unlock_irqrestore(&master_lp->netdev->queue_lock, flags); spin_unlock_irqrestore(&master_lp->netdev->queue_lock, flags);
} }
/*
* wake up the network -> net_device queue.
* For slaves, wake the corresponding master interface.
*/
static inline void isdn_net_device_wake_queue(isdn_net_local *lp)
{
if (lp->master)
netif_wake_queue(lp->master);
else
netif_wake_queue(&lp->netdev->dev);
}
static inline int static inline int
put_u8(unsigned char *p, u8 x) put_u8(unsigned char *p, u8 x)
{ {
......
...@@ -224,7 +224,7 @@ isdn_ppp_bind(isdn_net_local * lp) ...@@ -224,7 +224,7 @@ isdn_ppp_bind(isdn_net_local * lp)
* (wakes up daemon after B-channel connect) * (wakes up daemon after B-channel connect)
*/ */
void static void
isdn_ppp_wakeup_daemon(isdn_net_local * lp) isdn_ppp_wakeup_daemon(isdn_net_local * lp)
{ {
if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) { if (lp->ppp_slot < 0 || lp->ppp_slot >= ISDN_MAX_CHANNELS) {
...@@ -2926,6 +2926,7 @@ isdn_ppp_setup(isdn_net_dev *p) ...@@ -2926,6 +2926,7 @@ isdn_ppp_setup(isdn_net_dev *p)
p->dev.addr_len = 0; p->dev.addr_len = 0;
p->dev.do_ioctl = isdn_ppp_dev_ioctl; p->dev.do_ioctl = isdn_ppp_dev_ioctl;
p->local.receive = isdn_ppp_receive; p->local.receive = isdn_ppp_receive;
p->local.connected = isdn_ppp_wakeup_daemon;
return 0; return 0;
} }
...@@ -22,7 +22,6 @@ extern int isdn_ppp_hangup_slave(char *); ...@@ -22,7 +22,6 @@ extern int isdn_ppp_hangup_slave(char *);
#ifdef CONFIG_ISDN_PPP #ifdef CONFIG_ISDN_PPP
int isdn_ppp_setup(isdn_net_dev *p); int isdn_ppp_setup(isdn_net_dev *p);
void isdn_ppp_wakeup_daemon(isdn_net_local *);
int isdn_ppp_bind(isdn_net_local *); int isdn_ppp_bind(isdn_net_local *);
void isdn_ppp_free(isdn_net_local *); void isdn_ppp_free(isdn_net_local *);
int isdn_ppp_xmit(struct sk_buff *, struct net_device *); int isdn_ppp_xmit(struct sk_buff *, struct net_device *);
...@@ -36,11 +35,6 @@ isdn_ppp_setup(isdn_net_dev *p) ...@@ -36,11 +35,6 @@ isdn_ppp_setup(isdn_net_dev *p)
return -EINVAL; return -EINVAL;
} }
static inline void
isdn_ppp_wakeup_daemon(isdn_net_local *lp);
{
}
static inline int static inline int
isdn_ppp_bind(isdn_net_local *) isdn_ppp_bind(isdn_net_local *)
{ {
......
...@@ -374,6 +374,7 @@ typedef struct isdn_net_local_s { ...@@ -374,6 +374,7 @@ typedef struct isdn_net_local_s {
void (*receive)(struct isdn_net_dev_s *p, void (*receive)(struct isdn_net_dev_s *p,
struct isdn_net_local_s *olp, struct isdn_net_local_s *olp,
struct sk_buff *skb); struct sk_buff *skb);
void (*connected)(struct isdn_net_local_s *lp);
} isdn_net_local; } isdn_net_local;
/* the interface itself */ /* the interface itself */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment