Commit 33c7e1fa authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN: Gather per-slot data

Instead of having a number of arrays containg various bits of per-slot
data, start aggregating this data in a struct, and then have one
instance of this struct per slot.
parent a44a72fb
...@@ -44,8 +44,11 @@ MODULE_LICENSE("GPL"); ...@@ -44,8 +44,11 @@ MODULE_LICENSE("GPL");
isdn_dev *dev; isdn_dev *dev;
static int drvmap[ISDN_MAX_CHANNELS]; /* Map slot -> driver-index */ static struct {
static int chanmap[ISDN_MAX_CHANNELS]; /* Map slot -> channel-index */ int di; /* driver index */
int ch; /* channel index (per driver */
int usage; /* how is it used */
} slot[ISDN_MAX_CHANNELS];
static char *isdn_revision = "$Revision: 1.114.6.16 $"; static char *isdn_revision = "$Revision: 1.114.6.16 $";
...@@ -234,7 +237,7 @@ isdn_dc2minor(int di, int ch) ...@@ -234,7 +237,7 @@ isdn_dc2minor(int di, int ch)
{ {
int i; int i;
for (i = 0; i < ISDN_MAX_CHANNELS; i++) for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (chanmap[i] == ch && drvmap[i] == di) if (slot[i].ch == ch && slot[i].di == di)
return i; return i;
return -1; return -1;
} }
...@@ -448,7 +451,7 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -448,7 +451,7 @@ isdn_status_callback(isdn_ctrl * c)
case ISDN_STAT_RUN: case ISDN_STAT_RUN:
dev->drv[di]->flags |= DRV_FLAG_RUNNING; dev->drv[di]->flags |= DRV_FLAG_RUNNING;
for (i = 0; i < ISDN_MAX_CHANNELS; i++) for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (drvmap[i] == di) if (slot[i].di == di)
isdn_slot_all_eaz(i); isdn_slot_all_eaz(i);
set_global_features(); set_global_features();
break; break;
...@@ -665,20 +668,17 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -665,20 +668,17 @@ isdn_status_callback(isdn_ctrl * c)
save_flags(flags); save_flags(flags);
cli(); cli();
for (i = 0; i < ISDN_MAX_CHANNELS; i++) for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if ((drvmap[i] == di) && if ((slot[i].di == di) &&
(chanmap[i] == c->arg)) { (slot[i].ch == c->arg)) {
if (c->parm.num[0]) if (c->parm.num[0])
dev->usage[i] &= ~ISDN_USAGE_DISABLED; isdn_slot_set_usage(i, isdn_slot_usage(i) & ~ISDN_USAGE_DISABLED);
else else if (USG_NONE(isdn_slot_usage(i)))
if (USG_NONE(dev->usage[i])) { isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_DISABLED);
dev->usage[i] |= ISDN_USAGE_DISABLED; else
} retval = -1;
else break;
retval = -1;
break;
} }
restore_flags(flags); restore_flags(flags);
isdn_info_update();
break; break;
case ISDN_STAT_UNLOAD: case ISDN_STAT_UNLOAD:
while (dev->drv[di]->locks > 0) { while (dev->drv[di]->locks > 0) {
...@@ -693,10 +693,10 @@ isdn_status_callback(isdn_ctrl * c) ...@@ -693,10 +693,10 @@ isdn_status_callback(isdn_ctrl * c)
cli(); cli();
isdn_tty_stat_callback(i, c); isdn_tty_stat_callback(i, c);
for (i = 0; i < ISDN_MAX_CHANNELS; i++) for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (drvmap[i] == di) { if (slot[i].di == di) {
drvmap[i] = -1; slot[i].di = -1;
chanmap[i] = -1; slot[i].ch = -1;
dev->usage[i] &= ~ISDN_USAGE_DISABLED; slot[i].usage &= ~ISDN_USAGE_DISABLED;
isdn_unregister_devfs(i); isdn_unregister_devfs(i);
} }
dev->drivers--; dev->drivers--;
...@@ -760,14 +760,14 @@ isdn_getnum(char **p) ...@@ -760,14 +760,14 @@ isdn_getnum(char **p)
* It MUST be called with interrupts off. * It MUST be called with interrupts off.
*/ */
int int
isdn_slot_readbchan(int slot, u_char * buf, u_char * fp, int len) isdn_slot_readbchan(int sl, u_char * buf, u_char * fp, int len)
{ {
int count; int count;
int count_pull; int count_pull;
int count_put; int count_put;
int dflag; int dflag;
int di = isdn_slot_driver(slot); int di = isdn_slot_driver(sl);
int ch = isdn_slot_channel(slot); int ch = isdn_slot_channel(sl);
struct sk_buff *skb; struct sk_buff *skb;
u_char *cp; u_char *cp;
...@@ -860,13 +860,13 @@ isdn_slot_readbchan(int slot, u_char * buf, u_char * fp, int len) ...@@ -860,13 +860,13 @@ isdn_slot_readbchan(int slot, u_char * buf, u_char * fp, int len)
static __inline int static __inline int
isdn_minor2drv(int minor) isdn_minor2drv(int minor)
{ {
return drvmap[minor]; return slot[minor].di;
} }
static __inline int static __inline int
isdn_minor2chan(int minor) isdn_minor2chan(int minor)
{ {
return chanmap[minor]; return slot[minor].ch;
} }
static char * static char *
...@@ -879,25 +879,25 @@ isdn_statstr(void) ...@@ -879,25 +879,25 @@ isdn_statstr(void)
sprintf(istatbuf, "idmap:\t"); sprintf(istatbuf, "idmap:\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 ", (drvmap[i] < 0) ? "-" : dev->drvid[drvmap[i]]); sprintf(p, "%s ", (slot[i].di < 0) ? "-" : dev->drvid[slot[i].di]);
p = istatbuf + strlen(istatbuf); p = istatbuf + strlen(istatbuf);
} }
sprintf(p, "\nchmap:\t"); sprintf(p, "\nchmap:\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, "%d ", chanmap[i]); sprintf(p, "%d ", slot[i].ch);
p = istatbuf + strlen(istatbuf); p = istatbuf + strlen(istatbuf);
} }
sprintf(p, "\ndrmap:\t"); sprintf(p, "\ndrmap:\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, "%d ", drvmap[i]); sprintf(p, "%d ", slot[i].di);
p = istatbuf + strlen(istatbuf); p = istatbuf + strlen(istatbuf);
} }
sprintf(p, "\nusage:\t"); sprintf(p, "\nusage:\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, "%d ", dev->usage[i]); sprintf(p, "%d ", slot[i].usage);
p = istatbuf + strlen(istatbuf); p = istatbuf + strlen(istatbuf);
} }
sprintf(p, "\nflags:\t"); sprintf(p, "\nflags:\t");
...@@ -1736,34 +1736,28 @@ isdn_get_free_slot(int usage, int l2_proto, int l3_proto, ...@@ -1736,34 +1736,28 @@ isdn_get_free_slot(int usage, int l2_proto, int l3_proto,
* because we can emulate this in linklevel. * because we can emulate this in linklevel.
*/ */
for (i = 0; i < ISDN_MAX_CHANNELS; i++) for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (USG_NONE(dev->usage[i]) && if (USG_NONE(slot[i].usage) &&
(drvmap[i] != -1)) { (slot[i].di != -1)) {
int d = drvmap[i]; int d = slot[i].di;
if ((dev->usage[i] & ISDN_USAGE_EXCLUSIVE) && if ((slot[i].usage & ISDN_USAGE_EXCLUSIVE) &&
((pre_dev != d) || (pre_chan != chanmap[i]))) ((pre_dev != d) || (pre_chan != slot[i].ch)))
continue; continue;
if (!strcmp(isdn_map_eaz2msn(msn, d), "-")) if (!strcmp(isdn_map_eaz2msn(msn, d), "-"))
continue; continue;
if (dev->usage[i] & ISDN_USAGE_DISABLED) if (slot[i].usage & ISDN_USAGE_DISABLED)
continue; /* usage not allowed */ continue; /* usage not allowed */
if (dev->drv[d]->flags & DRV_FLAG_RUNNING) { if (dev->drv[d]->flags & DRV_FLAG_RUNNING) {
if (((dev->drv[d]->interface->features & features) == features) || if (((dev->drv[d]->interface->features & features) == features) ||
(((dev->drv[d]->interface->features & vfeatures) == vfeatures) && (((dev->drv[d]->interface->features & vfeatures) == vfeatures) &&
(dev->drv[d]->interface->features & ISDN_FEATURE_L2_TRANS))) { (dev->drv[d]->interface->features & ISDN_FEATURE_L2_TRANS))) {
if ((pre_dev < 0) || (pre_chan < 0)) { if ((pre_dev < 0) || (pre_chan < 0)) {
dev->usage[i] &= ISDN_USAGE_EXCLUSIVE; isdn_slot_set_usage(i, (isdn_slot_usage(i) & ISDN_USAGE_EXCLUSIVE) | usage);
dev->usage[i] |= usage; restore_flags(flags);
isdn_info_update(); return i;
} else if ((pre_dev == d) && (pre_chan == slot[i].ch)) {
isdn_slot_set_usage(i, (isdn_slot_usage(i) & ISDN_USAGE_EXCLUSIVE) | usage);
restore_flags(flags); restore_flags(flags);
return i; return i;
} else {
if ((pre_dev == d) && (pre_chan == chanmap[i])) {
dev->usage[i] &= ISDN_USAGE_EXCLUSIVE;
dev->usage[i] |= usage;
isdn_info_update();
restore_flags(flags);
return i;
}
} }
} }
} }
...@@ -1778,32 +1772,31 @@ isdn_get_free_slot(int usage, int l2_proto, int l3_proto, ...@@ -1778,32 +1772,31 @@ isdn_get_free_slot(int usage, int l2_proto, int l3_proto,
void void
isdn_free_channel(int di, int ch, int usage) isdn_free_channel(int di, int ch, int usage)
{ {
int slot; int sl;
slot = isdn_dc2minor(di, ch); sl = isdn_dc2minor(di, ch);
isdn_slot_free(slot, usage); isdn_slot_free(sl, usage);
} }
void void
isdn_slot_free(int slot, int usage) isdn_slot_free(int sl, int usage)
{ {
unsigned long flags; unsigned long flags;
save_flags(flags); save_flags(flags);
cli(); cli();
if (!usage || (dev->usage[slot] & ISDN_USAGE_MASK) == usage) { if (!usage || (slot[sl].usage & ISDN_USAGE_MASK) == usage) {
dev->usage[slot] &= (ISDN_USAGE_NONE | ISDN_USAGE_EXCLUSIVE); strcpy(dev->num[sl], "???");
strcpy(dev->num[slot], "???"); dev->ibytes[sl] = 0;
dev->ibytes[slot] = 0; dev->obytes[sl] = 0;
dev->obytes[slot] = 0;
// 20.10.99 JIM, try to reinitialize v110 ! // 20.10.99 JIM, try to reinitialize v110 !
dev->v110emu[slot] = 0; dev->v110emu[sl] = 0;
atomic_set(&(dev->v110use[slot]), 0); atomic_set(&(dev->v110use[sl]), 0);
isdn_v110_close(dev->v110[slot]); isdn_v110_close(dev->v110[sl]);
dev->v110[slot] = NULL; dev->v110[sl] = NULL;
// 20.10.99 JIM, try to reinitialize v110 ! // 20.10.99 JIM, try to reinitialize v110 !
isdn_info_update(); isdn_slot_set_usage(sl, isdn_slot_usage(sl) & (ISDN_USAGE_NONE | ISDN_USAGE_EXCLUSIVE));
skb_queue_purge(&dev->drv[isdn_slot_driver(slot)]->rpqueue[isdn_slot_channel(slot)]); skb_queue_purge(&dev->drv[isdn_slot_driver(sl)]->rpqueue[isdn_slot_channel(sl)]);
} }
restore_flags(flags); restore_flags(flags);
} }
...@@ -1820,10 +1813,9 @@ isdn_unexclusive_channel(int di, int ch) ...@@ -1820,10 +1813,9 @@ isdn_unexclusive_channel(int di, int ch)
save_flags(flags); save_flags(flags);
cli(); cli();
for (i = 0; i < ISDN_MAX_CHANNELS; i++) for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if ((drvmap[i] == di) && if ((slot[i].di == di) &&
(chanmap[i] == ch)) { (slot[i].ch == ch)) {
dev->usage[i] &= ~ISDN_USAGE_EXCLUSIVE; isdn_slot_set_usage(i, isdn_slot_usage(i) & ~ISDN_USAGE_EXCLUSIVE);
isdn_info_update();
restore_flags(flags); restore_flags(flags);
return; return;
} }
...@@ -1834,20 +1826,20 @@ isdn_unexclusive_channel(int di, int ch) ...@@ -1834,20 +1826,20 @@ isdn_unexclusive_channel(int di, int ch)
* Return: length of data on success, -ERRcode on failure. * Return: length of data on success, -ERRcode on failure.
*/ */
int int
isdn_slot_write(int slot, struct sk_buff *skb) isdn_slot_write(int sl, struct sk_buff *skb)
{ {
int ret; int ret;
struct sk_buff *nskb = NULL; struct sk_buff *nskb = NULL;
int v110_ret = skb->len; int v110_ret = skb->len;
int di = isdn_slot_driver(slot); int di = isdn_slot_driver(sl);
int ch = isdn_slot_channel(slot); int ch = isdn_slot_channel(sl);
BUG_ON(slot < 0); BUG_ON(sl < 0);
if (dev->v110[slot]) { if (dev->v110[sl]) {
atomic_inc(&dev->v110use[slot]); atomic_inc(&dev->v110use[sl]);
nskb = isdn_v110_encode(dev->v110[slot], skb); nskb = isdn_v110_encode(dev->v110[sl], skb);
atomic_dec(&dev->v110use[slot]); atomic_dec(&dev->v110use[sl]);
if (!nskb) if (!nskb)
return 0; return 0;
v110_ret = *((int *)nskb->data); v110_ret = *((int *)nskb->data);
...@@ -1859,7 +1851,7 @@ isdn_slot_write(int slot, struct sk_buff *skb) ...@@ -1859,7 +1851,7 @@ isdn_slot_write(int slot, struct sk_buff *skb)
/* V.110 must always be acknowledged */ /* V.110 must always be acknowledged */
ret = dev->drv[di]->interface->writebuf_skb(di, ch, 1, nskb); ret = dev->drv[di]->interface->writebuf_skb(di, ch, 1, nskb);
} else { } else {
int hl = isdn_slot_hdrlen(slot); int hl = isdn_slot_hdrlen(sl);
if( skb_headroom(skb) < hl ){ if( skb_headroom(skb) < hl ){
/* /*
...@@ -1887,10 +1879,10 @@ isdn_slot_write(int slot, struct sk_buff *skb) ...@@ -1887,10 +1879,10 @@ isdn_slot_write(int slot, struct sk_buff *skb)
} }
if (ret > 0) { if (ret > 0) {
dev->obytes[di] += ret; dev->obytes[di] += ret;
if (dev->v110[slot]) { if (dev->v110[sl]) {
atomic_inc(&dev->v110use[slot]); atomic_inc(&dev->v110use[sl]);
dev->v110[slot]->skbuser++; dev->v110[sl]->skbuser++;
atomic_dec(&dev->v110use[slot]); atomic_dec(&dev->v110use[sl]);
/* 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;
...@@ -1899,7 +1891,7 @@ isdn_slot_write(int slot, struct sk_buff *skb) ...@@ -1899,7 +1891,7 @@ isdn_slot_write(int slot, struct sk_buff *skb)
dev_kfree_skb(skb); dev_kfree_skb(skb);
} }
} else } else
if (dev->v110[slot]) if (dev->v110[sl])
dev_kfree_skb(nskb); dev_kfree_skb(nskb);
return ret; return ret;
} }
...@@ -1980,9 +1972,9 @@ isdn_add_channels(driver *d, int drvidx, int n, int adding) ...@@ -1980,9 +1972,9 @@ isdn_add_channels(driver *d, int drvidx, int n, int adding)
cli(); cli();
for (j = d->channels; j < m; j++) for (j = d->channels; j < m; j++)
for (k = 0; k < ISDN_MAX_CHANNELS; k++) for (k = 0; k < ISDN_MAX_CHANNELS; k++)
if (chanmap[k] < 0) { if (slot[k].ch < 0) {
chanmap[k] = j; slot[k].ch = j;
drvmap[k] = drvidx; slot[k].di = drvidx;
isdn_register_devfs(k); isdn_register_devfs(k);
break; break;
} }
...@@ -2124,54 +2116,71 @@ register_isdn(isdn_if * i) ...@@ -2124,54 +2116,71 @@ register_isdn(isdn_if * i)
} }
int int
isdn_slot_driver(int slot) isdn_slot_driver(int sl)
{ {
BUG_ON(slot < 0); BUG_ON(sl < 0);
return drvmap[slot]; return slot[sl].di;
} }
int int
isdn_slot_channel(int slot) isdn_slot_channel(int sl)
{ {
BUG_ON(slot < 0); BUG_ON(sl < 0);
return chanmap[slot]; return slot[sl].ch;
} }
int int
isdn_slot_hdrlen(int slot) isdn_slot_hdrlen(int sl)
{ {
int di = isdn_slot_driver(slot); int di = isdn_slot_driver(sl);
return dev->drv[di]->interface->hl_hdrlen; return dev->drv[di]->interface->hl_hdrlen;
} }
char * char *
isdn_slot_map_eaz2msn(int slot, char *msn) isdn_slot_map_eaz2msn(int sl, char *msn)
{ {
int di = isdn_slot_driver(slot); int di = isdn_slot_driver(sl);
return isdn_map_eaz2msn(msn, di); return isdn_map_eaz2msn(msn, di);
} }
int int
isdn_slot_command(int slot, int cmd, isdn_ctrl *ctrl) isdn_slot_command(int sl, int cmd, isdn_ctrl *ctrl)
{ {
ctrl->command = cmd; ctrl->command = cmd;
ctrl->driver = isdn_slot_driver(slot); ctrl->driver = isdn_slot_driver(sl);
ctrl->arg &= 0xff; ctrl->arg |= isdn_slot_channel(slot); ctrl->arg &= 0xff; ctrl->arg |= isdn_slot_channel(sl);
return isdn_command(ctrl); return isdn_command(ctrl);
} }
void void
isdn_slot_all_eaz(int slot) isdn_slot_all_eaz(int sl)
{ {
isdn_ctrl cmd; isdn_ctrl cmd;
cmd.parm.num[0] = '\0'; cmd.parm.num[0] = '\0';
isdn_slot_command(slot, ISDN_CMD_SETEAZ, &cmd); isdn_slot_command(sl, ISDN_CMD_SETEAZ, &cmd);
}
int
isdn_slot_usage(int sl)
{
BUG_ON(sl < 0);
return slot[sl].usage;
}
void
isdn_slot_set_usage(int sl, int usage)
{
BUG_ON(sl < 0);
slot[sl].usage = usage;
isdn_info_update();
} }
/* /*
...@@ -2295,8 +2304,8 @@ static int __init isdn_init(void) ...@@ -2295,8 +2304,8 @@ static int __init isdn_init(void)
init_MUTEX(&dev->sem); init_MUTEX(&dev->sem);
init_waitqueue_head(&dev->info_waitq); init_waitqueue_head(&dev->info_waitq);
for (i = 0; i < ISDN_MAX_CHANNELS; i++) { for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
drvmap[i] = -1; slot[i].di = -1;
chanmap[i] = -1; slot[i].ch = -1;
dev->m_idx[i] = -1; dev->m_idx[i] = -1;
strcpy(dev->num[i], "???"); strcpy(dev->num[i], "???");
init_waitqueue_head(&dev->mdm.info[i].open_wait); init_waitqueue_head(&dev->mdm.info[i].open_wait);
......
...@@ -52,3 +52,5 @@ extern int isdn_slot_readbchan(int slot, u_char *, u_char *, int); ...@@ -52,3 +52,5 @@ extern int isdn_slot_readbchan(int slot, u_char *, u_char *, int);
extern int isdn_slot_hdrlen(int slot); extern int isdn_slot_hdrlen(int slot);
extern int isdn_slot_driver(int slot); 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 void isdn_slot_set_usage(int slot, int usage);
...@@ -488,10 +488,9 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c) ...@@ -488,10 +488,9 @@ isdn_net_stat_callback(int idx, isdn_ctrl *c)
case 9: case 9:
case 10: case 10:
case 12: case 12:
if (lp->dialstate <= 6) { if (lp->dialstate <= 6)
dev->usage[idx] |= ISDN_USAGE_OUTGOING; isdn_slot_set_usage(idx, isdn_slot_usage(idx) | ISDN_USAGE_OUTGOING);
isdn_info_update(); else
} else
dev->rx_netdev[idx] = p; dev->rx_netdev[idx] = p;
lp->dialstate = 0; lp->dialstate = 0;
isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1); isdn_timer_ctrl(ISDN_TIMER_NETHANGUP, 1);
...@@ -698,8 +697,7 @@ isdn_net_dial(void) ...@@ -698,8 +697,7 @@ isdn_net_dial(void)
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(dev->num[lp->isdn_slot], cmd.parm.setup.phone);
dev->usage[lp->isdn_slot] |= ISDN_USAGE_OUTGOING; isdn_slot_set_usage(lp->isdn_slot, isdn_slot_usage(lp->isdn_slot) | ISDN_USAGE_OUTGOING);
isdn_info_update();
} }
printk(KERN_INFO "%s: dialing %d %s... %s\n", lp->name, printk(KERN_INFO "%s: dialing %d %s... %s\n", lp->name,
lp->dialretry, cmd.parm.setup.phone, lp->dialretry, cmd.parm.setup.phone,
...@@ -2084,17 +2082,14 @@ isdn_net_swapbind(int drvidx) ...@@ -2084,17 +2082,14 @@ isdn_net_swapbind(int drvidx)
static void static void
isdn_net_swap_usage(int i1, int i2) isdn_net_swap_usage(int i1, int i2)
{ {
int u1 = dev->usage[i1] & ISDN_USAGE_EXCLUSIVE; int u1 = isdn_slot_usage(i1);
int u2 = dev->usage[i2] & ISDN_USAGE_EXCLUSIVE; int u2 = isdn_slot_usage(i2);
#ifdef ISDN_DEBUG_NET_ICALL #ifdef ISDN_DEBUG_NET_ICALL
printk(KERN_DEBUG "n_fi: usage of %d and %d\n", i1, i2); printk(KERN_DEBUG "n_fi: usage of %d and %d\n", i1, i2);
#endif #endif
dev->usage[i1] &= ~ISDN_USAGE_EXCLUSIVE; isdn_slot_set_usage(i1, (u1 & ~ISDN_USAGE_EXCLUSIVE) | (u2 & ISDN_USAGE_EXCLUSIVE));
dev->usage[i1] |= u2; isdn_slot_set_usage(i2, (u2 & ~ISDN_USAGE_EXCLUSIVE) | (u1 & ISDN_USAGE_EXCLUSIVE));
dev->usage[i2] &= ~ISDN_USAGE_EXCLUSIVE;
dev->usage[i2] |= u1;
isdn_info_update();
} }
/* /*
...@@ -2206,7 +2201,7 @@ p = dev->netdev; ...@@ -2206,7 +2201,7 @@ p = dev->netdev;
#endif #endif
if ((!matchret) && /* EAZ is matching */ if ((!matchret) && /* EAZ is matching */
(((!(lp->flags & ISDN_NET_CONNECTED)) && /* but not connected */ (((!(lp->flags & ISDN_NET_CONNECTED)) && /* but not connected */
(USG_NONE(dev->usage[idx]))) || /* and ch. unused or */ (USG_NONE(isdn_slot_usage(idx)))) || /* and ch. unused or */
((((lp->dialstate == 4) || (lp->dialstate == 12)) && /* if dialing */ ((((lp->dialstate == 4) || (lp->dialstate == 12)) && /* if dialing */
(!(lp->flags & ISDN_NET_CALLBACK))) /* but no callback */ (!(lp->flags & ISDN_NET_CALLBACK))) /* but no callback */
))) )))
...@@ -2215,7 +2210,7 @@ p = dev->netdev; ...@@ -2215,7 +2210,7 @@ p = dev->netdev;
printk(KERN_DEBUG "n_fi: match1, pdev=%d pch=%d\n", printk(KERN_DEBUG "n_fi: match1, pdev=%d pch=%d\n",
lp->pre_device, lp->pre_channel); lp->pre_device, lp->pre_channel);
#endif #endif
if (dev->usage[idx] & ISDN_USAGE_EXCLUSIVE) { if (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) {
if ((lp->pre_channel != ch) || if ((lp->pre_channel != ch) ||
(lp->pre_device != di)) { (lp->pre_device != di)) {
/* Here we got a problem: /* Here we got a problem:
...@@ -2232,10 +2227,10 @@ p = dev->netdev; ...@@ -2232,10 +2227,10 @@ p = dev->netdev;
#ifdef ISDN_DEBUG_NET_ICALL #ifdef ISDN_DEBUG_NET_ICALL
printk(KERN_DEBUG "n_fi: ch is 0\n"); printk(KERN_DEBUG "n_fi: ch is 0\n");
#endif #endif
if (USG_NONE(dev->usage[sidx])) { if (USG_NONE(isdn_slot_usage(sidx))) {
/* Second Channel is free, now see if it is bound /* Second Channel is free, now see if it is bound
* exclusive too. */ * exclusive too. */
if (dev->usage[sidx] & ISDN_USAGE_EXCLUSIVE) { if (isdn_slot_usage(sidx) & ISDN_USAGE_EXCLUSIVE) {
#ifdef ISDN_DEBUG_NET_ICALL #ifdef ISDN_DEBUG_NET_ICALL
printk(KERN_DEBUG "n_fi: 2nd channel is down and bound\n"); printk(KERN_DEBUG "n_fi: 2nd channel is down and bound\n");
#endif #endif
...@@ -2263,7 +2258,7 @@ p = dev->netdev; ...@@ -2263,7 +2258,7 @@ p = dev->netdev;
#ifdef ISDN_DEBUG_NET_ICALL #ifdef ISDN_DEBUG_NET_ICALL
printk(KERN_DEBUG "n_fi: final check\n"); printk(KERN_DEBUG "n_fi: final check\n");
#endif #endif
if ((dev->usage[idx] & ISDN_USAGE_EXCLUSIVE) && if ((isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) &&
((lp->pre_channel != ch) || ((lp->pre_channel != ch) ||
(lp->pre_device != di))) { (lp->pre_device != di))) {
#ifdef ISDN_DEBUG_NET_ICALL #ifdef ISDN_DEBUG_NET_ICALL
...@@ -2408,10 +2403,8 @@ p = dev->netdev; ...@@ -2408,10 +2403,8 @@ p = dev->netdev;
isdn_slot_free(lp->isdn_slot, isdn_slot_free(lp->isdn_slot,
ISDN_USAGE_NET); ISDN_USAGE_NET);
} }
dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE;
dev->usage[idx] |= ISDN_USAGE_NET;
strcpy(dev->num[idx], nr); strcpy(dev->num[idx], nr);
isdn_info_update(); isdn_slot_set_usage(idx, (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) | ISDN_USAGE_NET);
dev->st_netdev[idx] = lp->netdev; dev->st_netdev[idx] = lp->netdev;
lp->isdn_slot = slot; lp->isdn_slot = slot;
lp->ppp_slot = -1; lp->ppp_slot = -1;
...@@ -2806,8 +2799,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg) ...@@ -2806,8 +2799,7 @@ isdn_net_setcfg(isdn_net_ioctl_cfg * cfg)
return -EBUSY; return -EBUSY;
} }
/* All went ok, so update isdninfo */ /* All went ok, so update isdninfo */
dev->usage[i] = ISDN_USAGE_EXCLUSIVE; isdn_slot_set_usage(i, ISDN_USAGE_EXCLUSIVE);
isdn_info_update();
restore_flags(flags); restore_flags(flags);
lp->exclusive = i; lp->exclusive = i;
} else { } else {
...@@ -3032,7 +3024,7 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer) ...@@ -3032,7 +3024,7 @@ isdn_net_getpeer(isdn_net_ioctl_phone *phone, isdn_net_ioctl_phone *peer)
/* 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(dev->num[idx],"???",3) == 0 ) return -ENOTCONN;
strncpy(phone->phone,dev->num[idx],ISDN_MSNLEN); strncpy(phone->phone,dev->num[idx],ISDN_MSNLEN);
phone->outgoing=USG_OUTGOING(dev->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;
} }
......
...@@ -658,10 +658,9 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m) ...@@ -658,10 +658,9 @@ isdn_tty_dial(char *n, modem_info * info, atemu * m)
} else { } else {
info->isdn_slot = i; info->isdn_slot = i;
dev->m_idx[i] = info->line; dev->m_idx[i] = info->line;
dev->usage[i] |= ISDN_USAGE_OUTGOING;
info->last_dir = 1; info->last_dir = 1;
strcpy(info->last_num, n); strcpy(info->last_num, n);
isdn_info_update(); isdn_slot_set_usage(i, isdn_slot_usage(i) | ISDN_USAGE_OUTGOING);
restore_flags(flags); restore_flags(flags);
isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd);
strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn));
...@@ -849,10 +848,9 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m) ...@@ -849,10 +848,9 @@ isdn_tty_resume(char *id, modem_info * info, atemu * m)
} else { } else {
info->isdn_slot = i; info->isdn_slot = i;
dev->m_idx[i] = info->line; dev->m_idx[i] = info->line;
dev->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);
isdn_info_update();
restore_flags(flags); restore_flags(flags);
isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd);
strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn));
...@@ -929,9 +927,8 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg) ...@@ -929,9 +927,8 @@ isdn_tty_send_msg(modem_info * info, atemu * m, char *msg)
} else { } else {
info->isdn_slot = i; info->isdn_slot = i;
dev->m_idx[i] = info->line; dev->m_idx[i] = info->line;
dev->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;
isdn_info_update();
restore_flags(flags); restore_flags(flags);
isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd); isdn_slot_command(info->isdn_slot, ISDN_CMD_CLREAZ, &cmd);
strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn)); strcpy(cmd.parm.num, isdn_slot_map_eaz2msn(info->isdn_slot, m->msn));
...@@ -2206,7 +2203,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) ...@@ -2206,7 +2203,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
(info->flags & ISDN_ASYNC_NORMAL_ACTIVE) && (info->flags & ISDN_ASYNC_NORMAL_ACTIVE) &&
#endif #endif
(info->isdn_slot == -1) && (info->isdn_slot == -1) &&
(USG_NONE(dev->usage[idx]))) { (USG_NONE(isdn_slot_usage(idx)))) {
int matchret; int matchret;
if ((matchret = isdn_tty_match_icall(eaz, &info->emu, di)) > wret) if ((matchret = isdn_tty_match_icall(eaz, &info->emu, di)) > wret)
...@@ -2214,14 +2211,12 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup) ...@@ -2214,14 +2211,12 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
if (!matchret) { /* EAZ is matching */ if (!matchret) { /* EAZ is matching */
info->isdn_slot = idx; info->isdn_slot = idx;
dev->m_idx[idx] = info->line; dev->m_idx[idx] = info->line;
dev->usage[idx] &= ISDN_USAGE_EXCLUSIVE;
dev->usage[idx] |= isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]);
strcpy(dev->num[idx], nr); strcpy(dev->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;
info->emu.mdmreg[REG_SCREEN] = setup->screen; info->emu.mdmreg[REG_SCREEN] = setup->screen;
isdn_info_update(); isdn_slot_set_usage(idx, (isdn_slot_usage(idx) & ISDN_USAGE_EXCLUSIVE) | isdn_calc_usage(si1, info->emu.mdmreg[REG_L2PROT]));
restore_flags(flags); restore_flags(flags);
printk(KERN_INFO "isdn_tty: call from %s, -> RING on ttyI%d\n", nr, printk(KERN_INFO "isdn_tty: call from %s, -> RING on ttyI%d\n", nr,
info->line); info->line);
...@@ -2349,14 +2344,14 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c) ...@@ -2349,14 +2344,14 @@ isdn_tty_stat_callback(int i, isdn_ctrl *c)
info->last_dir = 0; info->last_dir = 0;
info->dialing = 0; info->dialing = 0;
info->rcvsched = 1; info->rcvsched = 1;
if (USG_MODEM(dev->usage[i])) { if (USG_MODEM(isdn_slot_usage(i))) {
if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) { if (info->emu.mdmreg[REG_L2PROT] == ISDN_PROTO_L2_MODEM) {
strcpy(info->emu.connmsg, c->parm.num); strcpy(info->emu.connmsg, c->parm.num);
isdn_tty_modem_result(RESULT_CONNECT, info); isdn_tty_modem_result(RESULT_CONNECT, info);
} else } else
isdn_tty_modem_result(RESULT_CONNECT64000, info); isdn_tty_modem_result(RESULT_CONNECT64000, info);
} }
if (USG_VOICE(dev->usage[i])) if (USG_VOICE(isdn_slot_usage(i)))
isdn_tty_modem_result(RESULT_VCON, info); isdn_tty_modem_result(RESULT_VCON, info);
return 1; return 1;
} }
...@@ -3940,7 +3935,7 @@ isdn_tty_modem_escape(void) ...@@ -3940,7 +3935,7 @@ isdn_tty_modem_escape(void)
int midx; int midx;
for (i = 0; i < ISDN_MAX_CHANNELS; i++) for (i = 0; i < ISDN_MAX_CHANNELS; i++)
if (USG_MODEM(dev->usage[i])) if (USG_MODEM(isdn_slot_usage(i)))
if ((midx = dev->m_idx[i]) >= 0) { if ((midx = dev->m_idx[i]) >= 0) {
modem_info *info = &dev->mdm.info[midx]; modem_info *info = &dev->mdm.info[midx];
if (info->online) { if (info->online) {
......
...@@ -74,7 +74,7 @@ isdn_tty_fax_modem_result(int code, modem_info * info) ...@@ -74,7 +74,7 @@ isdn_tty_fax_modem_result(int code, modem_info * info)
case 2: /* +FCON */ case 2: /* +FCON */
/* Append CPN, if enabled */ /* Append CPN, if enabled */
if ((m->mdmreg[REG_CPNFCON] & BIT_CPNFCON) && if ((m->mdmreg[REG_CPNFCON] & BIT_CPNFCON) &&
(!(dev->usage[info->isdn_slot] & ISDN_USAGE_OUTGOING))) { (!(isdn_slot_usage(info->isdn_slot) & ISDN_USAGE_OUTGOING))) {
sprintf(rs, "/%s", m->cpn); sprintf(rs, "/%s", m->cpn);
isdn_tty_at_cout(rs, info); isdn_tty_at_cout(rs, info);
} }
......
...@@ -605,7 +605,6 @@ typedef struct isdn_devt { ...@@ -605,7 +605,6 @@ 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 */
int usage[ISDN_MAX_CHANNELS]; /* Used by tty/ip/voice */
char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN]; char num[ISDN_MAX_CHANNELS][ISDN_MSNLEN];
/* Remote number of active ch.*/ /* Remote number of active ch.*/
int m_idx[ISDN_MAX_CHANNELS]; /* Index for mdm.... */ int m_idx[ISDN_MAX_CHANNELS]; /* Index for mdm.... */
......
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