Commit cd5869cb authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Move more slot-specific data into the per-slot struct

parent 33c7e1fa
...@@ -44,11 +44,20 @@ MODULE_LICENSE("GPL"); ...@@ -44,11 +44,20 @@ MODULE_LICENSE("GPL");
isdn_dev *dev; isdn_dev *dev;
static struct { struct isdn_slot {
int di; /* driver index */ int di; /* driver index */
int ch; /* channel index (per driver */ int ch; /* channel index (per driver) */
int usage; /* how is it used */ int usage; /* how is it used */
} slot[ISDN_MAX_CHANNELS]; char num[ISDN_MSNLEN]; /* the current phone number */
unsigned long ibytes; /* Statistics incoming bytes */
unsigned long obytes; /* Statistics outgoing bytes */
struct isdn_v110 iv110; /* For V.110 */
int m_idx; /* Index for mdm.... */
isdn_net_dev *rx_netdev; /* rx netdev-pointers */
isdn_net_dev *st_netdev; /* stat netdev-pointers */
};
static struct isdn_slot slot[ISDN_MAX_CHANNELS];
static char *isdn_revision = "$Revision: 1.114.6.16 $"; static char *isdn_revision = "$Revision: 1.114.6.16 $";
...@@ -324,7 +333,7 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb) ...@@ -324,7 +333,7 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb)
return; return;
} }
/* Update statistics */ /* Update statistics */
dev->ibytes[i] += skb->len; slot[i].ibytes += skb->len;
/* First, try to deliver data to network-device */ /* First, try to deliver data to network-device */
if (isdn_net_rcv_skb(i, skb)) if (isdn_net_rcv_skb(i, skb))
...@@ -334,10 +343,10 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb) ...@@ -334,10 +343,10 @@ isdn_receive_skb_callback(int di, int channel, struct sk_buff *skb)
* makes sense for async streams only, so it is * makes sense for async streams only, so it is
* called after possible net-device delivery. * called after possible net-device delivery.
*/ */
if (dev->v110[i]) { if (slot[i].iv110.v110) {
atomic_inc(&dev->v110use[i]); atomic_inc(&slot[i].iv110.v110use);
skb = isdn_v110_decode(dev->v110[i], skb); skb = isdn_v110_decode(slot[i].iv110.v110, skb);
atomic_dec(&dev->v110use[i]); atomic_dec(&slot[i].iv110.v110use);
if (!skb) if (!skb)
return; return;
} }
...@@ -381,11 +390,11 @@ isdn_command(isdn_ctrl *cmd) ...@@ -381,11 +390,11 @@ isdn_command(isdn_ctrl *cmd)
* Layer-2 to transparent * Layer-2 to transparent
*/ */
if (!(features & l2_feature)) { if (!(features & l2_feature)) {
dev->v110emu[idx] = l2prot; slot[idx].iv110.v110emu = l2prot;
cmd->arg = (cmd->arg & 255) | cmd->arg = (cmd->arg & 255) |
(ISDN_PROTO_L2_TRANS << 8); (ISDN_PROTO_L2_TRANS << 8);
} else } else
dev->v110emu[idx] = 0; slot[idx].iv110.v110emu = 0;
} }
} }
return dev->drv[cmd->driver]->interface->command(cmd); return dev->drv[cmd->driver]->interface->command(cmd);
...@@ -435,7 +444,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -435,7 +444,7 @@ isdn_status_callback(isdn_ctrl * c)
return 0; return 0;
if (isdn_net_stat_callback(i, c)) if (isdn_net_stat_callback(i, c))
return 0; return 0;
if (isdn_v110_stat_callback(i, c)) if (isdn_v110_stat_callback(&slot[i].iv110, c))
return 0; return 0;
if (isdn_tty_stat_callback(i, c)) if (isdn_tty_stat_callback(i, c))
return 0; return 0;
...@@ -578,7 +587,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -578,7 +587,7 @@ isdn_status_callback(isdn_ctrl * c)
/* Find any net-device, waiting for D-channel setup */ /* Find any net-device, waiting for D-channel setup */
if (isdn_net_stat_callback(i, c)) if (isdn_net_stat_callback(i, c))
break; break;
isdn_v110_stat_callback(i, c); isdn_v110_stat_callback(&slot[i].iv110, c);
/* Find any ttyI, waiting for D-channel setup */ /* Find any ttyI, waiting for D-channel setup */
if (isdn_tty_stat_callback(i, c)) { if (isdn_tty_stat_callback(i, c)) {
cmd.driver = di; cmd.driver = di;
...@@ -601,7 +610,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -601,7 +610,7 @@ isdn_status_callback(isdn_ctrl * c)
/* Signal hangup to network-devices */ /* Signal hangup to network-devices */
if (isdn_net_stat_callback(i, c)) if (isdn_net_stat_callback(i, c))
break; break;
isdn_v110_stat_callback(i, c); isdn_v110_stat_callback(&slot[i].iv110, c);
if (isdn_tty_stat_callback(i, c)) if (isdn_tty_stat_callback(i, c))
break; break;
#ifdef CONFIG_ISDN_DIVERSION #ifdef CONFIG_ISDN_DIVERSION
...@@ -623,7 +632,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -623,7 +632,7 @@ isdn_status_callback(isdn_ctrl * c)
isdn_info_update(); isdn_info_update();
if (isdn_net_stat_callback(i, c)) if (isdn_net_stat_callback(i, c))
break; break;
isdn_v110_stat_callback(i, c); isdn_v110_stat_callback(&slot[i].iv110, c);
if (isdn_tty_stat_callback(i, c)) if (isdn_tty_stat_callback(i, c))
break; break;
break; break;
...@@ -642,7 +651,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -642,7 +651,7 @@ isdn_status_callback(isdn_ctrl * c)
if (isdn_net_stat_callback(i, c)) if (isdn_net_stat_callback(i, c))
break; break;
#endif #endif
isdn_v110_stat_callback(i, c); isdn_v110_stat_callback(&slot[i].iv110, c);
if (isdn_tty_stat_callback(i, c)) if (isdn_tty_stat_callback(i, c))
break; break;
break; break;
...@@ -914,7 +923,7 @@ isdn_statstr(void) ...@@ -914,7 +923,7 @@ isdn_statstr(void)
sprintf(p, "\nphone:\t"); sprintf(p, "\nphone:\t");
p = istatbuf + strlen(istatbuf); p = istatbuf + strlen(istatbuf);
for (i = 0; i < ISDN_MAX_CHANNELS; i++) { for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
sprintf(p, "%s ", dev->num[i]); sprintf(p, "%s ", isdn_slot_num(i));
p = istatbuf + strlen(istatbuf); p = istatbuf + strlen(istatbuf);
} }
sprintf(p, "\n"); sprintf(p, "\n");
...@@ -1071,8 +1080,8 @@ isdn_status_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg) ...@@ -1071,8 +1080,8 @@ isdn_status_ioctl(struct inode *inode, struct file *file, uint cmd, ulong arg)
sizeof(ulong) * ISDN_MAX_CHANNELS * 2))) sizeof(ulong) * ISDN_MAX_CHANNELS * 2)))
return ret; return ret;
for (i = 0; i < ISDN_MAX_CHANNELS; i++) { for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
put_user(dev->ibytes[i], p++); put_user(slot[i].ibytes, p++);
put_user(dev->obytes[i], p++); put_user(slot[i].obytes, p++);
} }
return 0; return 0;
} else } else
...@@ -1719,7 +1728,7 @@ isdn_map_eaz2msn(char *msn, int di) ...@@ -1719,7 +1728,7 @@ isdn_map_eaz2msn(char *msn, int di)
int int
isdn_get_free_slot(int usage, int l2_proto, int l3_proto, isdn_get_free_slot(int usage, int l2_proto, int l3_proto,
int pre_dev,int pre_chan, char *msn) int pre_dev, int pre_chan, char *msn)
{ {
int i; int i;
ulong flags; ulong flags;
...@@ -1786,14 +1795,14 @@ isdn_slot_free(int sl, int usage) ...@@ -1786,14 +1795,14 @@ isdn_slot_free(int sl, int usage)
save_flags(flags); save_flags(flags);
cli(); cli();
if (!usage || (slot[sl].usage & ISDN_USAGE_MASK) == usage) { if (!usage || (slot[sl].usage & ISDN_USAGE_MASK) == usage) {
strcpy(dev->num[sl], "???"); strcpy(isdn_slot_num(sl), "???");
dev->ibytes[sl] = 0; slot[sl].ibytes = 0;
dev->obytes[sl] = 0; slot[sl].obytes = 0;
// 20.10.99 JIM, try to reinitialize v110 ! // 20.10.99 JIM, try to reinitialize v110 !
dev->v110emu[sl] = 0; slot[sl].iv110.v110emu = 0;
atomic_set(&(dev->v110use[sl]), 0); atomic_set(&slot[sl].iv110.v110use, 0);
isdn_v110_close(dev->v110[sl]); isdn_v110_close(slot[sl].iv110.v110);
dev->v110[sl] = NULL; slot[sl].iv110.v110 = NULL;
// 20.10.99 JIM, try to reinitialize v110 ! // 20.10.99 JIM, try to reinitialize v110 !
isdn_slot_set_usage(sl, isdn_slot_usage(sl) & (ISDN_USAGE_NONE | ISDN_USAGE_EXCLUSIVE)); isdn_slot_set_usage(sl, isdn_slot_usage(sl) & (ISDN_USAGE_NONE | ISDN_USAGE_EXCLUSIVE));
skb_queue_purge(&dev->drv[isdn_slot_driver(sl)]->rpqueue[isdn_slot_channel(sl)]); skb_queue_purge(&dev->drv[isdn_slot_driver(sl)]->rpqueue[isdn_slot_channel(sl)]);
...@@ -1836,10 +1845,10 @@ isdn_slot_write(int sl, struct sk_buff *skb) ...@@ -1836,10 +1845,10 @@ isdn_slot_write(int sl, struct sk_buff *skb)
BUG_ON(sl < 0); BUG_ON(sl < 0);
if (dev->v110[sl]) { if (slot[sl].iv110.v110) {
atomic_inc(&dev->v110use[sl]); atomic_inc(&slot[sl].iv110.v110use);
nskb = isdn_v110_encode(dev->v110[sl], skb); nskb = isdn_v110_encode(slot[sl].iv110.v110, skb);
atomic_dec(&dev->v110use[sl]); atomic_dec(&slot[sl].iv110.v110use);
if (!nskb) if (!nskb)
return 0; return 0;
v110_ret = *((int *)nskb->data); v110_ret = *((int *)nskb->data);
...@@ -1878,11 +1887,11 @@ isdn_slot_write(int sl, struct sk_buff *skb) ...@@ -1878,11 +1887,11 @@ isdn_slot_write(int sl, struct sk_buff *skb)
} }
} }
if (ret > 0) { if (ret > 0) {
dev->obytes[di] += ret; slot[sl].obytes += ret;
if (dev->v110[sl]) { if (slot[sl].iv110.v110) {
atomic_inc(&dev->v110use[sl]); atomic_inc(&slot[sl].iv110.v110use);
dev->v110[sl]->skbuser++; slot[sl].iv110.v110->skbuser++;
atomic_dec(&dev->v110use[sl]); atomic_dec(&slot[sl].iv110.v110use);
/* For V.110 return unencoded data length */ /* For V.110 return unencoded data length */
ret = v110_ret; ret = v110_ret;
/* if the complete frame was send we free the skb; /* if the complete frame was send we free the skb;
...@@ -1891,7 +1900,7 @@ isdn_slot_write(int sl, struct sk_buff *skb) ...@@ -1891,7 +1900,7 @@ isdn_slot_write(int sl, struct sk_buff *skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
} }
} else } else
if (dev->v110[sl]) if (slot[sl].iv110.v110)
dev_kfree_skb(nskb); dev_kfree_skb(nskb);
return ret; return ret;
} }
...@@ -2183,6 +2192,38 @@ isdn_slot_set_usage(int sl, int usage) ...@@ -2183,6 +2192,38 @@ isdn_slot_set_usage(int sl, int usage)
isdn_info_update(); isdn_info_update();
} }
void
isdn_slot_set_rx_netdev(int sl, isdn_net_dev *nd)
{
BUG_ON(sl < 0);
slot[sl].rx_netdev = nd;
}
isdn_net_dev *
isdn_slot_rx_netdev(int sl)
{
BUG_ON(sl < 0);
return slot[sl].rx_netdev;
}
void
isdn_slot_set_st_netdev(int sl, isdn_net_dev *nd)
{
BUG_ON(sl < 0);
slot[sl].rx_netdev = nd;
}
isdn_net_dev *
isdn_slot_st_netdev(int sl)
{
BUG_ON(sl < 0);
return slot[sl].st_netdev;
}
/* /*
***************************************************************************** *****************************************************************************
* And now the modules code. * And now the modules code.
...@@ -2306,8 +2347,8 @@ static int __init isdn_init(void) ...@@ -2306,8 +2347,8 @@ static int __init isdn_init(void)
for (i = 0; i < ISDN_MAX_CHANNELS; i++) { for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
slot[i].di = -1; slot[i].di = -1;
slot[i].ch = -1; slot[i].ch = -1;
dev->m_idx[i] = -1; slot[i].m_idx = -1;
strcpy(dev->num[i], "???"); strcpy(isdn_slot_num(i), "???");
init_waitqueue_head(&dev->mdm.info[i].open_wait); init_waitqueue_head(&dev->mdm.info[i].open_wait);
init_waitqueue_head(&dev->mdm.info[i].close_wait); init_waitqueue_head(&dev->mdm.info[i].close_wait);
} }
......
...@@ -54,3 +54,11 @@ extern int isdn_slot_driver(int slot); ...@@ -54,3 +54,11 @@ extern int isdn_slot_driver(int slot);
extern int isdn_slot_channel(int slot); extern int isdn_slot_channel(int slot);
extern int isdn_slot_usage(int slot); extern int isdn_slot_usage(int slot);
extern void isdn_slot_set_usage(int slot, int usage); extern void isdn_slot_set_usage(int slot, int usage);
extern char *isdn_slot_num(int slot);
extern int isdn_slot_m_idx(int slot);
extern int isdn_slot_set_m_idx(int slot, int midx);
extern void isdn_slot_set_rx_netdev(int sl, isdn_net_dev *nd);
extern void isdn_slot_set_st_netdev(int sl, isdn_net_dev *nd);
extern isdn_net_dev *isdn_slot_rx_netdev(int sl);
extern isdn_net_dev *isdn_slot_st_netdev(int sl);
...@@ -281,8 +281,8 @@ isdn_net_bind_channel(isdn_net_local * lp, int idx) ...@@ -281,8 +281,8 @@ isdn_net_bind_channel(isdn_net_local * lp, int idx)
cli(); cli();
lp->flags |= ISDN_NET_CONNECTED; lp->flags |= ISDN_NET_CONNECTED;
lp->isdn_slot = idx; lp->isdn_slot = idx;
dev->rx_netdev[idx] = lp->netdev; isdn_slot_set_rx_netdev(lp->isdn_slot, lp->netdev);
dev->st_netdev[idx] = lp->netdev; isdn_slot_set_st_netdev(lp->isdn_slot, lp->netdev);
restore_flags(flags); restore_flags(flags);
} }
...@@ -306,8 +306,8 @@ isdn_net_unbind_channel(isdn_net_local * lp) ...@@ -306,8 +306,8 @@ isdn_net_unbind_channel(isdn_net_local * lp)
qdisc_reset(lp->netdev->dev.qdisc); qdisc_reset(lp->netdev->dev.qdisc);
} }
lp->dialstate = 0; lp->dialstate = 0;
dev->rx_netdev[lp->isdn_slot] = NULL; isdn_slot_set_rx_netdev(lp->isdn_slot, NULL);
dev->st_netdev[lp->isdn_slot] = NULL; isdn_slot_set_st_netdev(lp->isdn_slot, NULL);
isdn_slot_free(lp->isdn_slot, ISDN_USAGE_NET); isdn_slot_free(lp->isdn_slot, ISDN_USAGE_NET);
lp->flags &= ~ISDN_NET_CONNECTED; lp->flags &= ~ISDN_NET_CONNECTED;
lp->isdn_slot = -1; lp->isdn_slot = -1;
...@@ -405,7 +405,7 @@ static void isdn_net_lp_disconnected(isdn_net_local *lp) ...@@ -405,7 +405,7 @@ static void isdn_net_lp_disconnected(isdn_net_local *lp)
int int
isdn_net_stat_callback(int idx, isdn_ctrl *c) isdn_net_stat_callback(int idx, isdn_ctrl *c)
{ {
isdn_net_dev *p = dev->st_netdev[idx]; isdn_net_dev *p = isdn_slot_st_netdev(idx);
int cmd = c->command; int cmd = c->command;
if (p) { if (p) {
...@@ -491,7 +491,7 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c) ...@@ -491,7 +491,7 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c)
if (lp->dialstate <= 6) if (lp->dialstate <= 6)
isdn_slot_set_usage(idx, isdn_slot_usage(idx) | ISDN_USAGE_OUTGOING); isdn_slot_set_usage(idx, isdn_slot_usage(idx) | ISDN_USAGE_OUTGOING);
else else
dev->rx_netdev[idx] = p; isdn_slot_set_rx_netdev(idx, p);
lp->dialstate = 0; lp->dialstate = 0;
isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1); isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1);
if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK) if (lp->p_encap == ISDN_NET_ENCAP_CISCOHDLCK)
...@@ -696,7 +696,7 @@ isdn_net_dial(void) ...@@ -696,7 +696,7 @@ isdn_net_dial(void)
sprintf(cmd.parm.setup.eazmsn, "%s", sprintf(cmd.parm.setup.eazmsn, "%s",
isdn_slot_map_eaz2msn(lp->isdn_slot, lp->msn)); isdn_slot_map_eaz2msn(lp->isdn_slot, lp->msn));
if (lp->isdn_slot >= 0) { if (lp->isdn_slot >= 0) {
strcpy(dev->num[lp->isdn_slot], cmd.parm.setup.phone); strcpy(isdn_slot_num(lp->isdn_slot), cmd.parm.setup.phone);
isdn_slot_set_usage(lp->isdn_slot, isdn_slot_usage(lp->isdn_slot) | ISDN_USAGE_OUTGOING); isdn_slot_set_usage(lp->isdn_slot, isdn_slot_usage(lp->isdn_slot) | ISDN_USAGE_OUTGOING);
} }
printk(KERN_INFO "%s: dialing %d %s... %s\n", lp->name, printk(KERN_INFO "%s: dialing %d %s... %s\n", lp->name,
...@@ -1859,7 +1859,7 @@ isdn_net_receive(struct net_device *ndev, struct sk_buff *skb) ...@@ -1859,7 +1859,7 @@ isdn_net_receive(struct net_device *ndev, struct sk_buff *skb)
int int
isdn_net_rcv_skb(int idx, struct sk_buff *skb) isdn_net_rcv_skb(int idx, struct sk_buff *skb)
{ {
isdn_net_dev *p = dev->rx_netdev[idx]; isdn_net_dev *p = isdn_slot_rx_netdev(idx);
if (p) { if (p) {
isdn_net_local *lp = p->local; isdn_net_local *lp = p->local;
...@@ -2403,9 +2403,9 @@ p = dev->netdev; ...@@ -2403,9 +2403,9 @@ p = dev->netdev;
isdn_slot_free(lp->isdn_slot, isdn_slot_free(lp->isdn_slot,
ISDN_USAGE_NET); ISDN_USAGE_NET);
} }
strcpy(dev->num[idx], nr); strcpy(isdn_slot_num(idx), nr);
isdn_slot_set_usage(idx, (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) | ISDN_USAGE_NET); isdn_slot_set_usage(idx, (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) | ISDN_USAGE_NET);
dev->st_netdev[idx] = lp->netdev; isdn_slot_set_st_netdev(idx, lp->netdev);
lp->isdn_slot = slot; lp->isdn_slot = slot;
lp->ppp_slot = -1; lp->ppp_slot = -1;
lp->flags |= ISDN_NET_CONNECTED; lp->flags |= ISDN_NET_CONNECTED;
...@@ -3022,8 +3022,8 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer) ...@@ -3022,8 +3022,8 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer)
idx = p->local->isdn_slot; idx = p->local->isdn_slot;
if (idx<0) return -ENOTCONN; if (idx<0) return -ENOTCONN;
/* for pre-bound channels, we need this extra check */ /* for pre-bound channels, we need this extra check */
if ( strncmp(dev->num[idx],"???",3) == 0 ) return -ENOTCONN; if (strncmp(isdn_slot_num(idx),"???",3) == 0 ) return -ENOTCONN;
strncpy(phone->phone,dev->num[idx],ISDN_MSNLEN); strncpy(phone->phone,isdn_slot_num(idx),ISDN_MSNLEN);
phone->outgoing=USG_OUTGOING(isdn_slot_usage(idx)); phone->outgoing=USG_OUTGOING(isdn_slot_usage(idx));
if ( copy_to_user(peer,phone,sizeof(*peer)) ) return -EFAULT; if ( copy_to_user(peer,phone,sizeof(*peer)) ) return -EFAULT;
return 0; return 0;
......
...@@ -128,7 +128,7 @@ isdn_tty_readmodem(void) ...@@ -128,7 +128,7 @@ isdn_tty_readmodem(void)
modem_info *info; modem_info *info;
for (i = 0; i < ISDN_MAX_CHANNELS; i++) { for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
if ((midx = dev->m_idx[i]) >= 0) { if ((midx = isdn_slot_m_idx(i)) >= 0) {
info = &dev->mdm.info[midx]; info = &dev->mdm.info[midx];
if (info->online) { if (info->online) {
r = 0; r = 0;
...@@ -182,7 +182,7 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb) ...@@ -182,7 +182,7 @@ isdn_tty_rcv_skb(int i, int di, int channel, struct sk_buff *skb)
#endif #endif
modem_info *info; modem_info *info;
if ((midx = dev->m_idx[i]) < 0) { if ((midx = isdn_slot_m_idx(i)) < 0) {
/* if midx is invalid, packet is not for tty */ /* if midx is invalid, packet is not for tty */
return 0; return 0;
} }
...@@ -657,7 +657,7 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) ...@@ -657,7 +657,7 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m)
isdn_tty_modem_result(RESULT_NO_DIALTONE, info); isdn_tty_modem_result(RESULT_NO_DIALTONE, info);
} else { } else {
info->isdn_slot = i; info->isdn_slot = i;
dev->m_idx[i] = info->line; isdn_slot_set_m_idx(i, info->line);
info->last_dir = 1; info->last_dir = 1;
strcpy(info->last_num, n); strcpy(info->last_num, n);
isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING); isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING);
...@@ -683,7 +683,7 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) ...@@ -683,7 +683,7 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m)
cmd.parm.setup.si2 = m->mdmreg[REG_SI2]; cmd.parm.setup.si2 = m->mdmreg[REG_SI2];
info->dialing = 1; info->dialing = 1;
info->emu.carrierwait = 0; info->emu.carrierwait = 0;
strcpy(dev->num[i], n); strcpy(isdn_slot_num(i), n);
isdn_info_update(); isdn_info_update();
isdn_slot_command(info->isdn_slot, ISDN_CMD_DIAL, &cmd); isdn_slot_command(info->isdn_slot, ISDN_CMD_DIAL, &cmd);
isdn_timer_ctrl(ISDN_TIMER_CARRIER, 1); isdn_timer_ctrl(ISDN_TIMER_CARRIER, 1);
...@@ -754,7 +754,7 @@ isdn_tty_modem_hup(modem_info * info, int local) ...@@ -754,7 +754,7 @@ isdn_tty_modem_hup(modem_info * info, int local)
isdn_slot_all_eaz(slot); isdn_slot_all_eaz(slot);
info->emu.mdmreg[REG_RINGCNT] = 0; info->emu.mdmreg[REG_RINGCNT] = 0;
isdn_slot_free(slot, 0); isdn_slot_free(slot, 0);
dev->m_idx[slot] = -1; isdn_slot_set_m_idx(slot, -1);
info->isdn_slot = -1; info->isdn_slot = -1;
} }
...@@ -847,7 +847,7 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) ...@@ -847,7 +847,7 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m)
isdn_tty_modem_result(RESULT_NO_DIALTONE, info); isdn_tty_modem_result(RESULT_NO_DIALTONE, info);
} else { } else {
info->isdn_slot = i; info->isdn_slot = i;
dev->m_idx[i] = info->line; isdn_slot_set_m_idx(i, info->line);
isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING); isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING);
info->last_dir = 1; info->last_dir = 1;
// strcpy(info->last_num, n); // strcpy(info->last_num, n);
...@@ -926,7 +926,7 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) ...@@ -926,7 +926,7 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg)
isdn_tty_modem_result(RESULT_NO_DIALTONE, info); isdn_tty_modem_result(RESULT_NO_DIALTONE, info);
} else { } else {
info->isdn_slot = i; info->isdn_slot = i;
dev->m_idx[i] = info->line; isdn_slot_set_m_idx(i, info->line);
isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING); isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING);
info->last_dir = 1; info->last_dir = 1;
restore_flags(flags); restore_flags(flags);
...@@ -2210,8 +2210,8 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) ...@@ -2210,8 +2210,8 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
wret = matchret; wret = matchret;
if (!matchret) { /* EAZ is matching */ if (!matchret) { /* EAZ is matching */
info->isdn_slot = idx; info->isdn_slot = idx;
dev->m_idx[idx] = info->line; isdn_slot_set_m_idx(idx, info->line);
strcpy(dev->num[idx], nr); strcpy(isdn_slot_num(idx), nr);
strcpy(info->emu.cpn, eaz); strcpy(info->emu.cpn, eaz);
info->emu.mdmreg[REG_SI1I] = si2bit[si1]; info->emu.mdmreg[REG_SI1I] = si2bit[si1];
info->emu.mdmreg[REG_PLAN] = setup->plan; info->emu.mdmreg[REG_PLAN] = setup->plan;
...@@ -2246,7 +2246,7 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) ...@@ -2246,7 +2246,7 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c)
if (i < 0) if (i < 0)
return 0; return 0;
if ((mi = dev->m_idx[i]) >= 0) { if ((mi = isdn_slot_m_idx(i)) >= 0) {
info = &dev->mdm.info[mi]; info = &dev->mdm.info[mi];
switch (c->command) { switch (c->command) {
case ISDN_STAT_CINF: case ISDN_STAT_CINF:
...@@ -2682,7 +2682,7 @@ isdn_tty_modem_result(int code, modem_info * info) ...@@ -2682,7 +2682,7 @@ isdn_tty_modem_result(int code, modem_info * info)
/* print CID, _before_ _every_ ring */ /* print CID, _before_ _every_ ring */
if (!(m->mdmreg[REG_CIDONCE] & BIT_CIDONCE)) { if (!(m->mdmreg[REG_CIDONCE] & BIT_CIDONCE)) {
isdn_tty_at_cout("\r\nCALLER NUMBER: ", info); isdn_tty_at_cout("\r\nCALLER NUMBER: ", info);
isdn_tty_at_cout(dev->num[info->isdn_slot], info); isdn_tty_at_cout(isdn_slot_num(info->isdn_slot), info);
if (m->mdmreg[REG_CDN] & BIT_CDN) { if (m->mdmreg[REG_CDN] & BIT_CDN) {
isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); isdn_tty_at_cout("\r\nCALLED NUMBER: ", info);
isdn_tty_at_cout(info->emu.cpn, info); isdn_tty_at_cout(info->emu.cpn, info);
...@@ -2711,7 +2711,7 @@ isdn_tty_modem_result(int code, modem_info * info) ...@@ -2711,7 +2711,7 @@ isdn_tty_modem_result(int code, modem_info * info)
(m->mdmreg[REG_RINGCNT] == 1)) { (m->mdmreg[REG_RINGCNT] == 1)) {
isdn_tty_at_cout("\r\n", info); isdn_tty_at_cout("\r\n", info);
isdn_tty_at_cout("CALLER NUMBER: ", info); isdn_tty_at_cout("CALLER NUMBER: ", info);
isdn_tty_at_cout(dev->num[info->isdn_slot], info); isdn_tty_at_cout(isdn_slot_num(info->isdn_slot), info);
if (m->mdmreg[REG_CDN] & BIT_CDN) { if (m->mdmreg[REG_CDN] & BIT_CDN) {
isdn_tty_at_cout("\r\nCALLED NUMBER: ", info); isdn_tty_at_cout("\r\nCALLED NUMBER: ", info);
isdn_tty_at_cout(info->emu.cpn, info); isdn_tty_at_cout(info->emu.cpn, info);
...@@ -3223,7 +3223,7 @@ isdn_tty_cmd_ATA(modem_info * info) ...@@ -3223,7 +3223,7 @@ isdn_tty_cmd_ATA(modem_info * info)
if (info->msr & UART_MSR_RI) { if (info->msr & UART_MSR_RI) {
/* Accept incoming call */ /* Accept incoming call */
info->last_dir = 0; info->last_dir = 0;
strcpy(info->last_num, dev->num[info->isdn_slot]); strcpy(info->last_num, isdn_slot_num(info->isdn_slot));
m->mdmreg[REG_RINGCNT] = 0; m->mdmreg[REG_RINGCNT] = 0;
info->msr &= ~UART_MSR_RI; info->msr &= ~UART_MSR_RI;
l2 = m->mdmreg[REG_L2PROT]; l2 = m->mdmreg[REG_L2PROT];
...@@ -3936,7 +3936,7 @@ isdn_tty_modem_escape(void) ...@@ -3936,7 +3936,7 @@ isdn_tty_modem_escape(void)
for (i = 0; i < ISDN_MAX_CHANNELS; i++) for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (USG_MODEM(isdn_slot_usage(i))) if (USG_MODEM(isdn_slot_usage(i)))
if ((midx = dev->m_idx[i]) >= 0) { if ((midx = isdn_slot_m_idx(i)) >= 0) {
modem_info *info = &dev->mdm.info[midx]; modem_info *info = &dev->mdm.info[midx];
if (info->online) { if (info->online) {
ton = 1; ton = 1;
......
...@@ -380,10 +380,10 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info) ...@@ -380,10 +380,10 @@ isdn_tty_cmd_FCLASS1(char **p, modem_info * info)
PARSE_ERROR1; PARSE_ERROR1;
} }
info->isdn_slot = i; info->isdn_slot = i;
dev->m_idx[i] = info->line; isdn_slot_set_m_idx(i, info->line);
isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &c); isdn_slot_command(info->isdn_slot, ISDN_CMD_FAXCMD, &c);
isdn_slot_free(info->isdn_slot, ISDN_USAGE_FAX); isdn_slot_free(info->isdn_slot, ISDN_USAGE_FAX);
dev->m_idx[info->isdn_slot] = -1; isdn_slot_set_m_idx(i, -1);
info->isdn_slot = -1; info->isdn_slot = -1;
restore_flags(flags); restore_flags(flags);
} else { } else {
......
...@@ -515,14 +515,12 @@ isdn_v110_encode(isdn_v110_stream * v, struct sk_buff *skb) ...@@ -515,14 +515,12 @@ isdn_v110_encode(isdn_v110_stream * v, struct sk_buff *skb)
} }
int int
isdn_v110_stat_callback(int idx, isdn_ctrl * c) isdn_v110_stat_callback(struct isdn_v110 *iv110, isdn_ctrl *c)
{ {
isdn_v110_stream *v = NULL; isdn_v110_stream *v = NULL;
int i; int i;
int ret; int ret;
if (idx < 0)
return 0;
switch (c->command) { switch (c->command) {
case ISDN_STAT_BSENT: case ISDN_STAT_BSENT:
/* Keep the send-queue of the driver filled /* Keep the send-queue of the driver filled
...@@ -531,9 +529,9 @@ isdn_v110_stat_callback(int idx, isdn_ctrl * c) ...@@ -531,9 +529,9 @@ isdn_v110_stat_callback(int idx, isdn_ctrl * c)
* send down an Idle-Frame (or an Sync-Frame, if * send down an Idle-Frame (or an Sync-Frame, if
* v->SyncInit != 0). * v->SyncInit != 0).
*/ */
if (!(v = dev->v110[idx])) if (!(v = iv110->v110))
return 0; return 0;
atomic_inc(&dev->v110use[idx]); atomic_inc(&iv110->v110use);
if (v->skbidle > 0) { if (v->skbidle > 0) {
v->skbidle--; v->skbidle--;
ret = 1; ret = 1;
...@@ -560,38 +558,38 @@ isdn_v110_stat_callback(int idx, isdn_ctrl * c) ...@@ -560,38 +558,38 @@ isdn_v110_stat_callback(int idx, isdn_ctrl * c)
} else } else
break; break;
} }
atomic_dec(&dev->v110use[idx]); atomic_dec(&iv110->v110use);
return ret; return ret;
case ISDN_STAT_DHUP: case ISDN_STAT_DHUP:
case ISDN_STAT_BHUP: case ISDN_STAT_BHUP:
while (1) { while (1) {
atomic_inc(&dev->v110use[idx]); atomic_inc(&iv110->v110use);
if (atomic_dec_and_test(&dev->v110use[idx])) { if (atomic_dec_and_test(&iv110->v110use)) {
isdn_v110_close(dev->v110[idx]); isdn_v110_close(iv110->v110);
dev->v110[idx] = NULL; iv110->v110 = NULL;
break; break;
} }
sti(); sti();
} }
break; break;
case ISDN_STAT_BCONN: case ISDN_STAT_BCONN:
if (dev->v110emu[idx] && (dev->v110[idx] == NULL)) { if (iv110->v110emu && (iv110->v110 == NULL)) {
int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen; int hdrlen = dev->drv[c->driver]->interface->hl_hdrlen;
int maxsize = dev->drv[c->driver]->interface->maxbufsize; int maxsize = dev->drv[c->driver]->interface->maxbufsize;
atomic_inc(&dev->v110use[idx]); atomic_inc(&iv110->v110use);
switch (dev->v110emu[idx]) { switch (iv110->v110emu) {
case ISDN_PROTO_L2_V11096: case ISDN_PROTO_L2_V11096:
dev->v110[idx] = isdn_v110_open(V110_9600, hdrlen, maxsize); iv110->v110 = isdn_v110_open(V110_9600, hdrlen, maxsize);
break; break;
case ISDN_PROTO_L2_V11019: case ISDN_PROTO_L2_V11019:
dev->v110[idx] = isdn_v110_open(V110_19200, hdrlen, maxsize); iv110->v110 = isdn_v110_open(V110_19200, hdrlen, maxsize);
break; break;
case ISDN_PROTO_L2_V11038: case ISDN_PROTO_L2_V11038:
dev->v110[idx] = isdn_v110_open(V110_38400, hdrlen, maxsize); iv110->v110 = isdn_v110_open(V110_38400, hdrlen, maxsize);
break; break;
default:; default:;
} }
if ((v = dev->v110[idx])) { if ((v = iv110->v110)) {
while (v->SyncInit) { while (v->SyncInit) {
struct sk_buff *skb = isdn_v110_sync(v); struct sk_buff *skb = isdn_v110_sync(v);
if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) { if (dev->drv[c->driver]->interface->writebuf_skb(c->driver, c->arg, 1, skb) <= 0) {
...@@ -603,8 +601,8 @@ isdn_v110_stat_callback(int idx, isdn_ctrl * c) ...@@ -603,8 +601,8 @@ isdn_v110_stat_callback(int idx, isdn_ctrl * c)
v->skbidle++; v->skbidle++;
} }
} else } else
printk(KERN_WARNING "isdn_v110: Couldn't open stream for chan %d\n", idx); printk(KERN_WARNING "isdn_v110: Couldn't open stream\n");
atomic_dec(&dev->v110use[idx]); atomic_dec(&iv110->v110use);
} }
break; break;
default: default:
......
...@@ -9,8 +9,14 @@ ...@@ -9,8 +9,14 @@
* *
*/ */
#ifndef _isdn_v110_h_ #ifndef ISDN_V110_H
#define _isdn_v110_h_ #define ISDN_V110_H
struct isdn_v110 {
int v110emu; /* V.110 emulator-mode 0=none */
atomic_t v110use; /* Usage-Semaphore for stream */
isdn_v110_stream *v110; /* V.110 private data */
};
/* /*
* isdn_v110_encode will take raw data and encode it using V.110 * isdn_v110_encode will take raw data and encode it using V.110
...@@ -23,7 +29,7 @@ extern struct sk_buff *isdn_v110_encode(isdn_v110_stream *, struct sk_buff *); ...@@ -23,7 +29,7 @@ extern struct sk_buff *isdn_v110_encode(isdn_v110_stream *, struct sk_buff *);
*/ */
extern struct sk_buff *isdn_v110_decode(isdn_v110_stream *, struct sk_buff *); extern struct sk_buff *isdn_v110_decode(isdn_v110_stream *, struct sk_buff *);
extern int isdn_v110_stat_callback(int, isdn_ctrl *); extern int isdn_v110_stat_callback(struct isdn_v110 *v110, isdn_ctrl *);
extern void isdn_v110_close(isdn_v110_stream * v); extern void isdn_v110_close(isdn_v110_stream * v);
#endif #endif
...@@ -605,21 +605,11 @@ typedef struct isdn_devt { ...@@ -605,21 +605,11 @@ typedef struct isdn_devt {
infostruct *infochain; /* List of open info-devs. */ infostruct *infochain; /* List of open info-devs. */
wait_queue_head_t info_waitq; /* Wait-Queue for isdninfo */ wait_queue_head_t info_waitq; /* Wait-Queue for isdninfo */
struct timer_list timer; /* Misc.-function Timer */ struct timer_list timer; /* Misc.-function Timer */
char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN];
/* Remote number of active ch.*/
int m_idx[ISDN_MAX_CHANNELS]; /* Index for mdm.... */
driver *drv[ISDN_MAX_DRIVERS]; /* Array of drivers */ driver *drv[ISDN_MAX_DRIVERS]; /* Array of drivers */
isdn_net_dev *netdev; /* Linked list of net-if's */ isdn_net_dev *netdev; /* Linked list of net-if's */
char drvid[ISDN_MAX_DRIVERS][20];/* Driver-ID */ char drvid[ISDN_MAX_DRIVERS][20];/* Driver-ID */
struct task_struct *profd; /* For iprofd */ struct task_struct *profd; /* For iprofd */
modem mdm; /* tty-driver-data */ modem mdm; /* tty-driver-data */
isdn_net_dev *rx_netdev[ISDN_MAX_CHANNELS]; /* rx netdev-pointers */
isdn_net_dev *st_netdev[ISDN_MAX_CHANNELS]; /* stat netdev-pointers */
ulong ibytes[ISDN_MAX_CHANNELS]; /* Statistics incoming bytes */
ulong obytes[ISDN_MAX_CHANNELS]; /* Statistics outgoing bytes */
int v110emu[ISDN_MAX_CHANNELS];/* V.110 emulator-mode 0=none */
atomic_t v110use[ISDN_MAX_CHANNELS];/* Usage-Semaphore for stream */
isdn_v110_stream *v110[ISDN_MAX_CHANNELS]; /* V.110 private data */
struct semaphore sem; /* serialize list access*/ struct semaphore sem; /* serialize list access*/
unsigned long global_features; unsigned long global_features;
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
......
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